diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-08-02 12:34:39 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-08-02 12:34:39 -0300 |
commit | b4018984c7d3a9b6fd94721ab5df1b4b7124bc0a (patch) | |
tree | bb19f5952b7001c26db74ac74d89e86c997908ed /test | |
parent | a88b415391b1c191292a9a0aa7e40152066483e2 (diff) |
infra, test: new stubTemplate utility (slots permissable & as-are)
Diffstat (limited to 'test')
-rw-r--r-- | test/lib/content-function.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/lib/content-function.js b/test/lib/content-function.js index 5216c4f2..a9e5f449 100644 --- a/test/lib/content-function.js +++ b/test/lib/content-function.js @@ -90,6 +90,29 @@ export function testContentFunctions(t, message, fn) { t.matchSnapshot(result, description); }; + evaluate.stubTemplate = name => { + // Creates a particularly permissable template, allowing any slot values + // to be stored and just outputting the contents of those slots as-are. + + return new (class extends html.Template { + #slotValues = {}; + + constructor() { + super({ + content: () => `${name}: ${JSON.stringify(this.#slotValues)}`, + }); + } + + setSlots(slotNamesToValues) { + Object.assign(this.#slotValues, slotNamesToValues); + } + + setSlot(slotName, slotValue) { + this.#slotValues[slotName] = slotValue; + } + }); + }; + evaluate.mock = (...opts) => { const {value, close} = mock(...opts); mocks.push({close}); |