Skip to content

Commit a204931

Browse files
committed
feat(contains): copy over tests from solution to spec file
1 parent de104e3 commit a204931

File tree

1 file changed

+54
-9
lines changed

1 file changed

+54
-9
lines changed

14_contains/contains.spec.js

Lines changed: 54 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,60 @@
1-
const contains = require('./contains');
1+
const contains = require("./contains");
22

3-
describe('contains', () => {
4-
test('First test description', () => {
5-
// Replace this comment with any other necessary code, and update the expect line as necessary
3+
describe("contains", () => {
4+
const meaningOfLifeArray = [42];
5+
const object = {
6+
data: {
7+
duplicate: "e",
8+
stuff: {
9+
thing: {
10+
banana: NaN,
11+
moreStuff: {
12+
something: "foo",
13+
answer: meaningOfLifeArray,
14+
},
15+
},
16+
},
17+
info: {
18+
duplicate: "e",
19+
magicNumber: 44,
20+
empty: null,
21+
},
22+
},
23+
};
624

7-
expect(contains()).toBe('');
25+
test("true if the provided number is a value within the object", () => {
26+
expect(contains(object, 44)).toBe(true);
827
});
9-
10-
test.skip('Second test description', () => {
11-
// Replace this comment with any other necessary code, and update the expect line as necessary
1228

13-
expect(contains()).toBe('');
29+
test.skip("true if the provided string is a value within the object", () => {
30+
expect(contains(object, "foo")).toBe(true);
31+
});
32+
33+
test.skip("does not convert input string into a number when searching for a value within the object", () => {
34+
expect(contains(object, "44")).toBe(false);
35+
});
36+
37+
test.skip("false if the provided string is not a value within the object", () => {
38+
expect(contains(object, "bar")).toBe(false);
39+
});
40+
41+
test.skip("true if provided string is within the object, even if duplicated", () => {
42+
expect(contains(object, "e")).toBe(true);
43+
});
44+
45+
test.skip("true if the object contains the same object by reference", () => {
46+
expect(contains(object, meaningOfLifeArray)).toBe(true);
47+
});
48+
49+
test.skip("false if no matching object reference", () => {
50+
expect(contains(object, [42])).toBe(false);
51+
});
52+
53+
test.skip("true if NaN is a value within the object", () => {
54+
expect(contains(object, NaN)).toBe(true);
55+
});
56+
57+
test.skip("false if the provided value exists and is null", () => {
58+
expect(contains(object, null)).toBe(true);
1459
});
1560
});

0 commit comments

Comments
 (0)