@@ -16,28 +16,49 @@ const findMax = require("./max.js");
1616// When passed to the max function
1717// Then it should return -Infinity
1818// Delete this test.todo and replace it with a test.
19- test . todo ( "given an empty array, returns -Infinity" ) ;
19+ //test.todo("given an empty array, returns -Infinity");
20+ test ( "given an empty array, returns -Infinity" , ( ) => {
21+ expect ( findMax ( [ ] ) ) . toBe ( - Infinity ) ;
22+ } ) ;
2023
2124// Given an array with one number
2225// When passed to the max function
2326// Then it should return that number
27+ test ( "given an array with one number, it should return that number" , ( ) => {
28+ expect ( findMax ( [ 2 ] ) ) . toBe ( 2 ) ;
29+ } ) ;
2430
2531// Given an array with both positive and negative numbers
2632// When passed to the max function
2733// Then it should return the largest number overall
34+ test ( "given an array with both positive and negative numbers, it returns the largest number" , ( ) => {
35+ expect ( findMax ( [ 3 , - 3 ] ) ) . toBe ( 3 ) ;
36+ } ) ;
2837
2938// Given an array with just negative numbers
3039// When passed to the max function
3140// Then it should return the closest one to zero
41+ test ( "given an array with just negative numbers, it returns the closest one to zero" , ( ) => {
42+ expect ( findMax ( [ - 1 , - 5 , - 2 ] ) ) . toBe ( - 1 ) ;
43+ } ) ;
3244
3345// Given an array with decimal numbers
3446// When passed to the max function
3547// Then it should return the largest decimal number
48+ test ( "given an array with decimal numbers, it returns the largest decimal number" , ( ) => {
49+ expect ( findMax ( [ 1.5 , 20.3 , 4.1 ] ) ) . toBe ( 20.3 ) ;
50+ } ) ;
3651
3752// Given an array with non-number values
3853// When passed to the max function
3954// Then it should return the max and ignore non-numeric values
55+ test ( "given an array with non-number values, it returns the max and ignore non-numeric values" , ( ) => {
56+ expect ( findMax ( [ null , 15 , 'text' , false , 4 , Infinity ] ) ) . toBe ( Infinity ) ;
57+ } ) ;
4058
4159// Given an array with only non-number values
4260// When passed to the max function
4361// Then it should return the least surprising value given how it behaves for all other inputs
62+ test ( "given an array with only non-number values, it returns the least surprising value given how it behaves for all other inputs" , ( ) => {
63+ expect ( findMax ( [ 'text' , false , null , undefined , ] ) ) . toBe ( - Infinity ) ;
64+ } ) ;
0 commit comments