1
0
Fork 0
mirror of synced 2024-08-14 01:21:41 +12:00

Merge pull request #8956 from Budibase/fix/8843

Fix for JS helpers
This commit is contained in:
Michael Drury 2022-12-07 10:53:58 +00:00 committed by GitHub
commit eefba10623
2 changed files with 13 additions and 1 deletions

View file

@ -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 =

View file

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