@onflow/flow-js-testing
Version:
This package will expose a set of utility methods, to allow Cadence code testing with libraries like Jest
29 lines (24 loc) • 767 B
JavaScript
import {builtInMethods, emulator, init} from "../../src"
import {importManager} from "../../src/transformers"
import path from "path"
describe("transformers", () => {
beforeEach(async () => {
const basePath = path.resolve(__dirname, "../cadence")
await init(basePath)
return emulator.start()
})
// Stop emulator, so it could be restarted
afterEach(async () => {
return emulator.stop()
})
it("should inject contract for built-in methods", async () => {
const code = `
access(all) fun main() : UInt64 {
return getCurrentBlock().height
}
`
const transformed = await builtInMethods(code)
const importStatement = await importManager()
expect(transformed.includes(importStatement)).toBe(true)
})
})