|
1 | | -const contains = require('./contains'); |
| 1 | +const contains = require("./contains"); |
2 | 2 |
|
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 | + }; |
6 | 24 |
|
7 | | - expect(contains()).toBe(''); |
| 25 | + test("true if the provided number is a value within the object", () => { |
| 26 | + expect(contains(object, 44)).toBe(true); |
8 | 27 | }); |
9 | | - |
10 | | - test.skip('Second test description', () => { |
11 | | - // Replace this comment with any other necessary code, and update the expect line as necessary |
12 | 28 |
|
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); |
14 | 59 | }); |
15 | 60 | }); |
0 commit comments