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
64
65
66
67
68
|
import t from 'tap';
import {testContentFunctions} from '../lib/content-function.js';
testContentFunctions(t, 'transformContent (snapshot)', async (t, evaluate) => {
await evaluate.load();
const extraDependencies = {
wikiData: {
albumData: [
{directory: 'cool-album', name: 'Cool Album', color: '#123456'},
],
},
getSizeOfImageFile: () => 0,
to: (key, ...args) => `to-${key}/${args.join('/')}`,
};
const quickSnapshot = (message, content, slots) =>
evaluate.snapshot(message, {
name: 'transformContent',
args: [content],
extraDependencies,
slots,
});
// TODO: Snapshots for different transformContent modes
quickSnapshot(
'two text paragraphs',
`Hello, world!\n` +
`Wow, this is very cool.`);
quickSnapshot(
'links to a thing',
`This is [[album:cool-album|my favorite album]].\n` +
`That's right, [[album:cool-album]]!`);
quickSnapshot(
'inline images',
`<img src="snooping.png"> as USUAL...\n` +
`What do you know? <img src="cowabunga.png" width="24" height="32">\n` +
`[[album:cool-album|I'm on the left.]]<img src="im-on-the-right.jpg">\n` +
`<img src="im-on-the-left.jpg">[[album:cool-album|I'm on the right.]]\n` +
`Media time! <img src="media/misc/interesting.png"> Oh yeah!\n` +
`<img src="must.png"><img src="stick.png"><img src="together.png">\n` +
`And... all done! <img src="end-of-source.png">`);
quickSnapshot(
'non-inline image #1',
`<img src="spark.png">`);
quickSnapshot(
'non-inline image #2',
`Rad.\n<img src="spark.png">`);
quickSnapshot(
'non-inline image #3',
`<img src="spark.png">\nBaller.`);
quickSnapshot(
'dates',
`[[date:2023-04-13]] Yep!\nVery nice: [[date:25 October 2413]]`);
quickSnapshot(
'super basic string',
`Neat listing: [[string:listingPage.listAlbums.byDate.title]]`);
});
|