UNPKG

moy-fp

Version:
42 lines (35 loc) 855 B
import __ from '../../src/Function/__' /** * [k] -> {k: v} -> v | undefined */ import path from '../../src/Object/path' test('path(not using __), length 0', () => { expect( path([])({a: 1, b: 2, c: 3}) ).toEqual({a: 1, b: 2, c: 3}) }) test('path(not using __), length 1', () => { expect( path(['a'])({a: 1, b: 2, c: 3}) ).toBe(1) }) test('path(not using __), length 2', () => { expect( path(['a', 'x'])({a: {x: 1}, b: 2, c: 3}) ).toBe(1) }) test('path(not using __), length 2, null', () => { expect( path(['a', 'x'])({a: null, b: 2, c: 3}) ).toBe(undefined) }) test('path(not using __), length 2, undefined', () => { expect( path(['a', 'x'])({a: undefined, b: 2, c: 3}) ).toBe(undefined) }) test('path(using __), length 2', () => { expect( path(__, {a: {x: 1}, b: 2, c: 3})(['a', 'x']) ).toBe(1) })