|
| 1 | +const { isIntegers } = require('../lib/isIntegers'); |
| 2 | + |
| 3 | +describe('isIntegers', () => { |
| 4 | + it('should throw an error if no parameters are provided', () => { |
| 5 | + expect(() => isIntegers()).toThrow(); |
| 6 | + }); |
| 7 | + |
| 8 | + it('should throw an error if any parameters provided are not numbers', () => { |
| 9 | + expect(() => isIntegers('')).toThrow(); |
| 10 | + expect(() => isIntegers('test', 2)).toThrow(); |
| 11 | + }); |
| 12 | + |
| 13 | + it('should return false if any parameters are not an integer', () => { |
| 14 | + expect(isIntegers(2.5)).toBe(false); |
| 15 | + expect(isIntegers(2, 2.5)).toBe(false); |
| 16 | + }); |
| 17 | + |
| 18 | + it('should return true if all parameters are integers', () => { |
| 19 | + expect(isIntegers(0)).toBe(true); |
| 20 | + expect(isIntegers(2)).toBe(true); |
| 21 | + expect(isIntegers(-1)).toBe(true); |
| 22 | + expect(isIntegers(-1, 0, 2)).toBe(true); |
| 23 | + }); |
| 24 | + |
| 25 | + it('should return true if all parameters can parse to integer', () => { |
| 26 | + expect(isIntegers('0')).toBe(true); |
| 27 | + expect(isIntegers('2')).toBe(true); |
| 28 | + expect(isIntegers('-1')).toBe(true); |
| 29 | + expect(isIntegers('-1', '0', '2')).toBe(true); |
| 30 | + expect(isIntegers('-1', 0, '2')).toBe(true); |
| 31 | + }); |
| 32 | +}); |
0 commit comments