Repository URL to install this package:
|
Version:
2.0.5 ▾
|
import 'jest'
import { toEmpty, isEmpty, getEmpty, EMPTY } from '../src'
const getMocks = () => {
var obj = {
primitive: {
string: String('eh'),
number: Number(10),
boolean: Boolean(true),
nulls: null,
voids: void 0,
},
builtin: {
arguments: Arguments,
AsyncFunction,
GeneratorFunction,
stringIterator: Object.create(StringIterator),
mapIterator: Object.create(MapIterator),
setIterator: Object.create(SetIterator),
arrayIterator: Object.create(ArrayIterator),
float: '0.42',
nan: NaN,
infinity: Infinity,
promise: Promise.all('promised'),
obj: {},
array: [],
regexp: new RegExp('.'),
error: new Error('eh'),
symbol: Symbol.for('@@empty'),
set: new Set(),
map: new Map(),
// eslint-disable-next-line
generator: function*() {},
// eslint-disable-next-line
async: async function() {},
// eslint-disable-next-line
func: function() {},
// date: new Date(),
},
}
return obj
}
describe('species', () => {
it('empty primitives', () => {
const obj = getMocks()
const emptyPrimitives = Object.values(obj.primitive).map(x => getEmpty(x))
})
it.skip('empty builtin', () => {
const obj = getMocks()
const emptyBuiltIn = Object.values(obj.builtin).map(x => getEmpty(x))
const {
EMPTY_OBJ,
EMPTY_ARRAY,
EMPTY_STRING,
EMPTY_REGEXP,
EMPTY_ERROR,
EMPTY_FUNCTION,
} = EMPTY
const emptyBuiltInValues = [
EMPTY_OBJ,
EMPTY_STRING,
EMPTY_STRING,
EMPTY_OBJ,
EMPTY_OBJ,
EMPTY_OBJ,
EMPTY_OBJ,
EMPTY_STRING,
0,
0,
EMPTY_STRING,
EMPTY_OBJ,
EMPTY_ARRAY,
EMPTY_REGEXP,
EMPTY_ERROR,
new Set(),
new Map(),
EMPTY_STRING,
EMPTY_FUNCTION,
EMPTY_FUNCTION,
]
expect(emptyBuiltIn).toEqual(emptyBuiltInValues)
})
})