From 786acaa12127dcf21c312dab2d80848dde06e0b8 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 31 Jan 2024 13:59:16 +0100 Subject: [PATCH] Add basic test --- .../src/jsRunner/tests/jsRunner.spec.ts | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 packages/server/src/jsRunner/tests/jsRunner.spec.ts diff --git a/packages/server/src/jsRunner/tests/jsRunner.spec.ts b/packages/server/src/jsRunner/tests/jsRunner.spec.ts new file mode 100644 index 0000000000..730a92e99b --- /dev/null +++ b/packages/server/src/jsRunner/tests/jsRunner.spec.ts @@ -0,0 +1,21 @@ +import { processStringSync, encodeJSBinding } from "@budibase/string-templates" +import TestConfiguration from "../../tests/utilities/TestConfiguration" + +describe("jsRunner", () => { + const config = new TestConfiguration() + + beforeAll(async () => { + await config.init() + }) + + const processJS = (js: string, context?: object) => { + return config.doInContext(config.getAppId(), async () => + processStringSync(encodeJSBinding(js), context || {}) + ) + } + + it("it can run a basic javascript", async () => { + const output = await processJS(`return 1 + 2`) + expect(output).toBe(3) + }) +})