-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday.js
More file actions
68 lines (54 loc) · 1.79 KB
/
day.js
File metadata and controls
68 lines (54 loc) · 1.79 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Jasmine - Behavior-Driven JavaScript
// https://jasmine.github.io/
const Calculator = require('./calculator');
describe('Calculator', () => {
let calculator;
beforeEach(() => {
calculator = new Calculator();
});
it('should be defined', () => {
expect(calculator).toBeDefined();
expect(calculator).not.toBeUndefined();
expect(calculator).toBeTruthy();
expect(calculator).not.toBeFalsy();
});
it('should return false', () => {
expect(calculator.add()).toBeFalsy();
expect(calculator.add(1)).toBeFalsy();
expect(calculator.add('text')).toBeFalsy();
expect(calculator.add('text', 1)).toBeFalsy();
expect(calculator.sub()).toBeFalsy();
expect(calculator.sub(1)).toBeFalsy();
expect(calculator.sub('text')).toBeFalsy();
expect(calculator.sub('text', 1)).toBeFalsy();
expect(calculator.mult()).toBeFalsy();
expect(calculator.mult(1)).toBeFalsy();
expect(calculator.mult('text')).toBeFalsy();
expect(calculator.mult('text', 1)).toBeFalsy();
expect(calculator.div()).toBeFalsy();
expect(calculator.div(1)).toBeFalsy();
expect(calculator.div('text')).toBeFalsy();
expect(calculator.div('text', 1)).toBeFalsy();
});
it('adds 1 and 1', () => {
expect(calculator.add(1, 1)).toEqual(2);
});
it('subtracts 3 from 5', () => {
expect(calculator.sub(5, 3)).toEqual(2);
});
it('subtracts 10 from 5', () => {
expect(calculator.sub(5, 10)).toEqual(-5);
});
it('multiplies 12 and 5', () => {
expect(calculator.mult(12, 5)).toEqual(60);
});
it('multiplies 5 and 0', () => {
expect(calculator.mult(5, 0)).toEqual(0);
});
it('divides 25 by 5', () => {
expect(calculator.div(25, 5)).toEqual(5);
});
it('does not divide by 0', () => {
expect(calculator.div(25, 0)).toEqual(NaN);
});
});