From 9928fcbcff7cfa1aa6ec1f8437f43485e1245f21 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 4 Apr 2023 13:51:52 -0300 Subject: test: use postprocess option in snapshots --- tap-snapshots/test/snapshot/linkTemplate.js.test.cjs | 2 +- test/lib/content-function.js | 6 +----- test/snapshot/linkArtist.js | 5 ++++- test/snapshot/linkTemplate.js | 18 +++++++++++------- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/tap-snapshots/test/snapshot/linkTemplate.js.test.cjs b/tap-snapshots/test/snapshot/linkTemplate.js.test.cjs index 9063eace..3c4acb57 100644 --- a/tap-snapshots/test/snapshot/linkTemplate.js.test.cjs +++ b/tap-snapshots/test/snapshot/linkTemplate.js.test.cjs @@ -9,6 +9,6 @@ exports[`test/snapshot/linkTemplate.js TAP linkTemplate (snapshot) > fill many s My Cool Link ` -exports[`test/snapshot/linkTemplate.js TAP linkTemplate (snapshot) > fill path slot 1`] = ` +exports[`test/snapshot/linkTemplate.js TAP linkTemplate (snapshot) > fill path slot & provide appendIndexHTML 1`] = ` ` diff --git a/test/lib/content-function.js b/test/lib/content-function.js index b6177e46..692d5109 100644 --- a/test/lib/content-function.js +++ b/test/lib/content-function.js @@ -70,17 +70,13 @@ export function testContentFunctions(t, message, fn) { throw new Error(`Await .load() before performing tests`); } - const [description, opts, fn] = + const [description, opts] = (typeof args[0] === 'string' ? args : ['output', ...args]); let result = evaluate(opts); - if (fn) { - result = fn(result); - } - if (opts.multiple) { result = result.map(item => item.toString()).join('\n'); } else { diff --git a/test/snapshot/linkArtist.js b/test/snapshot/linkArtist.js index e479ece0..0451f1c5 100644 --- a/test/snapshot/linkArtist.js +++ b/test/snapshot/linkArtist.js @@ -23,5 +23,8 @@ testContentFunctions(t, 'linkArtist (snapshot)', async (t, evaluate) => { directory: '55gore', }, ], - }, v => v.slot('preferShortName', true)); + + postprocess: v => v + .slot('preferShortName', true), + }); }); diff --git a/test/snapshot/linkTemplate.js b/test/snapshot/linkTemplate.js index 07c3b501..e9a1ccd6 100644 --- a/test/snapshot/linkTemplate.js +++ b/test/snapshot/linkTemplate.js @@ -6,24 +6,28 @@ testContentFunctions(t, 'linkTemplate (snapshot)', async (t, evaluate) => { evaluate.snapshot('fill many slots', { name: 'linkTemplate', + extraDependencies: { getColors: c => ({primary: c + 'ff', dim: c + '77'}), }, - }, - v => v + + postprocess: v => v .slot('color', '#123456') .slot('href', 'https://hsmusic.wiki/media/cool file.pdf') .slot('hash', 'fooey') .slot('attributes', {class: 'dog', id: 'cat1'}) - .slot('content', 'My Cool Link')); + .slot('content', 'My Cool Link'), + }); - evaluate.snapshot('fill path slot', { + evaluate.snapshot('fill path slot & provide appendIndexHTML', { name: 'linkTemplate', + extraDependencies: { to: (...path) => '/c*lzone/' + path.join('/') + '/', appendIndexHTML: true, }, - }, - v => v - .slot('path', ['myCoolPath', 'ham', 'pineapple', 'tomato'])); + + postprocess: v => v + .slot('path', ['myCoolPath', 'ham', 'pineapple', 'tomato']), + }); }); -- cgit 1.3.0-6-gf8a5