From 55699cfaffd49de3edd5138ff66263549682face Mon Sep 17 00:00:00 2001 From: Sam Rose Date: Mon, 7 Oct 2024 12:23:22 +0100 Subject: [PATCH] Don't clone non-object/non-arrays, use default JS in manifest.spec.ts. --- packages/string-templates/src/helpers/javascript.ts | 6 +++++- packages/string-templates/test/manifest.spec.ts | 8 ++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/string-templates/src/helpers/javascript.ts b/packages/string-templates/src/helpers/javascript.ts index 4d53fe335d..61fe872103 100644 --- a/packages/string-templates/src/helpers/javascript.ts +++ b/packages/string-templates/src/helpers/javascript.ts @@ -64,7 +64,11 @@ const getContextValue = (path: string, context: any) => { if (isBackendService()) { return data } else { - return cloneDeep(data) + if (typeof data === "object") { + return cloneDeep(data) + } else { + return data + } } } diff --git a/packages/string-templates/test/manifest.spec.ts b/packages/string-templates/test/manifest.spec.ts index de0e3355fd..2d09bc7871 100644 --- a/packages/string-templates/test/manifest.spec.ts +++ b/packages/string-templates/test/manifest.spec.ts @@ -1,5 +1,3 @@ -import vm from "vm" - jest.mock("@budibase/handlebars-helpers/lib/math", () => { const actual = jest.requireActual("@budibase/handlebars-helpers/lib/math") @@ -17,7 +15,7 @@ jest.mock("@budibase/handlebars-helpers/lib/uuid", () => { } }) -import { processString, setJSRunner } from "../src/index" +import { defaultJSSetup, processString } from "../src/index" import tk from "timekeeper" import { getParsedManifest, runJsHelpersTests } from "./utils" @@ -32,9 +30,7 @@ describe("manifest", () => { const manifest = getParsedManifest() beforeAll(() => { - setJSRunner((js, context) => { - return vm.runInNewContext(js, context, { timeout: 1000 }) - }) + defaultJSSetup() }) describe("examples are valid", () => {