-
Notifications
You must be signed in to change notification settings - Fork 1
/
js-1.test.js
53 lines (49 loc) · 1.39 KB
/
js-1.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
/**
*
* DO NOT EDIT THIS FILE.
* (But you can read it if you want)
* This is the code that automatically checks your answers
* in js-1.js!
*/
const { expect, test } = require('@jest/globals');
const { bmi, countNormal, countTypes } = require('./js-1.js');
// BMI Tests
test('BMI returns normal for 188, 85', () => {
expect(bmi(188, 85)).toEqual("normal")
});
test('BMI returns underweight for 150, 35', () => {
expect(bmi(150, 35)).toEqual("underweight")
});
test('BMI returns overweight for 180, 90', () => {
expect(bmi(180, 90)).toEqual("overweight")
});
test('BMI returns obese for 100, 100', () => {
expect(bmi(100, 100)).toEqual("obese")
});
// Count Normal Tests
test('CountNormal returns 2 for 24,25,22,30.1,18', () => {
expect(countNormal([24, 25, 22, 30.1, 18])).toEqual(2);
});
test('CountNormal returns 1 for 18.5,31', () => {
expect(countNormal([18.5, 31])).toEqual(1);
});
test('CountNormal returns 0 for empty', () => {
expect(countNormal([])).toEqual(0);
});
//CountTypes Tests
test('CountTypes countTypes([20,24,30,31.1,18]', () => {
expect(countTypes([20,24,30,31.1,18])).toEqual({
underweight: 1,
normal: 2,
overweight: 0,
obese: 2
})
});
test('CountTypes countTypes([20, 24]', () => {
expect(countTypes([20, 24])).toEqual({
underweight: 0,
normal: 2,
overweight: 0,
obese: 0
})
});