1
0
Fork 0
mirror of synced 2024-07-04 22:11:23 +12:00

Fix some array examples

This commit is contained in:
Adria Navarro 2024-01-22 15:30:15 +01:00
parent 6f87a6f0bc
commit b66fac87cc

View file

@ -32,12 +32,14 @@ describe("manifest", () => {
let [hbs, js] = example.split("->").map(x => x.trim())
const context = {}
const context = {
double: i => i * 2,
}
const arrays = hbs.match(/\[[^/\]]+\]/)
arrays.forEach((arrayString, i) => {
hbs = hbs.replace(new RegExp(escapeRegExp(arrayString)), `array${i}`)
context[`array${i}`] = JSON.parse(arrayString)
context[`array${i}`] = JSON.parse(arrayString.replace(/\'/g, '"'))
})
if (js === undefined) {
@ -46,6 +48,14 @@ describe("manifest", () => {
}
const result = await processString(hbs, context)
try {
let parsedExpected
if (
Array.isArray((parsedExpected = JSON.parse(js.replace(/\'/g, '"'))))
) {
js = parsedExpected.join(",")
}
} catch {}
expect(result).toEqual(js)
})
})