linkTemplate.js 1.6 KB

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