@@ -20,16 +20,33 @@ 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" ) ;
2423
24+ test ( "contains on empty object returns false" , ( ) => {
25+ expect ( contains ( { } , "a" ) ) . toBe ( false ) ;
26+ } ) ;
2527// Given an object with properties
2628// When passed to contains with an existing property name
2729// Then it should return true
30+ test ( "contains returns true for existing property" , ( ) => {
31+ const obj = { a : 1 , b : 2 } ;
32+ expect ( contains ( obj , "a" ) ) . toBe ( true ) ;
33+ } ) ;
34+
2835
2936// Given an object with properties
3037// When passed to contains with a non-existent property name
3138// Then it should return false
39+ test ( "contains returns false for non-existent property" , ( ) => {
40+ const obj = { a : 1 , b : 2 } ;
41+ expect ( contains ( obj , "c" ) ) . toBe ( false ) ;
42+ } ) ;
43+
3244
3345// Given invalid parameters like an array
3446// When passed to contains
3547// Then it should return false or throw an error
48+ test ( "contains returns false for invalid input" , ( ) => {
49+ expect ( contains ( [ ] , "a" ) ) . toBe ( false ) ;
50+ expect ( contains ( null , "a" ) ) . toBe ( false ) ;
51+ expect ( contains ( "string" , "a" ) ) . toBe ( false ) ;
52+ } ) ;
0 commit comments