|
| 1 | +const { isNegativeInteger } = require('../lib/isNegativeInteger'); |
| 2 | + |
| 3 | +const MAX_SAFE_INTEGER = 9007199254740991; |
| 4 | +describe('IsNegativeInteger', () => { |
| 5 | + it('should return false for positive integers or 0', () => { |
| 6 | + expect(isNegativeInteger(2, 4, 200)).toBe(false); |
| 7 | + expect(isNegativeInteger(MAX_SAFE_INTEGER, 4, 200)).toBe(false); |
| 8 | + expect(isNegativeInteger(0, 98, 225, 56)).toBe(false); |
| 9 | + }); |
| 10 | + |
| 11 | + it('should return true for negative numbers', () => { |
| 12 | + expect(isNegativeInteger(-3, -4, -200)).toBe(true); |
| 13 | + expect(isNegativeInteger(-34, -98, -225, -56)).toBe(true); |
| 14 | + }); |
| 15 | + |
| 16 | + it('should return false for floats', () => { |
| 17 | + expect(isNegativeInteger(2.6, 4.9, 23.67)).toBe(false); |
| 18 | + expect(isNegativeInteger(2, 4, 23.67)).toBe(false); |
| 19 | + expect(isNegativeInteger(-10.2, -4.6, -200.4)).toBe(false); |
| 20 | + expect(isNegativeInteger(-32.7, 98, 225, 56)).toBe(false); |
| 21 | + }); |
| 22 | + |
| 23 | + it('should return false for other values', () => { |
| 24 | + expect(isNegativeInteger({})).toBe(false); |
| 25 | + expect(isNegativeInteger(2, [])).toBe(false); |
| 26 | + expect(isNegativeInteger(1, 'S')).toBe(false); |
| 27 | + expect(isNegativeInteger(MAX_SAFE_INTEGER + 1)).toBe(false); |
| 28 | + }); |
| 29 | +}); |
0 commit comments