linkTemplate.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import t from 'tap';
  2. import * as html from '#html';
  3. import {testContentFunctions} from '#test-lib';
  4. testContentFunctions(t, 'linkTemplate (snapshot)', async (t, evaluate) => {
  5. await evaluate.load();
  6. evaluate.snapshot('fill many slots', {
  7. name: 'linkTemplate',
  8. extraDependencies: {
  9. getColors: c => ({primary: c + 'ff', dim: c + '77'}),
  10. },
  11. slots: {
  12. 'color': '#123456',
  13. 'href': 'https://hsmusic.wiki/media/cool file.pdf',
  14. 'hash': 'fooey',
  15. 'attributes': {class: 'dog', id: 'cat1'},
  16. 'content': 'My Cool Link',
  17. },
  18. });
  19. evaluate.snapshot('fill path slot & provide appendIndexHTML', {
  20. name: 'linkTemplate',
  21. extraDependencies: {
  22. to: (...path) => '/c*lzone/' + path.join('/') + '/',
  23. appendIndexHTML: true,
  24. },
  25. slots: {
  26. path: ['myCoolPath', 'ham', 'pineapple', 'tomato'],
  27. content: 'delish',
  28. },
  29. });
  30. evaluate.snapshot('special characters in path argument', {
  31. name: 'linkTemplate',
  32. slots: {
  33. path: [
  34. 'media.albumAdditionalFile',
  35. 'homestuck-vol-1',
  36. 'Showtime (Piano Refrain) - #xXxAwesomeSheetMusick?rxXx#.pdf',
  37. ],
  38. content: `Damn, that's some good sheet music`,
  39. },
  40. });
  41. evaluate.snapshot('missing content', {
  42. name: 'linkTemplate',
  43. slots: {href: 'banana'},
  44. });
  45. evaluate.snapshot('link in content', {
  46. name: 'linkTemplate',
  47. slots: {
  48. hash: 'the-more-ye-know',
  49. content: [
  50. `Oh geez oh heck`,
  51. html.tag('a', {href: 'dogs'}, `There's a link in here!!`),
  52. `But here's <b>a normal tag.</b>`,
  53. html.tag('div', `Gotta keep them normal tags.`),
  54. html.tag('div', `But not... <a href="#">NESTED LINKS, OOO.</a>`),
  55. ],
  56. },
  57. });
  58. });