From 2ce5ddd844603b1c3d8f220a12603677104b7545 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 13 Jun 2023 12:37:18 -0300 Subject: test: use "native" slots shorthand instead of postprocess --- test/snapshot/generateAdditionalFilesList.js | 11 ++-- test/snapshot/image.js | 83 +++++++++++++++------------- test/snapshot/linkArtist.js | 6 +- test/snapshot/linkExternal.js | 13 +++-- test/snapshot/linkTemplate.js | 18 +++--- 5 files changed, 72 insertions(+), 59 deletions(-) (limited to 'test') diff --git a/test/snapshot/generateAdditionalFilesList.js b/test/snapshot/generateAdditionalFilesList.js index 0c27ad19..60b46ae8 100644 --- a/test/snapshot/generateAdditionalFilesList.js +++ b/test/snapshot/generateAdditionalFilesList.js @@ -41,16 +41,16 @@ testContentFunctions(t, 'generateAdditionalFilesList (snapshot)', async (t, eval }, ], ], - postprocess: template => template - .slot('fileLinks', { + slots: { + fileLinks: { 'sburbwp_1280x1024.jpg': 'link to 1280x1024', 'sburbwp_1440x900.jpg': 'link to 1440x900', 'sburbwp_1920x1080.jpg': null, 'Homestuck_Vol4_alt1.jpg': 'link to alt1', 'Homestuck_Vol4_alt2.jpg': null, 'Homestuck_Vol4_alt3.jpg': 'link to alt3', - }) - .slot('fileSizes', { + }, + fileSizes: { 'sburbwp_1280x1024.jpg': 2500, 'sburbwp_1440x900.jpg': null, 'sburbwp_1920x1080.jpg': null, @@ -58,6 +58,7 @@ testContentFunctions(t, 'generateAdditionalFilesList (snapshot)', async (t, eval 'Homestuck_Vol4_alt1.jpg': 1234567, 'Homestuck_Vol4_alt2.jpg': 1234567, 'Homestuck_Vol4_alt3.jpg': 1234567, - }), + } + }, }); }); diff --git a/test/snapshot/image.js b/test/snapshot/image.js index eeffb849..62e1cd9a 100644 --- a/test/snapshot/image.js +++ b/test/snapshot/image.js @@ -14,68 +14,77 @@ testContentFunctions(t, 'image (snapshot)', async (t, evaluate) => { }); quickSnapshot('source via path', { - postprocess: template => template - .slot('path', ['media.albumCover', 'beyond-canon', 'png']), + slots: { + path: ['media.albumCover', 'beyond-canon', 'png'], + }, }); quickSnapshot('source via src', { - postprocess: template => template - .slot('src', 'https://example.com/bananas.gif'), + slots: { + src: 'https://example.com/bananas.gif', + }, }); quickSnapshot('source missing', { - postprocess: template => template - .slot('missingSourceContent', 'Example of missing source message.'), + slots: { + missingSourceContent: 'Example of missing source message.', + }, }); quickSnapshot('id without link', { - postprocess: template => template - .slot('src', 'foobar') - .slot('id', 'banana'), + slots: { + src: 'foobar', + id: 'banana', + }, }); quickSnapshot('id with link', { - postprocess: template => template - .slot('src', 'foobar') - .slot('link', true) - .slot('id', 'banana'), + slots: { + src: 'foobar', + link: true, + id: 'banana', + }, }); quickSnapshot('id with square', { - postprocess: template => template - .slot('src', 'foobar') - .slot('square', true) - .slot('id', 'banana'), - }) + slots: { + src: 'foobar', + square: true, + id: 'banana', + }, + }); quickSnapshot('width & height', { - postprocess: template => template - .slot('src', 'foobar') - .slot('width', 600) - .slot('height', 400), + slots: { + src: 'foobar', + width: 600, + height: 400, + }, }); quickSnapshot('square', { - postprocess: template => template - .slot('src', 'foobar') - .slot('square', true), + slots: { + src: 'foobar', + square: true, + }, }); quickSnapshot('lazy with square', { - postprocess: template => template - .slot('src', 'foobar') - .slot('lazy', true) - .slot('square', true), + slots: { + src: 'foobar', + lazy: true, + square: true, + }, }); quickSnapshot('link with file size', { extraDependencies: { getSizeOfImageFile: () => 10 ** 6, }, - - postprocess: template => template - .slot('path', ['media.albumCover', 'pingas', 'png']) - .slot('link', true), + slots: { + path: ['media.albumCover', 'pingas', 'png'], + link: true, + }, }); quickSnapshot('content warnings via tags', { @@ -85,8 +94,8 @@ testContentFunctions(t, 'image (snapshot)', async (t, evaluate) => { {name: 'too cool for school', isContentWarning: true}, ], ], - - postprocess: template => template - .slot('path', ['media.albumCover', 'beyond-canon', 'png']), - }) + slots: { + path: ['media.albumCover', 'beyond-canon', 'png'], + }, + }); }); diff --git a/test/snapshot/linkArtist.js b/test/snapshot/linkArtist.js index 0451f1c5..684affc3 100644 --- a/test/snapshot/linkArtist.js +++ b/test/snapshot/linkArtist.js @@ -23,8 +23,8 @@ testContentFunctions(t, 'linkArtist (snapshot)', async (t, evaluate) => { directory: '55gore', }, ], - - postprocess: v => v - .slot('preferShortName', true), + slots: { + preferShortName: true, + }, }); }); diff --git a/test/snapshot/linkExternal.js b/test/snapshot/linkExternal.js index a65044df..391d5a10 100644 --- a/test/snapshot/linkExternal.js +++ b/test/snapshot/linkExternal.js @@ -31,15 +31,16 @@ testContentFunctions(t, 'linkExternal (snapshot)', async (t, evaluate) => { ], }); - evaluate.snapshot('custom matches - type: album', { + evaluate.snapshot('custom matches - album', { name: 'linkExternal', multiple: [ - {args: ['https://youtu.be/abc', {type: 'album'}]}, - {args: ['https://youtube.com/watch?v=abc', {type: 'album'}]}, - {args: ['https://youtube.com/Playlist?list=kweh', {type: 'album'}]}, + {args: ['https://youtu.be/abc']}, + {args: ['https://youtube.com/watch?v=abc']}, + {args: ['https://youtube.com/Playlist?list=kweh']}, ], - postprocess: - link => link.slot('mode', 'album'), + slots: { + mode: 'album', + }, }); evaluate.snapshot('custom domains for common platforms', { diff --git a/test/snapshot/linkTemplate.js b/test/snapshot/linkTemplate.js index e9a1ccd6..bef0935c 100644 --- a/test/snapshot/linkTemplate.js +++ b/test/snapshot/linkTemplate.js @@ -11,12 +11,13 @@ testContentFunctions(t, 'linkTemplate (snapshot)', async (t, evaluate) => { getColors: c => ({primary: c + 'ff', dim: c + '77'}), }, - 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'), + slots: { + 'color': '#123456', + 'href': 'https://hsmusic.wiki/media/cool file.pdf', + 'hash': 'fooey', + 'attributes': {class: 'dog', id: 'cat1'}, + 'content': 'My Cool Link', + }, }); evaluate.snapshot('fill path slot & provide appendIndexHTML', { @@ -27,7 +28,8 @@ testContentFunctions(t, 'linkTemplate (snapshot)', async (t, evaluate) => { appendIndexHTML: true, }, - postprocess: v => v - .slot('path', ['myCoolPath', 'ham', 'pineapple', 'tomato']), + slots: { + path: ['myCoolPath', 'ham', 'pineapple', 'tomato'], + }, }); }); -- cgit 1.3.0-6-gf8a5