Skip to main content
Module

x/rambda/pathOr.spec.js

Faster and smaller alternative to Ramda
Go to Latest
File
import { pathOr } from './pathOr'
test('with undefined', () => { const result = pathOr( 'foo', 'x.y', { x : { y : 1 } } )
expect(result).toEqual(1)})
test('with null', () => { const result = pathOr( 'foo', 'x.y', null )
expect(result).toEqual('foo')})
test('with NaN', () => { const result = pathOr( 'foo', 'x.y', NaN )
expect(result).toEqual('foo')})
test('curry case (x)(y)(z)', () => { const result = pathOr('foo')('x.y.z')({ x : { y : { a : 1 } } })
expect(result).toEqual('foo')})
test('curry case (x)(y,z)', () => { const result = pathOr('foo', 'x.y.z')({ x : { y : { a : 1 } } })
expect(result).toEqual('foo')})
test('curry case (x,y)(z)', () => { const result = pathOr('foo')('x.y.z', { x : { y : { a : 1 } } })
expect(result).toEqual('foo')})