Skip to content

Commit 075fe8e

Browse files
committed
Reformat test parameters for consistency
1 parent 5a7cd9b commit 075fe8e

File tree

3 files changed

+27
-27
lines changed

3 files changed

+27
-27
lines changed

08_calculator/calculator.spec.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,55 +2,55 @@ const calculator = require('./calculator');
22

33
describe('add', () => {
44
test('adds 0 and 0', () => {
5-
expect(calculator.add(0,0)).toBe(0);
5+
expect(calculator.add(0, 0)).toBe(0);
66
});
77

88
test.skip('adds 2 and 2', () => {
9-
expect(calculator.add(2,2)).toBe(4);
9+
expect(calculator.add(2, 2)).toBe(4);
1010
});
1111

1212
test.skip('adds positive numbers', () => {
13-
expect(calculator.add(2,6)).toBe(8);
13+
expect(calculator.add(2, 6)).toBe(8);
1414
});
1515
});
1616

1717
describe('subtract', () => {
1818
test.skip('subtracts numbers', () => {
19-
expect(calculator.subtract(10,4)).toBe(6);
19+
expect(calculator.subtract(10, 4)).toBe(6);
2020
});
2121
});
2222

2323
describe('sum', () => {
24-
test.skip('computes the sum of an empty array', () => {
25-
expect(calculator.sum([])).toBe(0);
24+
test.skip('computes the sum of an empty parameter', () => {
25+
expect(calculator.sum()).toBe(0);
2626
});
2727

28-
test.skip('computes the sum of an array of one number', () => {
29-
expect(calculator.sum([7])).toBe(7);
28+
test.skip('computes the sum of one number', () => {
29+
expect(calculator.sum(7)).toBe(7);
3030
});
3131

32-
test.skip('computes the sum of an array of two numbers', () => {
33-
expect(calculator.sum([7,11])).toBe(18);
32+
test.skip('computes the sum of two numbers', () => {
33+
expect(calculator.sum(7, 11)).toBe(18);
3434
});
3535

36-
test.skip('computes the sum of an array of many numbers', () => {
37-
expect(calculator.sum([1,3,5,7,9])).toBe(25);
36+
test.skip('computes the sum of many numbers', () => {
37+
expect(calculator.sum(1, 3, 5, 7, 9)).toBe(25);
3838
});
3939
});
4040

4141
describe('multiply', () => {
4242
test.skip('multiplies two numbers', () => {
43-
expect(calculator.multiply(2,4)).toBe(8);
43+
expect(calculator.multiply(2, 4)).toBe(8);
4444
});
4545

4646
test.skip('multiplies several numbers', () => {
47-
expect(calculator.multiply(2,4,6,8,10,12,14)).toBe(645120);
47+
expect(calculator.multiply(2, 4, 6, 8, 10, 12, 14)).toBe(645120);
4848
});
4949
});
5050

5151
describe('power', () => {
5252
test.skip('raises one number to the power of another number', () => {
53-
expect(calculator.power(4,3)).toBe(64); // 4 to third power is 64
53+
expect(calculator.power(4, 3)).toBe(64); // 4 to third power is 64
5454
});
5555
});
5656

08_calculator/solution/calculator-solution.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ const subtract = function (a, b) {
66
return a - b;
77
};
88

9-
const sum = function (array) {
10-
return array.reduce((total, current) => total + current, 0);
9+
const sum = function (...args) {
10+
return args.reduce((total, current) => total + current, 0);
1111
};
1212

1313
const multiply = function(...args){

08_calculator/solution/calculator-solution.spec.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,30 @@ describe('subtract', () => {
2121
});
2222

2323
describe('sum', () => {
24-
test('computes the sum of an empty array', () => {
25-
expect(calculator.sum([])).toBe(0);
24+
test('computes the sum of an empty parameter', () => {
25+
expect(calculator.sum()).toBe(0);
2626
});
2727

28-
test('computes the sum of an array of one number', () => {
29-
expect(calculator.sum([7])).toBe(7);
28+
test('computes the sum of one number', () => {
29+
expect(calculator.sum(7)).toBe(7);
3030
});
3131

32-
test('computes the sum of an array of two numbers', () => {
33-
expect(calculator.sum([7, 11])).toBe(18);
32+
test('computes the sum of two numbers', () => {
33+
expect(calculator.sum(7, 11)).toBe(18);
3434
});
3535

36-
test('computes the sum of an array of many numbers', () => {
37-
expect(calculator.sum([1, 3, 5, 7, 9])).toBe(25);
36+
test('computes the sum of many numbers', () => {
37+
expect(calculator.sum(1, 3, 5, 7, 9)).toBe(25);
3838
});
3939
});
4040

4141
describe('multiply', () => {
4242
test('multiplies two numbers', () => {
43-
expect(calculator.multiply([2, 4])).toBe(8);
43+
expect(calculator.multiply(2, 4)).toBe(8);
4444
});
4545

4646
test('multiplies several numbers', () => {
47-
expect(calculator.multiply([2, 4, 6, 8, 10, 12, 14])).toBe(645120);
47+
expect(calculator.multiply(2, 4, 6, 8, 10, 12, 14)).toBe(645120);
4848
});
4949
});
5050

0 commit comments

Comments
 (0)