|
1 | 1 | const totalIntegers = require('./totalIntegers'); |
2 | 2 |
|
3 | 3 | describe('totalIntegers', () => { |
4 | | - test('Works with a simple array of numbers', () => { |
| 4 | + test('Counts all integers in a simple array of only integers', () => { |
5 | 5 | expect(totalIntegers([1, 2, 3])).toBe(3); |
6 | 6 | }); |
7 | 7 |
|
8 | | - test.skip('Ignores non-integer values', () => { |
| 8 | + test.skip('Ignores non-number values', () => { |
9 | 9 | expect(totalIntegers([1, 2, '3', 4])).toBe(3); |
10 | 10 | }); |
11 | 11 |
|
12 | | - test.skip('Works with simple objects', () => { |
| 12 | + test.skip('Counts all integers in a plain object', () => { |
13 | 13 | expect(totalIntegers({ a: 1, b: '2', c: 3 })).toBe(2); |
14 | 14 | }); |
15 | 15 |
|
16 | | - test.skip('Works with an empty nested array', () => { |
| 16 | + test.skip('Does not find any integers in nested empty arrays', () => { |
17 | 17 | expect(totalIntegers([[], [], []])).toBe(0); |
18 | 18 | }); |
19 | 19 |
|
20 | | - test.skip('Works with a very nested array', () => { |
| 20 | + test.skip('Counts integers in deeply nested arrays', () => { |
21 | 21 | expect(totalIntegers([[[[[[[[[[[[[[4]]]]]], 246]]]]]]]])).toBe(2); |
22 | 22 | }); |
23 | 23 |
|
24 | | - test.skip('Works with negative numbers', () => { |
| 24 | + test.skip('Counts negative integers', () => { |
25 | 25 | expect(totalIntegers([5, 7, -7, [45, -1, -0], [4, 7, -4, -4, -4, [777777, -45674]], [-5477654]])).toBe(14); |
26 | 26 | }); |
27 | 27 |
|
28 | | - test.skip('Works with floats', () => { |
| 28 | + test.skip('Does not count non-integer numbers', () => { |
29 | 29 | expect(totalIntegers([5, 7.7, 7, [45, 1, 0], [4.0, 7, [7.77777, 4567.4]], [5477.654]])).toBe(7); |
30 | 30 | }); |
31 | 31 |
|
32 | | - test.skip('Only accepts arrays or objects', () => { |
| 32 | + test.skip('Returns undefined for non-array/object arguments', () => { |
33 | 33 | expect(totalIntegers('2')).toBe(undefined); |
34 | 34 | expect(totalIntegers(() => {})).toBe(undefined); |
35 | 35 | expect(totalIntegers(42)).toBe(undefined); |
36 | 36 | expect(totalIntegers(NaN)).toBe(undefined); |
37 | 37 | }); |
38 | 38 |
|
39 | | - test.skip('Works with NaN', () => { |
| 39 | + test.skip('Does not count NaN as an integer', () => { |
40 | 40 | expect(totalIntegers([5, NaN, [NaN, NaN, 64], 4])).toBe(3); |
41 | 41 | }); |
42 | 42 |
|
43 | | - test.skip('Works with a nested array of all kinds of things', () => { |
| 43 | + test.skip('Counts all integers even with deeply nested containing multiple types', () => { |
44 | 44 | expect(totalIntegers([NaN, [[{}], 555 ], '444', [], 74.0, undefined, [[() => {}], [4], Infinity, [[[], -44.0], [null, '-4'], NaN [[]], 6]], () => {}, [[], [-Infinity, ['4'], [4.7, -46.7], NaN]]])).toBe(5); |
45 | 45 | }); |
46 | 46 |
|
47 | | - test.skip('Works with arrays containing objects containing integers', () => { |
| 47 | + test.skip('Counts all integers when nested arrays and objects are mixed together', () => { |
48 | 48 | expect(totalIntegers([4, 6, { a: 1, b: { a: [5, 10], b: 11 } }, 9])).toBe(7); |
49 | 49 | }); |
50 | 50 | }); |
0 commit comments