Fix tests
This commit is contained in:
parent
3d936069cd
commit
6c78c7a45f
|
@ -14,13 +14,6 @@ const processJS = (js, context) => {
|
||||||
describe("Javascript", () => {
|
describe("Javascript", () => {
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
setJSRunner((js, context) => {
|
setJSRunner((js, context) => {
|
||||||
context = {
|
|
||||||
...context,
|
|
||||||
alert: undefined,
|
|
||||||
setInterval: undefined,
|
|
||||||
setTimeout: undefined,
|
|
||||||
}
|
|
||||||
vm.createContext(context)
|
|
||||||
return vm.runInNewContext(js, context, { timeout: 1000 })
|
return vm.runInNewContext(js, context, { timeout: 1000 })
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
const vm = require("vm")
|
||||||
|
|
||||||
jest.mock("@budibase/handlebars-helpers/lib/math", () => {
|
jest.mock("@budibase/handlebars-helpers/lib/math", () => {
|
||||||
const actual = jest.requireActual("@budibase/handlebars-helpers/lib/math")
|
const actual = jest.requireActual("@budibase/handlebars-helpers/lib/math")
|
||||||
|
|
||||||
|
@ -15,7 +17,7 @@ jest.mock("@budibase/handlebars-helpers/lib/uuid", () => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const { processString } = require("../src/index.js")
|
const { processString, setJSRunner } = require("../src/index.js")
|
||||||
|
|
||||||
const tk = require("timekeeper")
|
const tk = require("timekeeper")
|
||||||
const { getParsedManifest, runJsHelpersTests } = require("./utils")
|
const { getParsedManifest, runJsHelpersTests } = require("./utils")
|
||||||
|
@ -29,6 +31,12 @@ function escapeRegExp(string) {
|
||||||
describe("manifest", () => {
|
describe("manifest", () => {
|
||||||
const manifest = getParsedManifest()
|
const manifest = getParsedManifest()
|
||||||
|
|
||||||
|
beforeAll(() => {
|
||||||
|
setJSRunner((js, context) => {
|
||||||
|
return vm.runInNewContext(js, context, { timeout: 1000 })
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe("examples are valid", () => {
|
describe("examples are valid", () => {
|
||||||
describe.each(Object.keys(manifest))("%s", collection => {
|
describe.each(Object.keys(manifest))("%s", collection => {
|
||||||
it.each(manifest[collection])("%s", async (_, { hbs, js }) => {
|
it.each(manifest[collection])("%s", async (_, { hbs, js }) => {
|
||||||
|
|
Loading…
Reference in New Issue