@@ -20,16 +20,30 @@ as the object doesn't contains a key of 'c'
2020// Given an empty object
2121// When passed to contains
2222// Then it should return false
23- test . todo ( "contains on empty object returns false" ) ;
23+ test ( "contains an empty object returns false" , ( ) => {
24+ expect ( contains ( { } , "ball" ) ) . toEqual ( false ) ;
25+ } ) ;
2426
2527// Given an object with properties
2628// When passed to contains with an existing property name
2729// Then it should return true
28-
30+ test ( "contains an object with properties, returns true" , ( ) => {
31+ expect ( contains ( { foot : "ball" } , "foot" ) ) . toEqual ( true ) ;
32+ } ) ;
2933// Given an object with properties
3034// When passed to contains with a non-existent property name
3135// Then it should return false
36+ test ( "should return false when the object does not contain the property" , ( ) => {
37+ expect ( contains ( { foot : "ball" } , "basket" ) ) . toEqual ( false ) ;
38+ } ) ;
3239
3340// Given invalid parameters like an array
3441// When passed to contains
3542// Then it should return false or throw an error
43+ test ( "should return false when input is not an object" , ( ) => {
44+ expect ( contains ( [ ] , "a" ) ) . toEqual ( false ) ;
45+ } ) ;
46+
47+ test ( "should throw an error when input is not an object" , ( ) => {
48+ expect ( ( ) => contains ( [ ] , "c" ) ) . toThrow ( ) ;
49+ } ) ;
0 commit comments