@@ -16,7 +16,7 @@ describe("dedupe", () => {
1616 // Then it should return an empty array
1717 it ( "given an empty array it should return an empty array" , ( ) => {
1818 const array = [ ] ;
19- dedupeArray = dedupe ( array ) ;
19+ const dedupeArray = dedupe ( array ) ;
2020 expect ( dedupeArray ) . toEqual ( [ ] ) ;
2121 } ) ;
2222
@@ -51,8 +51,25 @@ describe("dedupe", () => {
5151 // Given an input value that is not array could be null or undefined or just a number or string
5252 // When passed to the dedupe function
5353 // Then it should thrown an error
54- [ null , 930 , "just a string" , undefined , { } ] . forEach ( ( val ) =>
55- it ( "throw an error if the input is not an array" , ( ) =>
56- expect ( ( ) => dedupe ( val ) ) . toThrow ( val + " is not an array" ) )
57- ) ;
54+ test ( "should thrown an error if the input is null" , ( ) => {
55+ expect ( ( ) => dedupe ( null ) ) . toThrow ( null + " is not an array" ) ;
56+ } ) ;
57+
58+ test ( "should thrown an error if the input is a number" , ( ) => {
59+ const number = 123 ;
60+ expect ( ( ) => dedupe ( number ) ) . toThrow ( number + " is not an array" ) ;
61+ } ) ;
62+ test ( "should thrown an error if the input is a string" , ( ) => {
63+ const string = "this is a string" ;
64+ expect ( ( ) => dedupe ( string ) ) . toThrow ( string + " is not an array" ) ;
65+ } ) ;
66+
67+ test ( "should thrown an error if the input is undefined" , ( ) => {
68+ expect ( ( ) => dedupe ( undefined ) ) . toThrow ( undefined + " is not an array" ) ;
69+ } ) ;
70+
71+ test ( "should thrown an error if the input is an object" , ( ) => {
72+ const emptyObject = { } ;
73+ expect ( ( ) => dedupe ( emptyObject ) ) . toThrow ( emptyObject + " is not an array" ) ;
74+ } ) ;
5875} ) ;
0 commit comments