Skip to content

Commit 897b2c1

Browse files
committed
feat/ create tests
1 parent 329d7d6 commit 897b2c1

File tree

1 file changed

+37
-7
lines changed

1 file changed

+37
-7
lines changed
Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,45 @@
11
const contains = require('./contains-solution');
22

33
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+
}
621

7-
expect(contains()).toBe('');
22+
test('true if property is number', () => {
23+
expect(contains(nestedObject, 44)).toBe(true);
824
});
9-
10-
test('Second test description', () => {
11-
// Replace this comment with any other necessary code, and update the expect line as necessary
1225

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);
1444
});
1545
});

0 commit comments

Comments
 (0)