![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/vreg/node_modules/@bugsnag/core/lib/test/ |
import intRange from '../validators/int-range' import stringWithLength from '../validators/string-with-length' describe('intRange(min, max)(val)', () => { it('work with various values', () => { // default min/max: 1 to Infinity expect(intRange()(10)).toBe(true) expect(intRange()(1e5)).toBe(true) for (let i = 1; i <= 1000; i++) expect(intRange()(i)).toBe(true) expect(intRange()(-10)).toBe(false) expect(intRange()(0)).toBe(false) expect(intRange()(1.123)).toBe(false) expect(intRange()('')).toBe(false) expect(intRange()('100')).toBe(false) // custom min/max expect(intRange(-10, 20)(11)).toBe(true) expect(intRange(-10, 20)(-13)).toBe(false) expect(intRange(-10, 20)(20)).toBe(true) expect(intRange(-10, 20)(21)).toBe(false) }) }) describe('stringWithLength(val)', () => { it('should work with various values', () => { expect(stringWithLength('hi')).toBe(true) expect(stringWithLength('')).toBe(false) expect(stringWithLength(null)).toBe(false) expect(stringWithLength(undefined)).toBe(false) expect(stringWithLength(10)).toBe(false) expect(stringWithLength([])).toBe(false) }) })