Skip to main content
Module

x/rambda/source/anyPass.spec.js

Faster and smaller alternative to Ramda
Go to Latest
File
import {anyPass} from './anyPass'
test('happy', () => { const rules = [x => typeof x === 'string', x => x > 10] const predicate = anyPass(rules) expect(predicate('foo')).toBeTrue() expect(predicate(6)).toBeFalse()})
test('happy', () => { const rules = [x => typeof x === 'string', x => x > 10]
expect(anyPass(rules)(11)).toBeTrue()
expect(anyPass(rules)(undefined)).toBeFalse()})
const obj = { a: 1, b: 2,}
test('when returns true', () => { const conditionArr = [val => val.a === 1, val => val.a === 2]
expect(anyPass(conditionArr)(obj)).toBeTrue()})
test('when returns false + curry', () => { const conditionArr = [val => val.a === 2, val => val.b === 3]
expect(anyPass(conditionArr)(obj)).toBeFalse()})
test('with empty predicates list', () => { expect(anyPass([])(3)).toEqual(false)})
test('works with multiple inputs', () => { var fn = function (w, x, y, z) { console.log(w, x, y, z) return w + x === y + z } expect(anyPass([fn])(3, 3, 3, 3)).toBeTrue()})