moy-fp
Version:
A functional programming library.
24 lines (20 loc) • 476 B
JavaScript
import __ from '../../src/Function/__'
/**
* (a -> Boolean) -> [a] -> a | undefined
*/
import find from '../../src/List/find'
test('find(not using __), satisfy pred', () => {
expect(
find(x => x === 3)([1, 2, 3, 4])
).toBe(3)
})
test('find(not using __), not satisfy pred', () => {
expect(
find(x => x === 5)([1, 2, 3, 4])
).toBeUndefined()
})
test('find(using __), satisfy pred', () => {
expect(
find(__, [1, 2, 3, 4])(x => x === 3)
).toBe(3)
})