From daa87915e889300be75e07e89fdca1d6405bcc90 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 19 Jan 2024 13:45:23 +0100 Subject: [PATCH] Test examples --- .../string-templates/test/manifest.spec.js | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 packages/string-templates/test/manifest.spec.js diff --git a/packages/string-templates/test/manifest.spec.js b/packages/string-templates/test/manifest.spec.js new file mode 100644 index 0000000000..90e23dcedd --- /dev/null +++ b/packages/string-templates/test/manifest.spec.js @@ -0,0 +1,22 @@ +const fs = require("fs") +const { processString } = require("../src/index.cjs") + +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) + }) + }) +})