@onflow/flow-js-testing
Version:
This package will expose a set of utility methods, to allow Cadence code testing with libraries like Jest
35 lines (29 loc) • 716 B
JavaScript
import path from "path"
import {init, emulator, executeScript, shallResolve} from "../src"
beforeEach(async () => {
const basePath = path.resolve(__dirname, "./cadence")
await init(basePath)
await emulator.start()
})
test("pass array of dictionaries", async () => {
const code = `
access(all) fun main(meta: [{String:String}], key: String): String?{
return meta[0]![key]
}
`
const args = [
[
{
name: "Giovanni Giorgio",
nickname: "Giorgio",
},
],
"name",
]
const [result] = await shallResolve(executeScript({code, args}))
expect(result).toBe("Giovanni Giorgio")
})
afterEach(async () => {
// Stop the emulator
await emulator.stop()
})