From 43e536e7a6f0049528ac33b5850a151544b07412 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 30 Jan 2024 16:52:25 +0100 Subject: [PATCH] Test only js helpers --- packages/string-templates/src/helpers/list.js | 5 +++++ packages/string-templates/test/manifest.spec.js | 11 +++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/string-templates/src/helpers/list.js b/packages/string-templates/src/helpers/list.js index 739d8b50be..c10a732371 100644 --- a/packages/string-templates/src/helpers/list.js +++ b/packages/string-templates/src/helpers/list.js @@ -3,6 +3,8 @@ const helperList = require("@budibase/handlebars-helpers") let helpers = undefined +const helpersToRemove = ["sortBy"] + module.exports.getHelperList = () => { if (helpers) { return helpers @@ -23,6 +25,9 @@ module.exports.getHelperList = () => { helpers[key] = externalHandlebars.addedHelpers[key] } + for (const toRemove of helpersToRemove) { + delete helpers[toRemove] + } Object.freeze(helpers) return helpers } diff --git a/packages/string-templates/test/manifest.spec.js b/packages/string-templates/test/manifest.spec.js index 01fb088bbc..7c794d8c23 100644 --- a/packages/string-templates/test/manifest.spec.js +++ b/packages/string-templates/test/manifest.spec.js @@ -24,6 +24,7 @@ const { } = require("../src/index.cjs") const tk = require("timekeeper") +const { getHelperList } = require("../src/helpers") tk.freeze("2021-01-21T12:00:00") @@ -108,9 +109,15 @@ describe("manifest", () => { }) describe("can be parsed and run as js", () => { - describe.each(Object.keys(examples))("%s", collection => { + const jsHelpers = getHelperList() + const jsExamples = Object.keys(examples).reduce((acc, v) => { + acc[v] = examples[v].filter(([key]) => jsHelpers[key]) + return acc + }, {}) + + describe.each(Object.keys(jsExamples))("%s", collection => { it.each( - examples[collection].filter( + jsExamples[collection].filter( ([_, { requiresHbsBody }]) => !requiresHbsBody ) )("%s", async (_, { hbs, js }) => {