From 9ec1992522b5c4132fc3b46a6cf692235501bb56 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Wed, 13 Oct 2021 14:37:29 +0100 Subject: [PATCH] Update JS HBS helper tests --- packages/string-templates/test/javascript.spec.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/string-templates/test/javascript.spec.js b/packages/string-templates/test/javascript.spec.js index 30ce9bbd60..07cc72c298 100644 --- a/packages/string-templates/test/javascript.spec.js +++ b/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")