Browse Source

Update JS HBS helper tests

pull/4089/head
Andrew Kingston 5 years ago
parent
commit
94f790f310
  1. 14
      packages/string-templates/test/javascript.spec.js

14
packages/string-templates/test/javascript.spec.js

@ -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")

Loading…
Cancel
Save