Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save charleslukes/5d8e4092436bf9ec7854417cd2c69061 to your computer and use it in GitHub Desktop.
Save charleslukes/5d8e4092436bf9ec7854417cd2c69061 to your computer and use it in GitHub Desktop.
addMethod.test.js
describe('addNumbers method ', () => {
it('Should contain atleast one input ', () => {
expect(addNumber(1,2)).toBe(3);
expect(addNumber(1)).toBe(1);
});
it('Should throw an error is user doesnt input value ', () => {
expect(addNumber()).Throw();
})
it('Should return the sum of numbers in the arguments ', () => {
expect(addNumber(1,3)).toBe(4);
expect(addNumber(2,3,5)).toBe(10);
expect(addNumber(2,3,2,2,2,2)).toBe(13);
})
it('Should add the numbers in the arguments ', () => {
expect(addNumber(1,3)).toBe(4);
expect(addNumber(2,3,5)).toBe(10);
expect(addNumber(2,3,2,2,2,2)).toBe(13);
})
it('Should check that the user inputs are numbers ', () => {
expect(addNumber(true, false)).toBe('Input must be a number');
expect(addNumber(' ', '1')).toBe('Input must be a number');
expect(addNumber(2, '3')).toBe('Input must be a number');
expect(addNumber('10', '2')).toBe('Input must be a number');
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment