UNPKG

@onflow/flow-js-testing

Version:

This package will expose a set of utility methods, to allow Cadence code testing with libraries like Jest

37 lines (32 loc) 855 B
import {getValueByKey} from "../../src/utils" describe("testing utilities", function () { test("extract object value - simple key", () => { const expected = 42 const key = "answer" const obj = { [key]: expected, } const actual = getValueByKey(key, obj) expect(actual).toBe(expected) }) test("extract object value - nested key", () => { const expected = 42 const key = "some.nested.value" const obj = { some: { nested: { value: expected, }, }, } const actual = getValueByKey(key, obj) expect(actual).toBe(expected) }) test("extract object value - not an object", () => { const expected = null const key = "some.nested.value" const obj = "not an object" const actual = getValueByKey(key, obj) expect(actual).toBe(expected) }) })