@@ -12,16 +12,27 @@ E.g. dedupe([1, 2, 1]) target output: [1, 2]
1212*/
1313
1414// Acceptance Criteria:
15+ describe ( "dedupe" , ( ) => {
16+ // Given an empty array
17+ // When passed to the dedupe function
18+ // Then it should return an empty array
19+ test ( "given an empty array, returns an empty array" , ( ) => {
20+ expect ( dedupe ( [ ] ) ) . toEqual ( [ ] ) ;
21+ } ) ;
1522
16- // Given an empty array
17- // When passed to the dedupe function
18- // Then it should return an empty array
19- test . todo ( "given an empty array, it returns an empty array" ) ;
23+ // Given an array with no duplicates
24+ // When passed to the dedupe function
25+ // Then it should return a copy of the original array
26+ test ( "given an array with no duplicates, returns a copy of the original array" , ( ) => {
27+ const input = [ 1 , 65 , 2 , 298 , 3 , 729 ] ;
28+ expect ( dedupe ( input ) ) . toEqual ( [ 1 , 65 , 2 , 298 , 3 , 729 ] ) ;
29+ } ) ;
2030
21- // Given an array with no duplicates
22- // When passed to the dedupe function
23- // Then it should return a copy of the original array
24-
25- // Given an array with strings or numbers
26- // When passed to the dedupe function
27- // Then it should remove the duplicate values, preserving the first occurence of each element
31+ // Given an array with strings or numbers
32+ // When passed to the dedupe function
33+ // Then it should remove the duplicate values, preserving the first occurence of each element
34+ test ( "given an array with duplicates, removes duplicate values preserving the first occurrence" , ( ) => {
35+ const input = [ "a" , "b" , "a" , "c" , "b" , "d" , "e" , "d" , "c" , "a" , "b" ] ;
36+ expect ( dedupe ( input ) ) . toEqual ( [ "a" , "b" , "c" , "d" , "e" ] ) ;
37+ } ) ;
38+ } ) ;
0 commit comments