-
Notifications
You must be signed in to change notification settings - Fork 2
/
basics.test.js
151 lines (118 loc) · 4.66 KB
/
basics.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
var basics = require('./basics');
describe('add', function() {
test('2 + 2 should equal 4', function() {
expect(basics.add(2, 2)).toEqual(4);
});
test('5 + -30 should be -25', function() {
expect(basics.add(5, -30)).toEqual(-25);
});
});
describe('double', function() {
test('double 10 should be 20', function() {
expect(basics.double(10)).toEqual(20);
});
test('double -4 should be -8', function() {
expect(basics.double(-4)).toEqual(-8);
});
});
describe('multThree', function() {
test('multiplying 3, 5, and 7 should give 105', function() {
expect(basics.multThree(3, 5, 7)).toEqual(105);
});
test('multiplying 100, -1, and -1 should be 100', function() {
expect(basics.multThree(100, -1, -1)).toEqual(100);
});
test('multiplying 1, 2, and 2.2 should be 4.4', function() {
expect(basics.multThree(1, 2, 2.2)).toEqual(4.4);
});
});
describe('earnings', function() {
test('100 A seats, 100 B seats, and 100 C seats should earn $3600 dollars', function() {
expect(basics.earnings(100, 100, 100)).toEqual(3600);
});
test('50 A seats, 75 B seats, and 100 C seats should earn $2550 dollars', function() {
expect(basics.earnings(50, 75, 100)).toEqual(2550);
});
test('0 A seats, 1000 B seats, and 79 C seats should earn $12711 dollars', function() {
expect(basics.earnings(0, 1000, 79)).toEqual(12711);
});
});
describe('both', function() {
test('true and false is false', function() {
expect(basics.both(true, false)).toEqual(false);
});
test('true and true is false', function() {
expect(basics.both(true, true)).toEqual(true);
});
test('false and false is false', function() {
expect(basics.both(false, false)).toEqual(false);
});
test('false and true is false', function() {
expect(basics.both(false, true)).toEqual(false);
});
});
describe('walkOrDrive', function() {
test('.2 miles and nice weather means you should walk', function() {
expect(basics.walkOrDrive(0.2, true)).toEqual('walk');
});
test('.2 miles and bad weather means you should drive', function() {
expect(basics.walkOrDrive(0.2, false)).toEqual('drive');
});
test('.3 miles and nice weather means you should drive', function() {
expect(basics.walkOrDrive(0.3, true)).toEqual('drive');
});
test('.3 miles and bad weather means you should drive', function() {
expect(basics.walkOrDrive(0.3, false)).toEqual('drive');
});
test('.25 miles and good weather means you should walk', function() {
expect(basics.walkOrDrive(0.25, true)).toEqual('walk');
});
});
describe('howPopulated', function() {
test('howPopulated(100, 1) should equal Sparsely Populated', function() {
expect(basics.howPopulated(100, 1)).toEqual('Sparsely Populated');
});
test('howPopulated(101, 1) should equal Densely Populated', function() {
expect(basics.howPopulated(101, 1)).toEqual('Densely Populated');
});
test('howPopulated(1000, 10) should equal Sparsely Populated', function() {
expect(basics.howPopulated(1000, 10)).toEqual('Sparsely Populated');
});
test('howPopulated(1001, 10) should equal Densely Populated', function() {
expect(basics.howPopulated(1001, 10)).toEqual('Densely Populated');
});
});
describe('goldStars', function() {
test('900 points should yield 1 gold stars', function() {
expect(basics.goldStars(900)).toEqual('*');
});
test('1900 points should yield 2 gold stars', function() {
expect(basics.goldStars(1900)).toEqual('**');
});
test('7999 points should yield 3 gold stars', function() {
expect(basics.goldStars(7999)).toEqual('***');
});
test('9001 points should yield 4 gold stars', function() {
expect(basics.goldStars(9001)).toEqual('****');
});
test('1234567 points should yield 5 gold stars', function() {
expect(basics.goldStars(1234567)).toEqual('*****');
});
});
describe('howManyPoints', function() {
test('extra kick should yield 1 points', function() {
expect(basics.howManyPoints('extra kick')).toEqual(1);
});
test('extra conv should yield 2 points', function() {
expect(basics.howManyPoints('extra conv')).toEqual(2);
});
test('safety should yield 2 points', function() {
expect(basics.howManyPoints('safety')).toEqual(2);
});
test('fg should yield 3 points', function() {
expect(basics.howManyPoints('fg')).toEqual(3);
});
test('td should yield 6 points', function() {
expect(basics.howManyPoints('td')).toEqual(6);
});
});