You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 0f21769
Browse filesBrowse the repository at this point in the historyBrowse files
// Delete this test.todo and replace it with a test.
19
-
test.todo("given an empty array, returns -Infinity");
19
+
test("Given an empty array, when passed to the max function, then it should return -Infinity",()=>{
20
+
expect(findMax([])).toBe(-Infinity);
21
+
});
20
22
21
23
// Given an array with one number
22
24
// When passed to the max function
23
25
// Then it should return that number
24
-
26
+
test("Given an array with one number, when passed to the max function, then it should return that number",()=>{
27
+
expect(findMax([5])).toBe(5);
28
+
});
25
29
// Given an array with both positive and negative numbers
26
30
// When passed to the max function
27
31
// Then it should return the largest number overall
32
+
test("Given an array with both positive and negative numbers, when passed to the max function, then it should return the largest number overall",()=>{
33
+
expect(findMax([-10,20,-30,40,-50])).toBe(40);
34
+
});
28
35
29
36
// Given an array with just negative numbers
30
37
// When passed to the max function
31
38
// Then it should return the closest one to zero
32
-
39
+
test("Given an array with just negative numbers, when passed to the max function, then it should return the closest one to zero",()=>{
40
+
expect(findMax([-10,-20,-30,-40,-50])).toBe(-10);
41
+
});
33
42
// Given an array with decimal numbers
34
43
// When passed to the max function
35
44
// Then it should return the largest decimal number
45
+
test("Given an array with decimal numbers, when passed to the max function, then it should return the largest decimal number",()=>{
46
+
expect(findMax([1.5,2.5,3.5,4.5,5.5])).toBe(5.5);
47
+
});
36
48
37
49
// Given an array with non-number values
38
50
// When passed to the max function
39
51
// Then it should return the max and ignore non-numeric values
52
+
test("Given an array with non-number values, when passed to the max function, then it should return the max and ignore non-numeric values",()=>{
53
+
expect(findMax(['hey',10,'hi',60,10])).toBe(60);
54
+
});
40
55
41
56
// Given an array with only non-number values
42
57
// When passed to the max function
43
58
// Then it should return the least surprising value given how it behaves for all other inputs
59
+
test("Given an array with only non-number values, when passed to the max function, then it should return the least surprising value given how it behaves for all other inputs",()=>{
0 commit comments