@@ -16,12 +16,26 @@ E.g. dedupe([1, 2, 1]) target output: [1, 2]
1616// Given an empty array
1717// When passed to the dedupe function
1818// Then it should return an empty array
19- test . todo ( "given an empty array, it returns an empty array" ) ;
19+ test ( "dedupe an empty array returns an empty array" , ( ) => {
20+ const inputEmpty = [ ] ;
21+ const result = dedupe ( inputEmpty ) ;
22+ expect ( result ) . toEqual ( [ ] ) ;
23+ } ) ;
2024
2125// Given an array with no duplicates
2226// When passed to the dedupe function
2327// Then it should return a copy of the original array
28+ test ( " Given an array with no duplicates" , ( ) => {
29+ const inputNoDuplicates = [ "a" , "b" , "c" ] ;
30+ const result = dedupe ( inputNoDuplicates ) ;
31+ expect ( result ) . toEqual ( [ "a" , "b" , "c" ] ) ;
32+ } ) ;
2433
2534// Given an array with strings or numbers
2635// When passed to the dedupe function
2736// Then it should remove the duplicate values, preserving the first occurence of each element
37+ test ( " Given an array with no duplicates" , ( ) => {
38+ const inputMix = [ 1 , 1 , 2 , 2 , 3 , 3 , 4 , 4 , 5 , 5 ] ;
39+ const result = dedupe ( inputMix ) ;
40+ expect ( result ) . toEqual ( [ 1 , 2 , 3 , 4 , 5 ] ) ;
41+ } ) ;
0 commit comments