Skip to main content
Module

x/rambda/whereEq.spec.js

Faster and smaller alternative to Ramda
Go to Latest
File
import { whereEq } from './whereEq'
test('when true', () => { const condition = { a : 1 } const input = { a : 1, b : 2, }
const result = whereEq(condition, input) const expectedResult = true
expect(result).toEqual(expectedResult)})
test('when false', () => { const condition = { a : 1 } const input = { b : 2 }
const result = whereEq(condition, input) const expectedResult = false
expect(result).toEqual(expectedResult)})
test('with nested object', () => { const condition = { a : { b : 1 } } const input = { a : { b : 1 }, c : 2, }
const result = whereEq(condition)(input) const expectedResult = true
expect(result).toEqual(expectedResult)})
test('with wrong input', () => { const condition = { a : { b : 1 } }
expect(() => whereEq(condition, null)).toThrowWithMessage(TypeError, 'Cannot read property \'a\' of null')})