@technobuddha/library
Version:
A large library of useful functions
21 lines (16 loc) • 486 B
text/typescript
import { toInteger } from './to-integer.ts';
describe('toInteger', () => {
test('should return numbers', () => {
expect(toInteger(123456.789)).toBe(123456);
});
test('should convert strings', () => {
expect(toInteger('123456.789')).toBe(123456);
});
test('should convert booleans', () => {
expect(toInteger(false)).toBe(0);
expect(toInteger(true)).toBe(1);
});
test('convert other types are NaN', () => {
expect(toInteger({})).toBeNaN();
});
});