@@ -16,20 +16,39 @@ as the object doesn't contains a key of 'c'
1616// Given a contains function
1717// When passed an object and a property name
1818// Then it should return true if the object contains the property, false otherwise
19+ test ( "contains a passed object should return true, false otherwise" , ( ) => {
20+ expect ( contains ( { a : 1 , b : 2 } , 2 ) ) . toEqual ( false ) ;
21+ expect ( contains ( { a : 1 , b : 2 } , 'b' ) ) . toEqual ( true ) ;
22+ } ) ;
1923
2024// Given an empty object
2125// When passed to contains
2226// Then it should return false
23- test . todo ( "contains on empty object returns false" ) ;
27+ test ( "contains an empty object, returns false" , ( ) => {
28+ expect ( contains ( { } ) ) . toEqual ( false ) ;
29+ } ) ;
2430
2531// Given an object with properties
2632// When passed to contains with an existing property name
2733// Then it should return true
34+ test ( "contains object with properties, return true when passed with existing property name" , ( ) => {
35+ expect ( contains ( { name : 'alice' } , 'name' ) ) . toEqual ( true ) ;
36+ } ) ;
37+
2838
2939// Given an object with properties
3040// When passed to contains with a non-existent property name
3141// Then it should return false
42+ test ( "contains a passed object with non-existent property names return false" , ( ) => {
43+ expect ( contains ( { a : 1 , b : 2 } , 'c' ) ) . toEqual ( false ) ;
44+ } ) ;
45+
3246
3347// Given invalid parameters like an array
3448// When passed to contains
3549// Then it should return false or throw an error
50+ test ( "contains passed invalid parameters like an array to throw error" , ( ) => {
51+ expect ( ( ) => contains ( [ 'horse' , 'dog' , 'fish' ] , 'fish' ) )
52+ . toThrow ( "Invalid parameter" ) ;
53+ } ) ;
54+
0 commit comments