wip: code formatting nits continued

This commit is contained in:
jdalton
2023-09-16 22:59:56 -07:00
parent 0b28b7f7b6
commit b5c59317ea
421 changed files with 7354 additions and 9005 deletions

41
test/isNil.spec.js Normal file
View File

@@ -0,0 +1,41 @@
import lodashStable from 'lodash';
import { falsey, args, slice, symbol, realm } from './utils';
import isNil from '../src/isNil';
describe('isNil', () => {
it('should return `true` for nullish values', () => {
expect(isNil(null)).toBe(true);
expect(isNil()).toBe(true);
expect(isNil(undefined)).toBe(true);
});
it('should return `false` for non-nullish values', () => {
const expected = lodashStable.map(falsey, (value) => value === null);
const actual = lodashStable.map(falsey, (value, index) => (index ? isNil(value) : isNil()));
expect(actual).toEqual(expected);
expect(isNil(args)).toBe(false);
expect(isNil([1, 2, 3])).toBe(false);
expect(isNil(true)).toBe(false);
expect(isNil(new Date())).toBe(false);
expect(isNil(new Error())).toBe(false);
expect(isNil(slice)).toBe(false);
expect(isNil({ a: 1 })).toBe(false);
expect(isNil(1)).toBe(false);
expect(isNil(/x/)).toBe(false);
expect(isNil('a')).toBe(false);
if (Symbol) {
expect(isNil(symbol)).toBe(false);
}
});
it('should work with nils from another realm', () => {
if (realm.object) {
expect(isNil(realm.null)).toBe(true);
expect(isNil(realm.undefined)).toBe(true);
}
});
});