From aa69e214f604d895abc0cb88675f9b907b2f83a6 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Wed, 2 Aug 2023 12:37:30 -0300 Subject: content, test: generatePreviousNextLinks: disable ID, fix null slots * New slot to disable id attribute, so component is more versatile * Fixes including false in return array for null previous/next slots --- test/snapshot/generatePreviousNextLinks.js | 36 ++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 test/snapshot/generatePreviousNextLinks.js (limited to 'test/snapshot') diff --git a/test/snapshot/generatePreviousNextLinks.js b/test/snapshot/generatePreviousNextLinks.js new file mode 100644 index 00000000..d0b61078 --- /dev/null +++ b/test/snapshot/generatePreviousNextLinks.js @@ -0,0 +1,36 @@ +import t from 'tap'; +import {testContentFunctions} from '../lib/content-function.js'; + +import * as html from '../../src/util/html.js'; + +testContentFunctions(t, 'generatePreviousNextLinks (snapshot)', async (t, evaluate) => { + await evaluate.load(); + + const quickSnapshot = (message, slots) => + evaluate.snapshot(message, { + name: 'generatePreviousNextLinks', + slots, + postprocess: template => template.content.join('\n'), + }); + + quickSnapshot('basic behavior', { + previousLink: evaluate.stubTemplate('previous'), + nextLink: evaluate.stubTemplate('next'), + }); + + quickSnapshot('previous missing', { + nextLink: evaluate.stubTemplate('next'), + }); + + quickSnapshot('next missing', { + previousLink: evaluate.stubTemplate('previous'), + }); + + quickSnapshot('neither link present', {}); + + quickSnapshot('disable id', { + previousLink: evaluate.stubTemplate('previous'), + nextLink: evaluate.stubTemplate('next'), + id: false, + }); +}); -- cgit 1.3.0-6-gf8a5