forked from bloominstituteoftechnology/Basic-JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproject-1.test.js
More file actions
223 lines (198 loc) · 6.42 KB
/
project-1.test.js
File metadata and controls
223 lines (198 loc) · 6.42 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
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
/* eslint-disable no-undef */
const {
multiplyByTen,
subtractFive,
areSameLength,
areEqual,
lessThanNinety,
greaterThanFifty,
add,
subtract,
divide,
multiply,
getRemainder,
isEven,
isOdd,
square,
cube,
raiseToPower,
roundNumber,
roundUp,
addExclamationPoint,
combineNames,
getGreeting,
getRectangleArea,
getTriangleArea,
getCircleArea,
getRectangularPrismVolume
} = require('../src/project-1');
describe('Project 1', () => {
describe('multiplyByTen(num)', () => {
it('should return the argument after multiplying by ten', () => {
expect(multiplyByTen(10)).toBe(100);
expect(multiplyByTen(0)).toBe(0);
});
});
describe('subtractFive(num)', () => {
it('should return the argument after subtracting five', () => {
expect(subtractFive(10)).toBe(5);
expect(subtractFive(0)).toBe(-5);
});
});
describe('areSameLength(str1, str2)', () => {
it('should return true if the arguments have the same length', () => {
expect(areSameLength('hi', 'there')).toBe(false);
expect(areSameLength('javascript', 'bumfuzzled')).toBe(true);
});
});
describe('areEqual(x, y)', () => {
it('should return true if the arguments are equal', () => {
expect(areEqual(15, 15)).toBe(true);
expect(areEqual(90, 50)).toBe(false);
expect(areEqual('test', 'test')).toBe(true);
});
});
describe('lessThanNinety(num)', () => {
it('should return true if the argument is less than ninety', () => {
expect(lessThanNinety(15)).toBe(true);
expect(lessThanNinety(90)).toBe(false);
expect(lessThanNinety(100)).toBe(false);
});
});
describe('greaterThanFifty(num)', () => {
it('should return true if the argument is greater than fifty', () => {
expect(greaterThanFifty(15)).toBe(false);
expect(greaterThanFifty(50)).toBe(false);
expect(greaterThanFifty(60)).toBe(true);
});
});
describe('add(x, y)', () => {
it('should return the sum of the two arguments', () => {
expect(add(5, 5)).toBe(10);
expect(add(-1, 5)).toBe(4);
});
});
describe('subtract(x, y)', () => {
it('should return the difference of the two arguments', () => {
expect(subtract(5, 5)).toBe(0);
expect(subtract(-1, 5)).toBe(-6);
expect(subtract(5, -5)).toBe(10);
expect(subtract(0, 0)).toBe(0);
});
});
describe('divide(x, y)', () => {
it('should return the quotient of the two arguments', () => {
expect(divide(5, 5)).toBe(1);
expect(divide(10, 5)).toBe(2);
expect(divide(11, 2)).toBe(5.5);
});
});
describe('multiply(x, y)', () => {
it('should return the product of the two arguments', () => {
expect(multiply(5, 5)).toBe(25);
expect(multiply(10, -5)).toBe(-50);
expect(multiply(11, 0)).toBe(0);
});
});
describe('getRemainder(x, y)', () => {
it('should return the division remainder of the two arguments', () => {
expect(getRemainder(5, 5)).toBe(0);
expect(getRemainder(10, 5)).toBe(0);
expect(getRemainder(11, 2)).toBe(1);
});
});
describe('isEven(num)', () => {
it('should return the bool true if the argument is even, false otherwise', () => {
expect(isEven(6)).toBe(true);
expect(isEven(7)).toBe(false);
expect(isEven(0)).toBe(true);
});
});
describe('isOdd(num)', () => {
it('should return the bool true if the argument is odd, false otherwise', () => {
expect(isOdd(6)).toBe(false);
expect(isOdd(7)).toBe(true);
expect(isOdd(0)).toBe(false);
});
});
describe('square(num)', () => {
it('should return the argument after squaring it', () => {
expect(square(6)).toBe(36);
expect(square(7)).toBe(49);
expect(square(0)).toBe(0);
expect(square(-5)).toBe(25);
});
});
describe('cube(num)', () => {
it('should return the argument after cubing it', () => {
expect(cube(3)).toBe(27);
expect(cube(0)).toBe(0);
expect(cube(-5)).toBe(-125);
});
});
describe('raiseToPower(num, exponent)', () => {
it('should return the argument after raising it to the exponent\'s power', () => {
expect(raiseToPower(2, 2)).toBe(4);
expect(raiseToPower(2, 3)).toBe(8);
expect(raiseToPower(0, 5)).toBe(0);
expect(raiseToPower(10, 1)).toBe(10);
});
});
describe('roundNumber(num)', () => {
it('should return the argument after rounding it', () => {
expect(roundNumber(1.5)).toBe(2);
expect(roundNumber(2)).toBe(2);
expect(roundNumber(0.1)).toBe(0);
});
});
describe('roundUp(num)', () => {
it('should return the argument after rounding it up', () => {
expect(roundUp(1.5)).toBe(2);
expect(roundUp(2)).toBe(2);
expect(roundUp(0.1)).toBe(1);
});
});
describe('addExclamationPoint(str)', () => {
it('should add an exclamation point to the end of the string', () => {
expect(addExclamationPoint('hello world')).toBe('hello world!');
expect(addExclamationPoint('LambdaSchool')).toBe('LambdaSchool!');
});
});
describe('combineNames(firstName, lastName)', () => {
it('should return the two strings combined into one with a space separating them', () => {
expect(combineNames('hello', 'world')).toBe('hello world');
expect(combineNames('Lambda', 'School')).toBe('Lambda School');
});
});
describe('getGreeting(name)', () => {
it('should return the string \'Hello {name}!\'', () => {
expect(getGreeting('Ben')).toBe('Hello Ben!');
expect(getGreeting('LambdaSchool')).toBe('Hello LambdaSchool!');
});
});
describe('getRectangleArea(length, width)', () => {
it('should return the correct area', () => {
expect(getRectangleArea(2, 2)).toBe(4);
expect(getRectangleArea(3, 6)).toBe(18);
expect(getRectangleArea(0, 2)).toBe(0);
});
});
describe('getTriangleArea(base, height)', () => {
it('should return the correct area', () => {
expect(getTriangleArea(2, 2)).toBe(2);
expect(getTriangleArea(0, 2)).toBe(0);
});
});
describe('getCircleArea(radius)', () => {
it('should return the correct area', () => {
expect(getCircleArea(4)).toBe(50);
expect(getCircleArea(0)).toBe(0);
});
});
describe('getRectangularPrismVolume(length, width, height)', () => {
it('should return the correct volume', () => {
expect(getRectangularPrismVolume(2, 2, 2)).toBe(8);
expect(getRectangularPrismVolume(0, 5, 10)).toBe(0);
});
});
});