From d3029d33ae748e39ea0fc20e9ede3261509f3f6c Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 6 Dec 2022 18:21:54 +0000 Subject: [PATCH] Minor fix for #8843 - the binding input drawer was using the format helper. rather than helpers. when generating JS helpers. --- .../builder/src/components/common/bindings/utils.js | 2 +- packages/string-templates/test/javascript.spec.js | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/builder/src/components/common/bindings/utils.js b/packages/builder/src/components/common/bindings/utils.js index c7b40604ad..8d414ffed3 100644 --- a/packages/builder/src/components/common/bindings/utils.js +++ b/packages/builder/src/components/common/bindings/utils.js @@ -24,7 +24,7 @@ export function addJSBinding(value, caretPos, binding, { helper } = {}) { if (!helper) { binding = `$("${binding}")` } else { - binding = `helper.${binding}()` + binding = `helpers.${binding}()` } if (caretPos.start) { value = diff --git a/packages/string-templates/test/javascript.spec.js b/packages/string-templates/test/javascript.spec.js index 5363f37e02..4ec7c48b1e 100644 --- a/packages/string-templates/test/javascript.spec.js +++ b/packages/string-templates/test/javascript.spec.js @@ -129,3 +129,15 @@ describe("Test the JavaScript helper", () => { expect(output).toBe("Error while executing JS") }) }) + +describe("check JS helpers", () => { + it("should error if using the format helper. not helpers.", () => { + const output = processJS(`return helper.toInt(4.3)`) + expect(output).toBe("Error while executing JS") + }) + + it("should be able to use toInt", () => { + const output = processJS(`return helpers.toInt(4.3)`) + expect(output).toBe(4) + }) +}) \ No newline at end of file