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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
import t from 'tap';
import {testContentFunctions} from '#test-lib';
testContentFunctions(t, 'linkExternal (snapshot)', async (t, evaluate) => {
await evaluate.load();
evaluate.snapshot('unknown domain (arbitrary world wide web path)', {
name: 'linkExternal',
args: ['https://snoo.ping.as/usual/i/see/'],
});
const urlsToArgs = urls =>
urls.map(url => ({args: [url]}));
const quickSnapshot = (message, urls, slots) =>
evaluate.snapshot(message, {
name: 'linkExternal',
slots,
multiple: urlsToArgs(urls),
});
const quickSnapshotAllStyles = (context, urls) => {
for (const style of ['platform', 'handle']) {
const message = `context: ${context}, style: ${style}`;
quickSnapshot(message, urls, {context, style});
}
};
// Try to comprehensively test every regular expression
// (in `match` and extractions like `handle` or `details`).
// For normal custom-domain matches (e.g. Mastodon),
// it's OK to just test one custom domain in the list.
// Generally match the sorting order in externalLinkSpec,
// so corresponding and missing test cases are easy to locate.
quickSnapshotAllStyles('generic', [
// platform: bandcamp
'https://music.solatrus.com/',
'https://homestuck.bandcamp.com/',
// platform: deviantart
'https://www.deviantart.com/chesswanderlust-sama',
// platform: fandom
'https://mspaintadventures.fandom.com/',
'https://mspaintadventures.fandom.com/wiki/',
'https://mspaintadventures.fandom.com/wiki/Draconian_Dignitary',
'https://community.fandom.com/',
'https://community.fandom.com/wiki/',
'https://community.fandom.com/wiki/Community_Central',
// platform: instagram
'https://www.instagram.com/levc_egm/',
// platform: mastodon
'https://types.pl/',
// platform: newgrounds
'https://buzinkai.newgrounds.com/',
// platform: patreon
'https://www.patreon.com/CecilyRenns',
// platform: poetryFoundation
'https://www.poetryfoundation.org/poets/christina-rossetti',
// platform: soundcloud
'https://soundcloud.com/plazmataz',
// platform: spotify
'https://open.spotify.com/artist/63SNNpNOicDzG3LY82G4q3',
// platform: tumblr
'https://aeritus.tumblr.com/',
// platform: twitter
'https://twitter.com/awkwarddoesart',
// platform: wikipedia
'https://en.wikipedia.org/wiki/Haydn_Quartet_(vocal_ensemble)',
]);
quickSnapshotAllStyles('album', [
'https://youtu.be/abc',
'https://youtube.com/watch?v=abc',
'https://youtube.com/Playlist?list=kweh',
]);
quickSnapshotAllStyles('albumNoTracks', [
'https://youtu.be/abc',
'https://youtube.com/watch?v=abc',
'https://youtube.com/Playlist?list=kweh',
]);
quickSnapshotAllStyles('albumOneTrack', [
'https://youtu.be/abc',
'https://youtube.com/watch?v=abc',
'https://youtube.com/Playlist?list=kweh',
]);
quickSnapshotAllStyles('albumMultipleTracks', [
'https://youtu.be/abc',
'https://youtube.com/watch?v=abc',
'https://youtube.com/Playlist?list=kweh',
]);
quickSnapshotAllStyles('flash', [
'https://www.bgreco.net/hsflash/002238.html',
'https://homestuck.com/story/1234',
'https://homestuck.com/story/pony',
'https://www.youtube.com/watch?v=wKgOp3Kg2wI',
'https://youtu.be/IOcvkkklWmY',
'https://some.external.site/foo/bar/',
]);
});
|