-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathindex.test.ts
More file actions
23 lines (21 loc) · 945 Bytes
/
Copy pathindex.test.ts
File metadata and controls
23 lines (21 loc) · 945 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Uncomment the code below and write your tests
import { simpleCalculator, Action } from './index';
const testCases = [
{ a: 1, b: 2, action: Action.Add, expected: 3 },
{ a: 2, b: 2, action: Action.Add, expected: 4 },
{ a: 3, b: 2, action: Action.Add, expected: 5 },
// cases from previous test
{ a: 4, b: 2, action: Action.Add, expected: 6 },
{ a: 4, b: 2, action: Action.Subtract, expected: 2 },
{ a: 4, b: 2, action: Action.Multiply, expected: 8 },
{ a: 4, b: 2, action: Action.Divide, expected: 2 },
{ a: 4, b: 2, action: Action.Exponentiate, expected: 16 },
{ a: 4, b: 2, action: '', expected: null },
{ a: '', b: 2, action: Action.Exponentiate, expected: null },
];
describe('simpleCalculator', () => {
// Consider to use Jest table tests API to test all cases above
test.each(testCases)('table tests', ({ a, b, action, expected }) => {
expect(simpleCalculator({ a, b, action })).toBe(expected);
});
});