@@ -17,38 +17,43 @@ E.g. dedupe([1, 2, 1]) returns [1, 2]
1717// When passed to the dedupe function
1818// Then it should return an empty array
1919describe ( "dedupe" , ( ) => {
20- [
21- { input : [ ] , expected : [ ] } ,
22- ] . forEach ( ( { input, expected } ) =>
23- it ( `returns empty array for [${ input } ]` , ( ) => expect ( dedupe ( input ) ) . toEqual ( expected ) )
20+ [ { input : [ ] , expected : [ ] } ] . forEach ( ( { input, expected } ) =>
21+ it ( `returns empty array for [${ input } ]` , ( ) =>
22+ expect ( dedupe ( input ) ) . toEqual ( expected ) )
2423 ) ;
2524
26-
27- // Given an array with no duplicates
28- // When passed to the dedupe function
29- // Then it should return a copy of the original array
25+ // Given an array with no duplicates
26+ // When passed to the dedupe function
27+ // Then it should return a copy of the original array
3028
3129 [
3230 { input : [ 1 , 2 , 3 ] , expected : [ 1 , 2 , 3 ] } ,
3331 { input : [ 3 , 2 , 1 , 4 , 5 ] , expected : [ 3 , 2 , 1 , 4 , 5 ] } ,
3432 { input : [ "hello" , "a" , "b" , "c" ] , expected : [ "hello" , "a" , "b" , "c" ] } ,
3533 { input : [ 1 , 2 , "hello" , 4 , "a" , 6 ] , expected : [ 1 , 2 , "hello" , 4 , "a" , 6 ] } ,
36- ] . forEach ( ( { input, expected } ) =>
37- it ( `returns the median for [${ input } ]` , ( ) => expect ( dedupe ( input ) ) . toEqual ( expected ) )
38- ) ;
39-
40- // Given an array of strings or numbers
41- // When passed to the dedupe function
42- // Then it should return a new array with duplicates removed while preserving the
43- // first occurrence of each element from the original array.
34+ ] . forEach ( ( { input, expected } ) => {
35+ it ( `returns array with same contents for [${ input } ]` , ( ) =>
36+ expect ( dedupe ( input ) ) . toEqual ( expected ) ) ;
37+ it ( `returns a non-identical array (copy) for [${ input } ]` , ( ) =>
38+ expect ( dedupe ( input ) ) . not . toBe ( input ) ) ;
39+ } ) ;
40+
41+ // Given an array of strings or numbers
42+ // When passed to the dedupe function
43+ // Then it should return a new array with duplicates removed while preserving the
44+ // first occurrence of each element from the original array.
4445
4546 [
46- { input : [ 1 , 1 , 2 , 2 , 3 , 3 , ] , expected : [ 1 , 2 , 3 ] } ,
47+ { input : [ 1 , 1 , 2 , 2 , 3 , 3 ] , expected : [ 1 , 2 , 3 ] } ,
4748 { input : [ "a" , "a" , "b" , "b" , "c" , "c" ] , expected : [ "a" , "b" , "c" ] } ,
48- { input : [ "qwe" , "qwe" , 3 , 3 , "hello" , "hello" , "hello" ] , expected : [ "qwe" , 3 , "hello" ] } ,
49+ {
50+ input : [ "qwe" , "qwe" , 3 , 3 , "hello" , "hello" , "hello" ] ,
51+ expected : [ "qwe" , 3 , "hello" ] ,
52+ } ,
4953 { input : [ "a" , "a" , "a" , "a" ] , expected : [ "a" ] } ,
5054 { input : [ 1 , 2 , 2 , 2 , 2 , 2 ] , expected : [ 1 , 2 ] } ,
5155 ] . forEach ( ( { input, expected } ) =>
52- it ( `returns the median for [${ input } ]` , ( ) => expect ( dedupe ( input ) ) . toEqual ( expected ) )
56+ it ( `returns no duplicates for [${ input } ]` , ( ) =>
57+ expect ( dedupe ( input ) ) . toEqual ( expected ) )
5358 ) ;
54- } ) ;
59+ } ) ;
0 commit comments