@@ -8,28 +8,35 @@ E.g. contains({a: 1, b: 2}, 'a') // returns true
88as the object contains a key of 'a'
99
1010E.g. contains({a: 1, b: 2}, 'c') // returns false
11- as the object doesn't contains a key of 'c'
11+ as the object doesn't contain a key of 'c'
1212*/
1313
1414// Acceptance criteria:
1515
16- // Given a contains function
17- // When passed an object and a property name
18- // Then it should return true if the object contains the property, false otherwise
19-
2016// Given an empty object
2117// When passed to contains
2218// Then it should return false
23- test . todo ( "contains on empty object returns false" ) ;
19+ test ( "contains on empty object returns false" , ( ) => {
20+ expect ( contains ( { } , "a" ) ) . toBe ( false ) ;
21+ } ) ;
2422
2523// Given an object with properties
2624// When passed to contains with an existing property name
2725// Then it should return true
26+ test ( "contains returns true when property exists" , ( ) => {
27+ expect ( contains ( { a : 1 , b : 2 } , "a" ) ) . toBe ( true ) ;
28+ } ) ;
2829
2930// Given an object with properties
3031// When passed to contains with a non-existent property name
3132// Then it should return false
33+ test ( "contains returns false when property does not exist" , ( ) => {
34+ expect ( contains ( { a : 1 , b : 2 } , "c" ) ) . toBe ( false ) ;
35+ } ) ;
3236
3337// Given invalid parameters like an array
3438// When passed to contains
3539// Then it should return false or throw an error
40+ test ( "contains returns false when passed an array" , ( ) => {
41+ expect ( contains ( [ ] , "length" ) ) . toBe ( false ) ;
42+ } ) ;
0 commit comments