Skip to content

Commit 97796cf

Browse files
authored
totalIntegers: Provide clearer test names (#623)
"works ..." doesn't communicate very well exactly what it means
1 parent 4aa0c39 commit 97796cf

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
11
const totalIntegers = require('./totalIntegers-solution');
22

33
describe('totalIntegers', () => {
4-
test('Works with a simple array of numbers', () => {
4+
test('Counts all integers in a simple array of only integers', () => {
55
expect(totalIntegers([1, 2, 3])).toBe(3);
66
});
7-
test('Ignores non-integer values', () => {
7+
test('Ignores non-number values', () => {
88
expect(totalIntegers([1, 2, '3', 4])).toBe(3);
99
});
10-
test('Works with simple objects', () => {
10+
test('Counts all integers in a plain object', () => {
1111
expect(totalIntegers({ a: 1, b: '2', c: 3 })).toBe(2);
1212
});
13-
test('Works with an empty nested array', () => {
13+
test('Does not find any integers in nested empty arrays', () => {
1414
expect(totalIntegers([[], [], []])).toBe(0);
1515
});
16-
test('Works with a very nested array', () => {
16+
test('Counts integers in deeply nested arrays', () => {
1717
expect(totalIntegers([[[[[[[[[[[[[[4]]]]]], 246]]]]]]]])).toBe(2);
1818
});
19-
test('Works with negative numbers', () => {
19+
test('Counts negative integers', () => {
2020
expect(totalIntegers([5, 7, -7, [45, -1, -0], [4, 7, -4, -4, -4, [777777, -45674]], [-5477654]])).toBe(14);
2121
});
22-
test('Works with floats', () => {
22+
test('Does not count non-integer numbers', () => {
2323
expect(totalIntegers([5, 7.7, 7, [45, 1, 0], [4.0, 7, [7.77777, 4567.4]], [5477.654]])).toBe(7);
2424
});
25-
test('Only accepts arrays or objects', () => {
25+
test('Returns undefined for non-array/object arguments', () => {
2626
expect(totalIntegers('2')).toBe(undefined);
2727
expect(totalIntegers(() => {})).toBe(undefined);
2828
expect(totalIntegers(42)).toBe(undefined);
2929
expect(totalIntegers(NaN)).toBe(undefined);
3030
});
31-
test('Works with NaN', () => {
31+
test('Does not count NaN as an integer', () => {
3232
expect(totalIntegers([5, NaN, [NaN, NaN, 64], 4])).toBe(3);
3333
});
34-
test('Works with a nested array of all kinds of things', () => {
34+
test('Counts all integers even with deeply nested containing multiple types', () => {
3535
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);
3636
});
37-
test('Works with arrays containing objects containing integers', () => {
37+
test('Counts all integers when nested arrays and objects are mixed together', () => {
3838
expect(totalIntegers([4, 6, { a: 1, b: { a: [5, 10], b: 11 } }, 9])).toBe(7);
3939
});
4040
});
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,50 @@
11
const totalIntegers = require('./totalIntegers');
22

33
describe('totalIntegers', () => {
4-
test('Works with a simple array of numbers', () => {
4+
test('Counts all integers in a simple array of only integers', () => {
55
expect(totalIntegers([1, 2, 3])).toBe(3);
66
});
77

8-
test.skip('Ignores non-integer values', () => {
8+
test.skip('Ignores non-number values', () => {
99
expect(totalIntegers([1, 2, '3', 4])).toBe(3);
1010
});
1111

12-
test.skip('Works with simple objects', () => {
12+
test.skip('Counts all integers in a plain object', () => {
1313
expect(totalIntegers({ a: 1, b: '2', c: 3 })).toBe(2);
1414
});
1515

16-
test.skip('Works with an empty nested array', () => {
16+
test.skip('Does not find any integers in nested empty arrays', () => {
1717
expect(totalIntegers([[], [], []])).toBe(0);
1818
});
1919

20-
test.skip('Works with a very nested array', () => {
20+
test.skip('Counts integers in deeply nested arrays', () => {
2121
expect(totalIntegers([[[[[[[[[[[[[[4]]]]]], 246]]]]]]]])).toBe(2);
2222
});
2323

24-
test.skip('Works with negative numbers', () => {
24+
test.skip('Counts negative integers', () => {
2525
expect(totalIntegers([5, 7, -7, [45, -1, -0], [4, 7, -4, -4, -4, [777777, -45674]], [-5477654]])).toBe(14);
2626
});
2727

28-
test.skip('Works with floats', () => {
28+
test.skip('Does not count non-integer numbers', () => {
2929
expect(totalIntegers([5, 7.7, 7, [45, 1, 0], [4.0, 7, [7.77777, 4567.4]], [5477.654]])).toBe(7);
3030
});
3131

32-
test.skip('Only accepts arrays or objects', () => {
32+
test.skip('Returns undefined for non-array/object arguments', () => {
3333
expect(totalIntegers('2')).toBe(undefined);
3434
expect(totalIntegers(() => {})).toBe(undefined);
3535
expect(totalIntegers(42)).toBe(undefined);
3636
expect(totalIntegers(NaN)).toBe(undefined);
3737
});
3838

39-
test.skip('Works with NaN', () => {
39+
test.skip('Does not count NaN as an integer', () => {
4040
expect(totalIntegers([5, NaN, [NaN, NaN, 64], 4])).toBe(3);
4141
});
4242

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', () => {
4444
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);
4545
});
4646

47-
test.skip('Works with arrays containing objects containing integers', () => {
47+
test.skip('Counts all integers when nested arrays and objects are mixed together', () => {
4848
expect(totalIntegers([4, 6, { a: 1, b: { a: [5, 10], b: 11 } }, 9])).toBe(7);
4949
});
5050
});

0 commit comments

Comments
 (0)