import { isNumber, isNaturalNumber, isWholeNumber } from '../src/type-utils'; describe('isNumber utility', () => { it('Checks if a value is number', () => { expect(isNumber(10)).toBe(true); }); it('Checks if negative value is number', () => { expect(isNumber(-10)).toBe(true); }); it('Checks if postive fraction is number', () => { expect(isNumber(10.2255)).toBe(true); }); it('Checks if negative fraction is number', () => { expect(isNumber(-10.2255)).toBe(true); }); it('Checks if string is not considered number', () => { expect(isNumber("hello")).toBe(false); }); it('Checks if number quoted as string is not considered number', () => { expect(isNumber("100")).toBe(false); }); it('Checks if positive infinity is not considered number', () => { expect(isNumber(Number.POSITIVE_INFINITY)).toBe(false); }); it('Checks if negative infinity is not considered number', () => { expect(isNumber(Number.NEGATIVE_INFINITY)).toBe(false); }); it('Checks if a date is not considered number', () => { expect(isNumber(new Date())).toBe(false); }); it('Checks if an object is not considered number', () => { expect(isNumber({ foo: 'bar', hello: 'hi' })).toBe(false); }); it('Checks if a boolean is not considered number', () => { expect(isNumber(true)).toBe(false); }); it('Checks if 0 is considered number', () => { expect(isNumber(0)).toBe(true); }); }); describe('isNaturalNumber utility', () => { it('Checks if a value is natural number', () => { expect(isNaturalNumber(10)).toBe(true); }); it('Checks if negative value is not a natural number', () => { expect(isNaturalNumber(-10)).toBe(false); }); it('Checks if postive fraction is not a natural number', () => { expect(isNaturalNumber(10.2255)).toBe(false); }); it('Checks if negative fraction is not a natural number', () => { expect(isNaturalNumber(-10.2255)).toBe(false); }); it('Checks if string is not considered a natural number', () => { expect(isNaturalNumber("hello")).toBe(false); }); it('Checks if number quoted as string is not considered a natural number', () => { expect(isNaturalNumber("100")).toBe(false); }); it('Checks if positive infinity is not considered a natural a natural number', () => { expect(isNaturalNumber(Number.POSITIVE_INFINITY)).toBe(false); }); it('Checks if negative infinity is not considered a natural a natural number', () => { expect(isNaturalNumber(Number.NEGATIVE_INFINITY)).toBe(false); }); it('Checks if a date is not considered a natural number', () => { expect(isNaturalNumber(new Date())).toBe(false); }); it('Checks if an object is not considered a natural number', () => { expect(isNaturalNumber({ foo: 'bar', hello: 'hi' })).toBe(false); }); it('Checks if a boolean is not considered a natural number', () => { expect(isNaturalNumber(true)).toBe(false); }); it('Checks if 0 is not considered a natural number', () => { expect(isNaturalNumber(0)).toBe(false); }); }); describe('isWholeNumber utility', () => { it('Checks if a value is whole number', () => { expect(isWholeNumber(10)).toBe(true); }); it('Checks if negative value is not a whole number', () => { expect(isWholeNumber(-10)).toBe(false); }); it('Checks if postive fraction is not a whole number', () => { expect(isWholeNumber(10.2255)).toBe(false); }); it('Checks if negative fraction is not a whole number', () => { expect(isWholeNumber(-10.2255)).toBe(false); }); it('Checks if string is not considered a whole number', () => { expect(isWholeNumber("hello")).toBe(false); }); it('Checks if number quoted as string is not considered a whole number', () => { expect(isWholeNumber("100")).toBe(false); }); it('Checks if positive infinity is not considered a whole number', () => { expect(isWholeNumber(Number.POSITIVE_INFINITY)).toBe(false); }); it('Checks if negative infinity is not considered a whole number', () => { expect(isWholeNumber(Number.NEGATIVE_INFINITY)).toBe(false); }); it('Checks if a date is not considered a whole number', () => { expect(isWholeNumber(new Date())).toBe(false); }); it('Checks if an object is not considered a whole number', () => { expect(isWholeNumber({ foo: 'bar', hello: 'hi' })).toBe(false); }); it('Checks if a boolean is not considered a whole number', () => { expect(isWholeNumber(true)).toBe(false); }); it('Checks if 0 is not considered a whole number', () => { expect(isWholeNumber(0)).toBe(true); }); it('Checks if -0 is not considered a whole number', () => { expect(isWholeNumber(-0)).toBe(true); }); it('Checks if 1.0 is not considered a whole number', () => { expect(isWholeNumber(1.0)).toBe(true); }); });