diff options
Diffstat (limited to 'test/snapshots')
-rw-r--r-- | test/snapshots/_support.js | 55 | ||||
-rw-r--r-- | test/snapshots/linkArtist.js | 26 | ||||
-rw-r--r-- | test/snapshots/linkTemplate.js | 28 |
3 files changed, 0 insertions, 109 deletions
diff --git a/test/snapshots/_support.js b/test/snapshots/_support.js deleted file mode 100644 index b51f2847..00000000 --- a/test/snapshots/_support.js +++ /dev/null @@ -1,55 +0,0 @@ -import {quickEvaluate} from '../../src/content-function.js'; -import {quickLoadContentDependencies} from '../../src/content/dependencies/index.js'; - -import chroma from 'chroma-js'; -import * as html from '../../src/util/html.js'; -import urlSpec from '../../src/url-spec.js'; -import {getColors} from '../../src/util/colors.js'; -import {generateURLs} from '../../src/util/urls.js'; - -export function testContentFunctions(t, message, fn) { - const urls = generateURLs(urlSpec); - - t.test(message, async t => { - const loadedContentDependencies = await quickLoadContentDependencies(); - - const evaluate = ({ - from = 'localized.home', - contentDependencies = {}, - extraDependencies = {}, - ...opts - }) => { - const {to} = urls.from(from); - - try { - return quickEvaluate({ - ...opts, - contentDependencies: { - ...contentDependencies, - ...loadedContentDependencies, - }, - extraDependencies: { - html, - to, - urls, - appendIndexHTML: false, - getColors: c => getColors(c, {chroma}), - ...extraDependencies, - }, - }); - } catch (error) { - if (error instanceof AggregateError) { - error = new Error(`AggregateError: ${error.message}\n${error.errors.map(err => `** ${err}`).join('\n')}`); - } - throw error; - } - }; - - evaluate.snapshot = (opts, fn) => { - const result = (fn ? fn(evaluate(opts)) : evaluate(opts)); - t.matchSnapshot(result.toString(), 'output'); - }; - - return fn(t, evaluate); - }); -} diff --git a/test/snapshots/linkArtist.js b/test/snapshots/linkArtist.js deleted file mode 100644 index 43fee88e..00000000 --- a/test/snapshots/linkArtist.js +++ /dev/null @@ -1,26 +0,0 @@ -import t from 'tap'; - -import {testContentFunctions} from './_support.js'; - -testContentFunctions(t, 'linkArtist', (t, evaluate) => { - evaluate.snapshot({ - name: 'linkArtist', - args: [ - { - name: `Toby Fox`, - directory: `toby-fox`, - } - ], - }); - - evaluate.snapshot({ - name: 'linkArtist', - args: [ - { - name: 'ICCTTCMDMIROTMCWMWFTPFTDDOTARHPOESWGBTWEATFCWSEBTSSFOFG', - nameShort: '55gore', - directory: '55gore', - }, - ], - }, v => v.slot('preferShortName', true)); -}); diff --git a/test/snapshots/linkTemplate.js b/test/snapshots/linkTemplate.js deleted file mode 100644 index 0dcf5b61..00000000 --- a/test/snapshots/linkTemplate.js +++ /dev/null @@ -1,28 +0,0 @@ -import t from 'tap'; - -import {testContentFunctions} from './_support.js'; - -testContentFunctions(t, 'linkTemplate', (t, evaluate) => { - evaluate.snapshot({ - name: 'linkTemplate', - extraDependencies: { - getColors: c => ({primary: c + 'ff', dim: c + '77'}), - }, - }, - 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')); - - evaluate.snapshot({ - name: 'linkTemplate', - extraDependencies: { - to: (...path) => '/c*lzone/' + path.join('/') + '/', - appendIndexHTML: true, - }, - }, - v => v - .slot('path', ['myCoolPath', 'ham', 'pineapple', 'tomato'])); -}); |