odin-default-js-exercises/05_sumAll/solution/sumAll-solution.spec.js

26 lines
834 B
JavaScript
Raw Normal View History

2023-02-01 23:53:54 +00:00
const sumAll = require('./sumAll-solution');
2022-02-20 19:07:44 +00:00
2023-02-01 23:53:54 +00:00
describe('sumAll', () => {
test('sums numbers within the range', () => {
2023-01-21 17:53:41 +00:00
expect(sumAll(1, 4)).toEqual(10);
});
2023-02-01 23:53:54 +00:00
test.skip('works with large numbers', () => {
2023-01-21 17:53:41 +00:00
expect(sumAll(1, 4000)).toEqual(8002000);
});
2023-02-01 23:53:54 +00:00
test.skip('works with larger number first', () => {
2023-01-21 17:53:41 +00:00
expect(sumAll(123, 1)).toEqual(7626);
});
2023-02-01 23:53:54 +00:00
test.skip('returns ERROR with negative numbers', () => {
expect(sumAll(-10, 4)).toEqual('ERROR');
2023-01-21 17:53:41 +00:00
});
2023-02-01 23:53:54 +00:00
test.skip('returns ERROR with non-integer parameters', () => {
expect(sumAll(2.5, 4)).toEqual('ERROR');
2023-01-21 17:53:41 +00:00
});
2023-02-01 23:53:54 +00:00
test.skip('returns ERROR with non-number parameters', () => {
expect(sumAll(10, '90')).toEqual('ERROR');
2023-01-21 17:53:41 +00:00
});
2023-02-01 23:53:54 +00:00
test.skip('returns ERROR with non-number parameters', () => {
expect(sumAll(10, [90, 1])).toEqual('ERROR');
2023-01-21 17:53:41 +00:00
});
2022-02-20 19:07:44 +00:00
});