Skip to content

Commit ee12fc4

Browse files
committed
feat: add test to account for children nested objects
1 parent 019af1d commit ee12fc4

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed
Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,55 @@
1-
const contains = require('./contains-solution');
1+
const contains = require("./contains-solution");
22

3-
describe('contains', () => {
3+
describe("contains", () => {
44
const object = {
55
data: {
6-
duplicate: 'e',
6+
duplicate: "e",
7+
stuff: {
8+
thing: {
9+
banana: NaN,
10+
moreStuff: {
11+
something: "foo",
12+
answer: [42],
13+
},
14+
},
15+
},
716
info: {
8-
duplicate: 'e',
9-
magicNumber: 44,
10-
empty: null,
11-
stuff: {
12-
thing: {
13-
banana: NaN,
14-
moreStuff: {
15-
something: 'foo',
16-
answer: [42]
17-
}
18-
}
19-
}
20-
}
21-
}
22-
}
23-
24-
test('true if the provided number is a value within the object', () => {
17+
duplicate: "e",
18+
magicNumber: 44,
19+
empty: null,
20+
},
21+
},
22+
};
23+
24+
test("true if the provided number is a value within the object", () => {
2525
expect(contains(object, 44)).toBe(true);
2626
});
2727

28-
test('true if the provided string is a value within the object', () => {
29-
expect(contains(object, 'foo')).toBe(true);
28+
test("true if the provided string is a value within the object", () => {
29+
expect(contains(object, "foo")).toBe(true);
3030
});
3131

32-
test('does not convert input string into a number when searching for a value within the object', () => {
33-
expect(contains(object, '44')).toBe(false);
32+
test("does not convert input string into a number when searching for a value within the object", () => {
33+
expect(contains(object, "44")).toBe(false);
3434
});
3535

36-
test('false if the provided string is not a value within the object', () => {
37-
expect(contains(object, 'bar')).toBe(false);
36+
test("false if the provided string is not a value within the object", () => {
37+
expect(contains(object, "bar")).toBe(false);
3838
});
3939

40-
test('true if provided string is within the object, even if duplicated', () => {
41-
expect(contains(object, 'e')).toBe(true);
40+
test("true if provided string is within the object, even if duplicated", () => {
41+
expect(contains(object, "e")).toBe(true);
4242
});
4343

44-
test('false if the provided value exists but is not a primitive', () => {
44+
test("false if the provided value exists but is not a primitive", () => {
4545
expect(contains(object, [42])).toBe(false);
4646
});
4747

48-
test('true if NaN is a value within the object', () => {
48+
test("true if NaN is a value within the object", () => {
4949
expect(contains(object, NaN)).toBe(true);
5050
});
5151

52-
test('false if the provided value exists and is null', () => {
52+
test("false if the provided value exists and is null", () => {
5353
expect(contains(object, null)).toBe(true);
5454
});
5555
});

0 commit comments

Comments
 (0)