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