1
0
Fork 0
mirror of synced 2024-07-03 21:40:55 +12:00

Test only js helpers

This commit is contained in:
Adria Navarro 2024-01-30 16:52:25 +01:00
parent f5157c4184
commit 43e536e7a6
2 changed files with 14 additions and 2 deletions

View file

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

View file

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