-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathindex.test.ts
More file actions
54 lines (47 loc) · 1.48 KB
/
index.test.ts
File metadata and controls
54 lines (47 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Uncomment the code below and write your tests
import { simpleCalculator, Action } from './index';
describe('simpleCalculator tests', () => {
test('should add two numbers', () => {
// Write your test here
const result = simpleCalculator({ a: 2, b: 7, action: Action.Add });
expect(result).toBe(9);
});
test('should subtract two numbers', () => {
// Write your test here
const result = simpleCalculator({ a: 18, b: 12, action: Action.Subtract });
expect(result).toBe(6);
});
test('should multiply two numbers', () => {
// Write your test here
const result = simpleCalculator({ a: 3, b: 8, action: Action.Multiply });
expect(result).toBe(24);
});
test('should divide two numbers', () => {
// Write your test here
const result = simpleCalculator({ a: 12, b: 3, action: Action.Divide });
expect(result).toBe(4);
});
test('should exponentiate two numbers', () => {
// Write your test here
const result = simpleCalculator({
a: 2,
b: 3,
action: Action.Exponentiate,
});
expect(result).toBe(8);
});
test('should return null for invalid action', () => {
// Write your test here
const result = simpleCalculator({ a: 1, b: 2, action: '%' });
expect(result).toBeNull();
});
test('should return null for invalid arguments', () => {
// Write your test here
const result = simpleCalculator({
a: '1',
b: 2,
action: Action.Add,
});
expect(result).toBeNull();
});
});