mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-03 16:47:49 +00:00
wip: code formatting nits continued
This commit is contained in:
24
test/toInteger-methods.spec.js
Normal file
24
test/toInteger-methods.spec.js
Normal file
@@ -0,0 +1,24 @@
|
||||
import lodashStable from 'lodash';
|
||||
import { _, MAX_SAFE_INTEGER, MAX_INTEGER } from './utils';
|
||||
|
||||
describe('toInteger methods', () => {
|
||||
lodashStable.each(['toInteger', 'toSafeInteger'], (methodName) => {
|
||||
const func = _[methodName];
|
||||
const isSafe = methodName === 'toSafeInteger';
|
||||
|
||||
it(`\`_.${methodName}\` should convert values to integers`, () => {
|
||||
expect(func(-5.6)).toBe(-5);
|
||||
expect(func('5.6')).toBe(5);
|
||||
expect(func()).toBe(0);
|
||||
expect(func(NaN)).toBe(0);
|
||||
|
||||
const expected = isSafe ? MAX_SAFE_INTEGER : MAX_INTEGER;
|
||||
expect(func(Infinity)).toBe(expected);
|
||||
expect(func(-Infinity)).toBe(-expected);
|
||||
});
|
||||
|
||||
it(`\`_.${methodName}\` should support \`value\` of \`-0\``, () => {
|
||||
expect(1 / func(-0)).toBe(-Infinity);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user