« get me outta code hell

linkTemplate.js « snapshot « test - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/test/snapshot/linkTemplate.js
blob: 300065e210fdf9f70c1578f0f261cc3cb9a6e5c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import t from 'tap';
import * as html from '#html';
import {testContentFunctions} from '#test-lib';

testContentFunctions(t, 'linkTemplate (snapshot)', async (t, evaluate) => {
  await evaluate.load();

  evaluate.snapshot('fill many slots', {
    name: 'linkTemplate',

    slots: {
      'href': 'https://hsmusic.wiki/media/cool file.pdf',
      'hash': 'fooey',
      'attributes': {class: 'dog', id: 'cat1'},
      'content': 'My Cool Link',
    },
  });

  evaluate.snapshot('fill path slot & provide appendIndexHTML', {
    name: 'linkTemplate',

    extraDependencies: {
      to: (...path) => '/c*lzone/' + path.join('/') + '/',
      appendIndexHTML: true,
    },

    slots: {
      path: ['myCoolPath', 'ham', 'pineapple', 'tomato'],
      content: 'delish',
    },
  });

  evaluate.snapshot('special characters in path argument', {
    name: 'linkTemplate',
    slots: {
      path: [
        'media.albumAdditionalFile',
        'homestuck-vol-1',
        'Showtime (Piano Refrain) - #xXxAwesomeSheetMusick?rxXx#.pdf',
      ],
      content: `Damn, that's some good sheet music`,
    },
  });

  evaluate.snapshot('missing content', {
    name: 'linkTemplate',
    slots: {href: 'banana'},
  });

  evaluate.snapshot('link in content', {
    name: 'linkTemplate',
    slots: {
      hash: 'the-more-ye-know',
      content: [
        `Oh geez oh heck`,
        html.tag('a', {href: 'dogs'}, `There's a link in here!!`),
        `But here's <b>a normal tag.</b>`,
        html.tag('div', `Gotta keep them normal tags.`),
        html.tag('div', `But not... <a href="#">NESTED LINKS, OOO.</a>`),
      ],
    },
  });
});