Skip to main content
Module

x/rambda/source/allPass.spec.js

Faster and smaller alternative to Ramda
Go to Latest
File
import {allPass} from './allPass'
test('happy', () => { const rules = [x => typeof x === 'number', x => x > 10, x => x * 7 < 100]
expect(allPass(rules)(11)).toBeTrue()
expect(allPass(rules)(undefined)).toBeFalse()})
test('when returns true', () => { const conditionArr = [val => val.a === 1, val => val.b === 2]
expect( allPass(conditionArr)({ a: 1, b: 2, }) ).toBeTrue()})
test('when returns false', () => { const conditionArr = [val => val.a === 1, val => val.b === 3]
expect( allPass(conditionArr)({ a: 1, b: 2, }) ).toBeFalse()})
test('works with multiple inputs', () => { var fn = function (w, x, y, z) { return w + x === y + z } expect(allPass([fn])(3, 3, 3, 3)).toBeTrue()})