|
1 | 1 | const contains = require('./contains-solution'); |
2 | 2 |
|
3 | 3 | describe('contains', () => { |
4 | | - test('First test description', () => { |
5 | | - // Replace this comment with any other necessary code, and update the expect line as necessary |
| 4 | + const nestedObject = { |
| 5 | + data: { |
| 6 | + banana: NaN, |
| 7 | + info: { |
| 8 | + magicNumber: 44, |
| 9 | + stuff: { |
| 10 | + thing: { |
| 11 | + banana: NaN, |
| 12 | + moreStuff: { |
| 13 | + something: 'foo', |
| 14 | + answer: [42] |
| 15 | + } |
| 16 | + } |
| 17 | + } |
| 18 | + } |
| 19 | + } |
| 20 | + } |
6 | 21 |
|
7 | | - expect(contains()).toBe(''); |
| 22 | + test('true if property is number', () => { |
| 23 | + expect(contains(nestedObject, 44)).toBe(true); |
8 | 24 | }); |
9 | | - |
10 | | - test('Second test description', () => { |
11 | | - // Replace this comment with any other necessary code, and update the expect line as necessary |
12 | 25 |
|
13 | | - expect(contains()).toBe(''); |
| 26 | + test('true if property is string', () => { |
| 27 | + expect(contains(nestedObject, 'foo')).toBe(true); |
| 28 | + }); |
| 29 | + |
| 30 | + test('does not do type conversions', () => { |
| 31 | + expect(contains(nestedObject, '44')).toBe(false); |
| 32 | + }); |
| 33 | + |
| 34 | + test('false if property is not in object', () => { |
| 35 | + expect(contains(nestedObject, 'bar')).toBe(false); |
| 36 | + }); |
| 37 | + |
| 38 | + test('true if property is duplicated', () => { |
| 39 | + expect(contains(nestedObject, NaN)).toBe(true); |
| 40 | + }); |
| 41 | + |
| 42 | + test('false if property exists but is not primitive', () => { |
| 43 | + expect(contains(nestedObject, [42])).toBe(false); |
14 | 44 | }); |
15 | 45 | }); |
0 commit comments