linkThing.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. import t from 'tap';
  2. import * as html from '#html';
  3. import {testContentFunctions} from '#test-lib';
  4. testContentFunctions(t, 'linkThing (snapshot)', async (t, evaluate) => {
  5. await evaluate.load();
  6. const quickSnapshot = (message, oneOrMultiple) =>
  7. evaluate.snapshot(message,
  8. (Array.isArray(oneOrMultiple)
  9. ? {name: 'linkThing', multiple: oneOrMultiple}
  10. : {name: 'linkThing', ...oneOrMultiple}));
  11. quickSnapshot('basic behavior', {
  12. args: ['localized.track', {
  13. directory: 'foo',
  14. color: '#abcdef',
  15. name: `Cool track!`,
  16. }],
  17. });
  18. quickSnapshot('preferShortName', {
  19. args: ['localized.tag', {
  20. directory: 'five-oceanfalls',
  21. name: 'Five (Oceanfalls)',
  22. nameShort: 'Five',
  23. }],
  24. slots: {preferShortName: true},
  25. });
  26. quickSnapshot('tooltip & content', {
  27. args: ['localized.album', {
  28. directory: 'beyond-canon',
  29. name: 'Beyond Canon',
  30. }],
  31. multiple: [
  32. {slots: {tooltip: false}},
  33. {slots: {tooltip: true}},
  34. {slots: {tooltip: true, content: 'Next'}},
  35. {slots: {tooltip: 'Apple', content: 'Banana'}},
  36. {slots: {content: 'Banana'}},
  37. ],
  38. });
  39. quickSnapshot('color', {
  40. args: ['localized.track', {
  41. directory: 'showtime-piano-refrain',
  42. name: 'Showtime (Piano Refrain)',
  43. color: '#38f43d',
  44. }],
  45. multiple: [
  46. {slots: {color: false}},
  47. {slots: {color: true}},
  48. {slots: {color: '#aaccff'}},
  49. ],
  50. });
  51. quickSnapshot('tags in name escaped', [
  52. {args: ['localized.track', {
  53. directory: 'foo',
  54. name: `<a href="SNOOPING">AS USUAL</a> I SEE`,
  55. }]},
  56. {args: ['localized.track', {
  57. directory: 'bar',
  58. name: `<b>boldface</b>`,
  59. }]},
  60. {args: ['localized.album', {
  61. directory: 'exile',
  62. name: '>Exile<',
  63. }]},
  64. {args: ['localized.track', {
  65. directory: 'heart',
  66. name: '<3',
  67. }]},
  68. ]);
  69. quickSnapshot('nested links in content stripped', {
  70. args: ['localized.staticPage', {directory: 'foo', name: 'Foo'}],
  71. slots: {
  72. content:
  73. html.tag('b', {[html.joinChildren]: ''}, [
  74. html.tag('a', {href: 'bar'}, `Oooo!`),
  75. ` Very spooky.`,
  76. ]),
  77. },
  78. });
  79. });