|
1 | | -const contains = require('./contains-solution'); |
| 1 | +const contains = require("./contains-solution"); |
2 | 2 |
|
3 | | -describe('contains', () => { |
| 3 | +describe("contains", () => { |
4 | 4 | const object = { |
5 | 5 | 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 | + }, |
7 | 16 | 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", () => { |
25 | 25 | expect(contains(object, 44)).toBe(true); |
26 | 26 | }); |
27 | 27 |
|
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); |
30 | 30 | }); |
31 | 31 |
|
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); |
34 | 34 | }); |
35 | 35 |
|
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); |
38 | 38 | }); |
39 | 39 |
|
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); |
42 | 42 | }); |
43 | 43 |
|
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", () => { |
45 | 45 | expect(contains(object, [42])).toBe(false); |
46 | 46 | }); |
47 | 47 |
|
48 | | - test('true if NaN is a value within the object', () => { |
| 48 | + test("true if NaN is a value within the object", () => { |
49 | 49 | expect(contains(object, NaN)).toBe(true); |
50 | 50 | }); |
51 | 51 |
|
52 | | - test('false if the provided value exists and is null', () => { |
| 52 | + test("false if the provided value exists and is null", () => { |
53 | 53 | expect(contains(object, null)).toBe(true); |
54 | 54 | }); |
55 | 55 | }); |
0 commit comments