linkThing.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. nameShort: 'BC',
  31. }],
  32. multiple: [
  33. {slots: {tooltipStyle: 'none'}},
  34. {slots: {tooltipStyle: 'browser'}},
  35. {slots: {tooltipStyle: 'browser', content: 'Next'}},
  36. {slots: {tooltipStyle: 'auto'}},
  37. {slots: {tooltipStyle: 'auto', preferShortName: true}},
  38. {slots: {tooltipStyle: 'auto', preferShortName: true, content: 'Next'}},
  39. {slots: {tooltipStyle: 'auto', content: 'Next'}},
  40. {slots: {tooltipStyle: 'wiki'}},
  41. {slots: {tooltipStyle: 'wiki', content: 'Next'}},
  42. {slots: {content: 'Banana'}},
  43. ],
  44. });
  45. quickSnapshot('color', {
  46. args: ['localized.track', {
  47. directory: 'showtime-piano-refrain',
  48. name: 'Showtime (Piano Refrain)',
  49. color: '#38f43d',
  50. }],
  51. multiple: [
  52. {slots: {color: false}},
  53. {slots: {color: true}},
  54. {slots: {color: '#aaccff'}},
  55. {slots: {color: '#aaccff', tooltipStyle: 'wiki'}},
  56. ],
  57. });
  58. quickSnapshot('tags in name escaped', [
  59. {args: ['localized.track', {
  60. directory: 'foo',
  61. name: `<a href="SNOOPING">AS USUAL</a> I SEE`,
  62. }]},
  63. {args: ['localized.track', {
  64. directory: 'bar',
  65. name: `<b>boldface</b>`,
  66. }]},
  67. {args: ['localized.album', {
  68. directory: 'exile',
  69. name: '>Exile<',
  70. }]},
  71. {args: ['localized.track', {
  72. directory: 'heart',
  73. name: '<3',
  74. }]},
  75. ]);
  76. quickSnapshot('nested links in content stripped', {
  77. args: ['localized.staticPage', {directory: 'foo', name: 'Foo'}],
  78. slots: {
  79. content:
  80. html.tag('b', {[html.joinChildren]: ''}, [
  81. html.tag('a', {href: 'bar'}, `Oooo!`),
  82. ` Very spooky.`,
  83. ]),
  84. },
  85. });
  86. });