-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathmath.test.js
95 lines (71 loc) · 1.74 KB
/
math.test.js
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
const { sum, sub, prod, digital_root, sum42, sayHelloTo, anomalyCode } = require('./math');
// test('adds 1 + 2 to equal 3', () => {
// expect(sum(1, 2)).toBe(3);
// });
/**
* Sum to be defined
*/
test('Sum function exists', () => {
expect(sum).toBeDefined();
});
test('adds 1 + 2 to equal 3', sumTest);
function sumTest() {
expect(sum(1, 2)).toBe(3);
}
function helloTest() {
expect(sayHelloTo("Dan")).toBe("Hello, Dan!");
}
test('sayHelloTo function exists', () => {
expect(sayHelloTo).toBeDefined();
});
test('sayHelloTo Dan should be Hello, Dan!', () => {
helloTest();
});
/**
* Prod to be defined
*/
test('Prod function exists',()=>{
expect(prod).toBeDefined();
});
/**
* prod function output
*/
test('prod calculates 2 * 10 = 20', () => {
expect(prod(2, 10)).toBe(20);
});
/**
* Digital Root to be defined
*/
test('digital_root function exists', ()=>{
expect('digital_root').toBeDefined();
});
test('digital root of 265 should equal 4', () => {
expect(digital_root(265)).toBe(4);
})
test('Sum42 function exists', () => {
expect(sum42).toBeDefined();
});
test('Sum42 3 + 1 should be 46', () => {
expect(sum42(3, 1)).toBe(46);
});
test('Sub function exists', () => {
expect(sub).toBeDefined();
})
test('Sub 10 - 3 should be 7', () => {
expect(sub(10,3)).toBe(7);
})
test('anomalyCode function exists', () => {
expect(anomalyCode(1)).toBeDefined();
})
test('anomalyCode one should be 50', () => {
expect(anomalyCode(7)).toBe(50);
})
test('anomalyCode ten should be 500', () => {
expect(anomalyCode(78)).toBe(500);
})
test('anomalyCode hundred should be 5000', () => {
expect(anomalyCode(789)).toBe(5000);
})
test('anomalyCode thousand should be 50000', () => {
expect(anomalyCode(7891)).toBe(50000);
})