Advertisement
kstoyanov

04. Sum of Numbers

Oct 26th, 2020
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. describe('sum(arr) - sum array of numbers', () => {
  2.   it('should return 3 for [1,2]', () => {
  3.     expect(sum([1, 2])).to.be.equal(3);
  4.   });
  5.   it('should return 1 for [1]', () => {
  6.     expect(sum([1])).to.be.equal(1);
  7.   });
  8.   it('should return 0 for empty array', () => {
  9.     expect(sum([])).to.be.equal(0);
  10.   });
  11.   it('should return 3 for [1.5, 2.5, -1]', () => {
  12.     expect(sum([1.5, 2.5, -1])).to.be.equal(3);
  13.   });
  14.   it('should return NaN for invalid data', () => {
  15.     expect(sum('invalid data')).to.be.NaN;
  16.   });
  17. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement