diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-09-23 20:19:12 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-09-23 20:19:12 -0300 |
commit | 61a3fad9cde8fa3809ccf26465f69dd050e6c669 (patch) | |
tree | 5c5c90d452c5aa7c023174bddc1a08f3f0acd75f /test/snapshot | |
parent | 64476074cbc7375afe2388ddd6e9e3275c25f3bd (diff) | |
parent | a53d53e1f95d84b23cffb9a5d43f1a70a412b6fe (diff) |
Merge branch 'preview' into track-data-cleanup
Diffstat (limited to 'test/snapshot')
-rw-r--r-- | test/snapshot/linkThing.js | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/test/snapshot/linkThing.js b/test/snapshot/linkThing.js new file mode 100644 index 00000000..195d8c0e --- /dev/null +++ b/test/snapshot/linkThing.js @@ -0,0 +1,87 @@ +import t from 'tap'; +import * as html from '#html'; +import {testContentFunctions} from '#test-lib'; + +testContentFunctions(t, 'linkThing (snapshot)', async (t, evaluate) => { + await evaluate.load(); + + const quickSnapshot = (message, oneOrMultiple) => + evaluate.snapshot(message, + (Array.isArray(oneOrMultiple) + ? {name: 'linkThing', multiple: oneOrMultiple} + : {name: 'linkThing', ...oneOrMultiple})); + + quickSnapshot('basic behavior', { + args: ['localized.track', { + directory: 'foo', + color: '#abcdef', + name: `Cool track!`, + }], + }); + + quickSnapshot('preferShortName', { + args: ['localized.tag', { + directory: 'five-oceanfalls', + name: 'Five (Oceanfalls)', + nameShort: 'Five', + }], + slots: {preferShortName: true}, + }); + + quickSnapshot('tooltip & content', { + args: ['localized.album', { + directory: 'beyond-canon', + name: 'Beyond Canon', + }], + multiple: [ + {slots: {tooltip: false}}, + {slots: {tooltip: true}}, + {slots: {tooltip: true, content: 'Next'}}, + {slots: {tooltip: 'Apple', content: 'Banana'}}, + {slots: {content: 'Banana'}}, + ], + }); + + quickSnapshot('color', { + args: ['localized.track', { + directory: 'showtime-piano-refrain', + name: 'Showtime (Piano Refrain)', + color: '#38f43d', + }], + multiple: [ + {slots: {color: false}}, + {slots: {color: true}}, + {slots: {color: '#aaccff'}}, + ], + }); + + quickSnapshot('tags in name escaped', [ + {args: ['localized.track', { + directory: 'foo', + name: `<a href="SNOOPING">AS USUAL</a> I SEE`, + }]}, + {args: ['localized.track', { + directory: 'bar', + name: `<b>boldface</b>`, + }]}, + {args: ['localized.album', { + directory: 'exile', + name: '>Exile<', + }]}, + {args: ['localized.track', { + directory: 'heart', + name: '<3', + }]}, + ]); + + quickSnapshot('nested links in content stripped', { + args: ['localized.staticPage', {directory: 'foo', name: 'Foo'}], + slots: { + content: + html.tag('b', {[html.joinChildren]: ''}, [ + html.tag('a', {href: 'bar'}, `Oooo!`), + ` Very spooky.`, + ]), + }, + }); +}); |