moy-fp
Version:
A functional programming library.
52 lines (44 loc) • 765 B
JavaScript
import __ from '../../src/Function/__'
/**
* a -> a | undefined
*/
import empty from '../../src/Function/empty'
test('empty(not using __), String', () => {
expect(
empty('murakami')
).toBe('')
})
test('empty(not using __), Array', () => {
expect(
empty([1, 2, 3, 4])
).toEqual([])
})
test('empty(not using __), Object', () => {
expect(
empty({
a: 1,
b: 2,
c: 3.
})
).toEqual({})
})
test('empty(not using __), Number', () => {
expect(
empty(12)
).toEqual(undefined)
})
test('empty(not using __), empty method', () => {
expect(
empty({
empty(){
return 3
},
a: 1,
})
).toEqual(3)
})
test('empty(using __)', () => {
expect(
empty(__)('murakami')
).toBe('')
})