Skip to content

Commit e630a8b

Browse files
committed
feat(contains): add a more exhaustive test for reference in the object
1 parent 0f87177 commit e630a8b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

14_contains/solution/contains-solution.spec.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const contains = require("./contains-solution");
22

33
describe("contains", () => {
4+
const meaningOfLifeArray = [42]
45
const object = {
56
data: {
67
duplicate: "e",
@@ -9,7 +10,7 @@ describe("contains", () => {
910
banana: NaN,
1011
moreStuff: {
1112
something: "foo",
12-
answer: [42],
13+
answer: meaningOfLifeArray,
1314
},
1415
},
1516
},
@@ -41,10 +42,14 @@ describe("contains", () => {
4142
expect(contains(object, "e")).toBe(true);
4243
});
4344

44-
test("false if the provided value exists but is not a primitive", () => {
45+
test("false if the provided array has the same structure as an array within the object, however the reference is not the same", () => {
4546
expect(contains(object, [42])).toBe(false);
4647
});
4748

49+
test("true if the provided array is a reference to an array that exists within the object", () => {
50+
expect(contains(object, meaningOfLifeArray)).toBe(true);
51+
});
52+
4853
test("true if NaN is a value within the object", () => {
4954
expect(contains(object, NaN)).toBe(true);
5055
});

0 commit comments

Comments
 (0)