@ -1,12 +1,24 @@
|
||||
const {CalculateQuality} = require('@dsabot/CalculateQuality');
|
||||
require('module-alias/register');
|
||||
const { CalculateQuality } = require('@dsabot/CalculateQuality');
|
||||
|
||||
const TestValues = [
|
||||
[1,1], [2,1], [3,1],
|
||||
[4,2], [5,2], [6,2],
|
||||
[7,3], [8,3], [9,3],
|
||||
[10,4],[11,4],[12,4],
|
||||
[13,5],[14,5],[15,5]
|
||||
[1, 1],
|
||||
[2, 1],
|
||||
[3, 1],
|
||||
[4, 2],
|
||||
[5, 2],
|
||||
[6, 2],
|
||||
[7, 3],
|
||||
[8, 3],
|
||||
[9, 3],
|
||||
[10, 4],
|
||||
[11, 4],
|
||||
[12, 4],
|
||||
[13, 5],
|
||||
[14, 5],
|
||||
[15, 5],
|
||||
];
|
||||
|
||||
test.each(TestValues)('Retrieving Quality for %s', (input, output) => {
|
||||
expect(CalculateQuality(input)).toBe(output);
|
||||
});
|
||||
});
|
||||
|
6
__tests__/functions/Capitalize.js
Normal file
6
__tests__/functions/Capitalize.js
Normal file
@ -0,0 +1,6 @@
|
||||
require('module-alias/register');
|
||||
const { Capitalize } = require('@dsabot/Capitalize');
|
||||
|
||||
it('should capitalize the first letter.', () => {
|
||||
expect(Capitalize('mother')).toBe('Mother');
|
||||
});
|
60
__tests__/functions/CompareResults.js
Normal file
60
__tests__/functions/CompareResults.js
Normal file
@ -0,0 +1,60 @@
|
||||
require('module-alias/register');
|
||||
|
||||
const { CompareResults } = require('@dsabot/CompareResults');
|
||||
|
||||
it('should return an object', () => {
|
||||
let Obj = {
|
||||
Passed: 0,
|
||||
CriticalHit: 0,
|
||||
Fumbles: 0,
|
||||
PointsUsed: [],
|
||||
PointsRemaining: 0,
|
||||
};
|
||||
expect(CompareResults).toBeInstanceOf(Object);
|
||||
expect(CompareResults()).toMatchObject(Obj);
|
||||
});
|
||||
|
||||
it('should match No. of Fumbles', () => {
|
||||
let Obj = {
|
||||
Passed: 0,
|
||||
CriticalHit: 0,
|
||||
Fumbles: 2,
|
||||
PointsUsed: [0, 0, 0],
|
||||
PointsRemaining: 0,
|
||||
};
|
||||
expect(CompareResults([9, 20, 20])).toMatchObject(Obj);
|
||||
});
|
||||
|
||||
it('should match No. of Passed', () => {
|
||||
let Obj = {
|
||||
Passed: 3,
|
||||
CriticalHit: 0,
|
||||
Fumbles: 0,
|
||||
PointsUsed: [0, 0, 0],
|
||||
PointsRemaining: 0,
|
||||
};
|
||||
expect(CompareResults([7, 7, 7])).toMatchObject(Obj);
|
||||
});
|
||||
|
||||
it('should match No. of Critical Hits', () => {
|
||||
let Obj = {
|
||||
Passed: 3,
|
||||
CriticalHit: 2,
|
||||
Fumbles: 0,
|
||||
PointsUsed: [0, 0, 0],
|
||||
PointsRemaining: 0,
|
||||
};
|
||||
expect(CompareResults([8, 1, 1])).toMatchObject(Obj);
|
||||
});
|
||||
|
||||
it('should decrease Points remaining', () => {
|
||||
let Obj = {
|
||||
Passed: 3,
|
||||
CriticalHit: 0,
|
||||
Fumbles: 0,
|
||||
PointsUsed: [0, 0, 3],
|
||||
PointsRemaining: 3,
|
||||
};
|
||||
|
||||
expect(CompareResults([11, 9, 15], [12, 12, 12], 0, 6)).toMatchObject(Obj);
|
||||
});
|
@ -1,6 +1,4 @@
|
||||
const {
|
||||
CountOccurences
|
||||
} = require('../../functions/CountOccurences');
|
||||
const { CountOccurences } = require('../../functions/CountOccurences');
|
||||
test('Counting Occurences', () => {
|
||||
expect(CountOccurences([1, 2, 3, 4, 1], 1)).toBe(2);
|
||||
});
|
||||
expect(CountOccurences([1, 2, 3, 4, 1], 1)).toBe(2);
|
||||
});
|
||||
|
9
__tests__/functions/CreateResultTable.js
Normal file
9
__tests__/functions/CreateResultTable.js
Normal file
@ -0,0 +1,9 @@
|
||||
require('module-alias/register');
|
||||
|
||||
const { CreateResultTable, f } = require('@dsabot/CreateResultTable');
|
||||
|
||||
it('turn any number into a string', () => {
|
||||
expect(f(2)).toBe('+2');
|
||||
expect(f(0)).toBe('0');
|
||||
expect(f(-1)).toBe('-1');
|
||||
});
|
19
__tests__/functions/Random.js
Normal file
19
__tests__/functions/Random.js
Normal file
@ -0,0 +1,19 @@
|
||||
require('module-alias/register');
|
||||
|
||||
const { Random } = require('@dsabot/Random');
|
||||
|
||||
it('should return with no min or max value', () => {
|
||||
expect(Random.int()).toBeUndefined();
|
||||
});
|
||||
it('call for use should return true', () => {
|
||||
expect(Random.use(null)).toBeTruthy();
|
||||
});
|
||||
it('should return between 1 and 2', () => {
|
||||
expect(Random.int(1, 2)).toBeGreaterThanOrEqual(1);
|
||||
});
|
||||
it('should return between 1 and 2', () => {
|
||||
expect(Random.int(1, 2)).toBeLessThanOrEqual(2);
|
||||
});
|
||||
it('should return exactly 1', () => {
|
||||
expect(Random.int(1, 1)).toBe(1);
|
||||
});
|
@ -1,8 +1,8 @@
|
||||
const { roll } = require('@dsabot/Roll');
|
||||
|
||||
describe('rolling dice', () => {
|
||||
const expected = [1, 2, 3, 4, 5, 6];
|
||||
test.each(expected)('contains only numbers from 1 to 6', (value) => {
|
||||
expect(roll(200, 6).dice).toContain(value);
|
||||
});
|
||||
});
|
||||
const expected = [1, 2, 3, 4, 5, 6];
|
||||
test.each(expected)('contains only numbers from 1 to 6', value => {
|
||||
expect(roll(200, 6).dice).toContain(value);
|
||||
});
|
||||
});
|
||||
|
23
__tests__/functions/getAttributeLevels.js
Normal file
23
__tests__/functions/getAttributeLevels.js
Normal file
@ -0,0 +1,23 @@
|
||||
require('module-alias/register');
|
||||
const { getAttributeLevels } = require('@dsabot/getAttributeLevels');
|
||||
|
||||
const Character = {
|
||||
attributes: [
|
||||
{ id: 'mut', level: 10 },
|
||||
{ id: 'klugheit', level: 11 },
|
||||
{ id: 'intuition', level: 12 },
|
||||
{ id: 'charisma', level: 13 },
|
||||
{ id: 'fingerfertigkeit', level: 14 },
|
||||
{ id: 'gewandtheit', level: 15 },
|
||||
{ id: 'konstitution', level: 16 },
|
||||
{ id: 'koerperkraft', level: 17 },
|
||||
],
|
||||
};
|
||||
|
||||
it('should return an array', () => {
|
||||
expect(getAttributeLevels(['MU', 'IN', 'KO'], Character)).toBeInstanceOf(Array);
|
||||
});
|
||||
|
||||
it('should have 3 items in it.', () => {
|
||||
expect(getAttributeLevels(['MU', 'IN', 'KO'], Character)).toHaveLength(3);
|
||||
});
|
Reference in New Issue
Block a user