-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalculator.test.js
47 lines (38 loc) · 1.04 KB
/
calculator.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
const { TestWatcher } = require('jest');
const mathOperations = require('./calculator');
describe("Calculator tests", () => {
var input1 = 0
var input2 = 0
beforeAll(() => {
console.log("beforeAll called");
});
afterAll(() => {
console.log("afterAll called");
});
beforeEach(() => {
console.log("beforeEach called");
input1 = 1;
input2 = 2;
});
afterEach(() => {
console.log("afterEach called");
});
test('adding 1 + 2 should return 3', () => {
// arrange and act
var result = mathOperations.sum(1,2)
// assert
expect(result).toBe(3);
});
test("subtracting 2 from 10 should return 8", () => {
// arrange and act
var result = mathOperations.diff(10,2)
// assert
expect(result).toBe(8);
});
test("multiplying 2 and 8 should return 16", () => {
// arrange and act
var result = mathOperations.product(2,8)
// assert
expect(result).toBe(16);
});
})