1
0
Fork 0
mirror of synced 2024-09-30 17:18:14 +13:00

Update JS HBS helper tests

This commit is contained in:
Andrew Kingston 2021-10-13 14:37:29 +01:00
parent 0dfa108ef5
commit 9ec1992522

View file

@ -4,7 +4,21 @@ const processJS = (js, context) => {
return processStringSync(encodeJSBinding(js), context)
}
describe("Test the JavaScript helper in Node", () => {
it("should not execute JS in Node", () => {
const output = processJS(`return 1`)
expect(output).toBe("JS bindings are not executed in a Node environment")
})
})
describe("Test the JavaScript helper", () => {
// JS bindings do not get evaluated on the server for safety.
// Since we want to run SJ for tests, we fake a window object to make
// it think that we're in the browser
beforeEach(() => {
window = {}
})
it("should execute a simple expression", () => {
const output = processJS(`return 1 + 2`)
expect(output).toBe("3")