Update tests
This commit is contained in:
parent
6f6100e7a2
commit
f0a149984d
|
@ -1,21 +1,4 @@
|
|||
// import { validate as isValidUUID } from "uuid"
|
||||
|
||||
jest.mock("@budibase/handlebars-helpers/lib/math", () => {
|
||||
const actual = jest.requireActual("@budibase/handlebars-helpers/lib/math")
|
||||
|
||||
return {
|
||||
...actual,
|
||||
random: () => 10,
|
||||
}
|
||||
})
|
||||
jest.mock("@budibase/handlebars-helpers/lib/uuid", () => {
|
||||
const actual = jest.requireActual("@budibase/handlebars-helpers/lib/uuid")
|
||||
|
||||
return {
|
||||
...actual,
|
||||
uuid: () => "f34ebc66-93bd-4f7c-b79b-92b5569138bc",
|
||||
}
|
||||
})
|
||||
import { validate as isValidUUID } from "uuid"
|
||||
|
||||
import { processStringSync, encodeJSBinding } from "@budibase/string-templates"
|
||||
|
||||
|
@ -47,8 +30,7 @@ describe("jsRunner", () => {
|
|||
expect(output).toBe(3)
|
||||
})
|
||||
|
||||
// TODO This should be reenabled when running on isolated-vm
|
||||
it.skip("should prevent sandbox escape", async () => {
|
||||
it("should prevent sandbox escape", async () => {
|
||||
const output = await processJS(
|
||||
`return this.constructor.constructor("return process")()`
|
||||
)
|
||||
|
@ -58,26 +40,26 @@ describe("jsRunner", () => {
|
|||
describe("helpers", () => {
|
||||
runJsHelpersTests({
|
||||
funcWrap: (func: any) => config.doInContext(config.getAppId(), func),
|
||||
// testsToSkip: ["random", "uuid"],
|
||||
testsToSkip: ["random", "uuid"],
|
||||
})
|
||||
|
||||
// describe("uuid", () => {
|
||||
// it("uuid helper returns a valid uuid", async () => {
|
||||
// const result = await processJS("return helpers.uuid()")
|
||||
// expect(result).toBeDefined()
|
||||
// expect(isValidUUID(result)).toBe(true)
|
||||
// })
|
||||
// })
|
||||
describe("uuid", () => {
|
||||
it("uuid helper returns a valid uuid", async () => {
|
||||
const result = await processJS("return helpers.uuid()")
|
||||
expect(result).toBeDefined()
|
||||
expect(isValidUUID(result)).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
// describe("random", () => {
|
||||
// it("random helper returns a valid number", async () => {
|
||||
// const min = 1
|
||||
// const max = 8
|
||||
// const result = await processJS(`return helpers.random(${min}, ${max})`)
|
||||
// expect(result).toBeDefined()
|
||||
// expect(result).toBeGreaterThanOrEqual(min)
|
||||
// expect(result).toBeLessThanOrEqual(max)
|
||||
// })
|
||||
// })
|
||||
describe("random", () => {
|
||||
it("random helper returns a valid number", async () => {
|
||||
const min = 1
|
||||
const max = 8
|
||||
const result = await processJS(`return helpers.random(${min}, ${max})`)
|
||||
expect(result).toBeDefined()
|
||||
expect(result).toBeGreaterThanOrEqual(min)
|
||||
expect(result).toBeLessThanOrEqual(max)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue