1
0
Fork 0
mirror of synced 2024-09-08 13:41:09 +12:00
budibase/packages/string-templates/test/manifest.spec.js

35 lines
886 B
JavaScript
Raw Normal View History

2024-01-22 22:40:26 +13:00
jest.mock("@budibase/handlebars-helpers/lib/math", () => {
const actual = jest.requireActual("@budibase/handlebars-helpers/lib/math")
return {
...actual,
random: () => 10,
}
})
2024-01-20 01:45:23 +13:00
const fs = require("fs")
const { processString } = require("../src/index.cjs")
2024-01-20 02:05:35 +13:00
const tk = require("timekeeper")
tk.freeze("2021-01-21T12:00:00")
2024-01-20 01:45:23 +13:00
const manifest = JSON.parse(
fs.readFileSync(require.resolve("../manifest.json"), "utf8")
)
const examples = Object.keys(manifest).flatMap(collection =>
Object.keys(manifest[collection]).map(fnc => [collection, fnc])
)
describe("manifest", () => {
describe("examples are valid", () => {
it.each(examples)("%s - %s", async (collection, func) => {
const example = manifest[collection][func].example
const [hbs, js] = example.split("->").map(x => x.trim())
expect(await processString(hbs)).toEqual(js)
})
})
})