mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 18:07:49 +00:00
wip: code formatting nits continued
This commit is contained in:
37
test/isNaN.spec.js
Normal file
37
test/isNaN.spec.js
Normal file
@@ -0,0 +1,37 @@
|
||||
import lodashStable from 'lodash';
|
||||
import { falsey, args, slice, symbol, realm } from './utils';
|
||||
import isNaN from '../src/isNaN';
|
||||
|
||||
describe('isNaN', () => {
|
||||
it('should return `true` for NaNs', () => {
|
||||
expect(isNaN(NaN)).toBe(true);
|
||||
expect(isNaN(Object(NaN))).toBe(true);
|
||||
});
|
||||
|
||||
it('should return `false` for non-NaNs', () => {
|
||||
const expected = lodashStable.map(falsey, (value) => value !== value);
|
||||
|
||||
const actual = lodashStable.map(falsey, (value, index) => (index ? isNaN(value) : isNaN()));
|
||||
|
||||
expect(actual).toEqual(expected);
|
||||
|
||||
expect(isNaN(args)).toBe(false);
|
||||
expect(isNaN([1, 2, 3])).toBe(false);
|
||||
expect(isNaN(true)).toBe(false);
|
||||
expect(isNaN(new Date())).toBe(false);
|
||||
expect(isNaN(new Error())).toBe(false);
|
||||
expect(isNaN(slice)).toBe(false);
|
||||
expect(isNaN({ a: 1 })).toBe(false);
|
||||
expect(isNaN(1)).toBe(false);
|
||||
expect(isNaN(Object(1))).toBe(false);
|
||||
expect(isNaN(/x/)).toBe(false);
|
||||
expect(isNaN('a')).toBe(false);
|
||||
expect(isNaN(symbol)).toBe(false);
|
||||
});
|
||||
|
||||
it('should work with `NaN` from another realm', () => {
|
||||
if (realm.object) {
|
||||
expect(isNaN(realm.nan)).toBe(true);
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user