From 8bc0bd0205983fea97803a9993225b42830544c8 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 30 Jul 2023 20:13:20 -0300 Subject: test: transformContent (snapshot) for image processing --- test/snapshot/transformContent.js | 60 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 test/snapshot/transformContent.js (limited to 'test') diff --git a/test/snapshot/transformContent.js b/test/snapshot/transformContent.js new file mode 100644 index 00000000..f55ca4fa --- /dev/null +++ b/test/snapshot/transformContent.js @@ -0,0 +1,60 @@ +import t from 'tap'; +import {testContentFunctions} from '../lib/content-function.js'; + +testContentFunctions(t, 'transformContent (snapshot)', async (t, evaluate) => { + await evaluate.load(); + + const extraDependencies = { + wikiData: { + albumData: [ + {directory: 'cool-album', name: 'Cool Album', color: '#123456'}, + ], + }, + + getSizeOfImageFile: () => 0, + + to: (key, ...args) => `to-${key}/${args.join('/')}`, + }; + + const quickSnapshot = (message, content, slots) => + evaluate.snapshot(message, { + name: 'transformContent', + args: [content], + extraDependencies, + slots, + }); + + // TODO: Snapshots for different transformContent modes + + quickSnapshot( + 'two text paragraphs', + `Hello, world!\n` + + `Wow, this is very cool.`); + + quickSnapshot( + 'links to a thing', + `This is [[album:cool-album|my favorite album]].\n` + + `That's right, [[album:cool-album]]!`); + + quickSnapshot( + 'inline images', + ` as USUAL...\n` + + `What do you know? \n` + + `[[album:cool-album|I'm on the left.]]\n` + + `[[album:cool-album|I'm on the right.]]\n` + + `Media time! Oh yeah!\n` + + `\n` + + `And... all done! `); + + quickSnapshot( + 'non-inline image #1', + ``); + + quickSnapshot( + 'non-inline image #2', + `Rad.\n`); + + quickSnapshot( + 'non-inline image #3', + `\nBaller.`); +}); -- cgit 1.3.0-6-gf8a5