UNPKG

@applicaster/zapp-react-native-utils

Version:

Applicaster Zapp React Native utilities package

38 lines (27 loc) 865 B
import { pathOr } from "../pathOr"; test("example 1", () => { const defaultValue = "defaultValue"; const path = ["a", "b", "c"]; const xs = { a: { b: { c: 1 } } }; const output = 1; expect(pathOr(defaultValue, path, xs)).toEqual(output); }); test("example 2", () => { const defaultValue = "defaultValue"; const path = ["a", "b"]; const xs = { a: { b: { c: 1 } } }; const output = { c: 1 }; expect(pathOr(defaultValue, path, xs)).toEqual(output); }); test("example 3", () => { const defaultValue = "defaultValue"; const path = ["a", "b", "x"]; const xs = { a: { b: { c: 1 } } }; expect(pathOr(defaultValue, path, xs)).toBe(defaultValue); }); test("example 4", () => { const defaultValue = "defaultValue"; const path = ["a", "b", "c"]; const xs = undefined; expect(pathOr(defaultValue, path, xs)).toBe(defaultValue); });