« get me outta code hell

withParsedCommentaryEntries.js « wiki-data « composite « data « unit « test - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/test/unit/data/composite/wiki-data/withParsedCommentaryEntries.js
blob: 411fd11de2fc439c4b3e705654ca0eab78952e6b (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
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
import t from 'tap';

import {compositeFrom, input} from '#composite';
import thingConstructors from '#things';

import {exposeDependency} from '#composite/control-flow';
import {withParsedCommentaryEntries} from '#composite/wiki-data';

const {Artist} = thingConstructors;

const composite = compositeFrom({
  compose: false,

  steps: [
    withParsedCommentaryEntries({
      from: 'from',
    }),

    exposeDependency({dependency: '#parsedCommentaryEntries'}),
  ],
});

function stubArtist(artistName = `Test Artist`) {
  const artist = new Artist();
  artist.name = artistName;

  return artist;
}

t.test(`withParsedCommentaryEntries: basic behavior`, t => {
  t.plan(7);

  const artist1 = stubArtist(`Mobius Trip`);
  const artist2 = stubArtist(`Hadron Kaleido`);
  const artist3 = stubArtist('Homestuck');

  const artistData = [artist1, artist2, artist3];

  t.match(composite, {
    expose: {
      dependencies: ['from', 'artistData'],
    },
  });

  t.same(composite.expose.compute({
    artistData,
    from:
      `<i>Mobius Trip:</i>\n` +
      `Some commentary.\n` +
      `Very cool.\n`,
  }), [
    {
      artists: [artist1],
      artistDisplayText: null,
      annotation: null,
      date: null,
      accessDate: null,
      accessKind: null,
      secondDate: null,
      dateKind: null,
      body: `Some commentary.\nVery cool.`,
    },
  ]);

  t.same(composite.expose.compute({
    artistData,
    from:
      `<i>Mobius Trip|Moo-bius Trip:</i> (music, art, 12 January 2015)\n` +
      `First commentary entry.\n` +
      `Very cool.\n` +
      `<i>Hadron Kaleido|<b>[[artist:hadron-kaleido|The Ol' Hadron]]</b>:</i> (moral support, 4/4/2022)\n` +
      `Second commentary entry. Yes. So cool.\n` +
      `<i>Mystery Artist:</i> (pingas, August 25, 2023)\n` +
      `Oh no.. Oh dear...\n` +
      `<i>Mobius Trip, Hadron Kaleido:</i>\n` +
      `And back around we go.`,
  }), [
    {
      artists: [artist1],
      artistDisplayText: `Moo-bius Trip`,
      annotation: `music, art`,
      date: new Date('12 January 2015'),
      body: `First commentary entry.\nVery cool.`,
      secondDate: null,
      dateKind: null,
      accessDate: null,
      accessKind: null,
    },
    {
      artists: [artist2],
      artistDisplayText: `<b>[[artist:hadron-kaleido|The Ol' Hadron]]</b>`,
      annotation: `moral support`,
      date: new Date('4 April 2022'),
      body: `Second commentary entry. Yes. So cool.`,
      secondDate: null,
      dateKind: null,
      accessDate: null,
      accessKind: null,
    },
    {
      artists: [],
      artistDisplayText: null,
      annotation: `pingas`,
      date: new Date('25 August 2023'),
      body: `Oh no.. Oh dear...`,
      secondDate: null,
      dateKind: null,
      accessDate: null,
      accessKind: null,
    },
    {
      artists: [artist1, artist2],
      artistDisplayText: null,
      annotation: null,
      date: null,
      body: `And back around we go.`,
      secondDate: null,
      dateKind: null,
      accessDate: null,
      accessKind: null,
    },
  ]);

  t.same(composite.expose.compute({
    artistData,
    from:
      `<i>Homestuck:</i> ([Bandcamp credits blurb](https://web.archive.org/web/20201024170202/https://homestuck.bandcamp.com/track/sburban-countdown-3) on "Homestuck Vol. 1-4 (with Midnight Crew: Drawing Dead)", 10/25/2019)\n` +
      `\n` +
      `Written by [[artist:michael-guy-bowman|Michael Guy Bowman]]<br>\n` +
      `Arrangement by [[artist:mark-j-hadley|Mark Hadley]]\n` +
      `\n` +
      `<i>Homestuck:</i> ([fake](https://web.archive.org/web/20201024170202/https://homestuck.bandcamp.com/fake), 7/20/2019 captured 4/13/2024)\n` +
      `This isn't real!\n` +
      `\n` +
      `<i>Homestuck:</i> ([fake](https://homestuck.com/fake), 10/25/2011 accessed 10/27/2011)\n` +
      `This isn't real either!\n` +
      `\n` +
      `<i>Homestuck:</i> ([fake](https://web.archive.org/web/20201024170202/https://homestuck.bandcamp.com/fake), 7/20/2019 accessed 4/13/2024)\n` +
      `Not this one, neither!\n`
  }), [
    {
      artists: [artist3],
      artistDisplayText: null,
      annotation: `[Bandcamp credits blurb](https://web.archive.org/web/20201024170202/https://homestuck.bandcamp.com/track/sburban-countdown-3) on "Homestuck Vol. 1-4 (with Midnight Crew: Drawing Dead)"`,
      date: new Date('10/25/2019'),
      body:
        `Written by [[artist:michael-guy-bowman|Michael Guy Bowman]]<br>\n` +
        `Arrangement by [[artist:mark-j-hadley|Mark Hadley]]`,
      secondDate: null,
      dateKind: null,
      accessDate: new Date('10/24/2020'),
      accessKind: 'captured',
    },
    {
      artists: [artist3],
      artistDisplayText: null,
      annotation: `[fake](https://web.archive.org/web/20201024170202/https://homestuck.bandcamp.com/fake)`,
      date: new Date('7/20/2019'),
      body: `This isn't real!`,
      secondDate: null,
      dateKind: null,
      accessDate: new Date('4/13/2024'),
      accessKind: 'captured',
    },
    {
      artists: [artist3],
      artistDisplayText: null,
      annotation: `[fake](https://homestuck.com/fake)`,
      date: new Date('10/25/2011'),
      body: `This isn't real either!`,
      secondDate: null,
      dateKind: null,
      accessDate: new Date('10/27/2011'),
      accessKind: 'accessed',
    },
    {
      artists: [artist3],
      artistDisplayText: null,
      annotation: `[fake](https://web.archive.org/web/20201024170202/https://homestuck.bandcamp.com/fake)`,
      date: new Date('7/20/2019'),
      body: `Not this one, neither!`,
      secondDate: null,
      dateKind: null,
      accessDate: new Date('4/13/2024'),
      accessKind: 'accessed',
    },
  ]);

  t.same(composite.expose.compute({
    artistData,
    from:
      `<i>Homestuck:</i> ([MSPA sound credits](https://web.archive.org/web/20120805031705/http://www.mspaintadventures.com:80/soundcredits.html), sometime 6/21/2012 - 8/5/2012)\n` +
      `\n` +
      `[[flash:246|Page 2146]] - <b>"Sburban Countdown"</b><br>\n` +
      `Available on Bandcamp in [[album:homestuck-vol-1-4|Homestuck Vol. 1-4]]<br>\n` +
      `Written by [[artist:michael-guy-bowman|Michael Guy Bowman]]<br>\n` +
      `Arrangement by [[artist:mark-j-hadley|Mark Hadley]]\n` +
      `\n` +
      `<i>Homestuck:</i> ([fake](https://web.archive.org/web/20201024170202/https://homestuck.bandcamp.com/fake), 7/20/2019 - 7/20/2022 captured 4/13/2024)\n` +
      `It's goin' once.\n` +
      `\n` +
      `<i>Homestuck:</i> (10/25/2011 - 10/28/2011 accessed 10/27/2011)\n` +
      `It's goin' twice.\n` +
      `\n` +
      `<i>Homestuck:</i> ([fake](https://web.archive.org/web/20201024170202/https://homestuck.bandcamp.com/fake), 7/20/2019 - 7/20/2022 accessed 4/13/2024)\n` +
      `It's goin' thrice!\n`
  }), [
    {
      artists: [artist3],
      artistDisplayText: null,
      annotation: `[MSPA sound credits](https://web.archive.org/web/20120805031705/http://www.mspaintadventures.com:80/soundcredits.html)`,
      body:
        `[[flash:246|Page 2146]] - <b>"Sburban Countdown"</b><br>\n` +
        `Available on Bandcamp in [[album:homestuck-vol-1-4|Homestuck Vol. 1-4]]<br>\n` +
        `Written by [[artist:michael-guy-bowman|Michael Guy Bowman]]<br>\n` +
        `Arrangement by [[artist:mark-j-hadley|Mark Hadley]]`,
      date: new Date('6/21/2012'),
      secondDate: new Date('8/5/2012'),
      dateKind: 'sometime',
      accessDate: new Date('8/5/2012'),
      accessKind: 'captured',
    },
    {
      artists: [artist3],
      artistDisplayText: null,
      annotation: `[fake](https://web.archive.org/web/20201024170202/https://homestuck.bandcamp.com/fake)`,
      body: `It's goin' once.`,
      date: new Date('7/20/2019'),
      secondDate: new Date('7/20/2022'),
      dateKind: null,
      accessDate: new Date('4/13/2024'),
      accessKind: 'captured',
    },
    {
      artists: [artist3],
      artistDisplayText: null,
      annotation: '', // TODO: This should be null, but the regex isn't structured for that, at the moment.
      body: `It's goin' twice.`,
      date: new Date('10/25/2011'),
      secondDate: new Date('10/28/2011'),
      dateKind: null,
      accessDate: new Date('10/27/2011'),
      accessKind: 'accessed',

    },
    {
      artists: [artist3],
      artistDisplayText: null,
      annotation: `[fake](https://web.archive.org/web/20201024170202/https://homestuck.bandcamp.com/fake)`,
      body: `It's goin' thrice!`,
      date: new Date('7/20/2019'),
      secondDate: new Date('7/20/2022'),
      dateKind: null,
      accessDate: new Date('4/13/2024'),
      accessKind: 'accessed',
    },
  ]);

  t.same(composite.expose.compute({
    artistData,
    from:
      `<i>Homestuck:</i> ([MSPA sound credits](https://web.archive.org/web/20120805031705/http://www.mspaintadventures.com:80/soundcredits.html), sometime 6/21/2012 - 8/5/2012)\n` +
      `\n` +
      `[[flash:246|Page 2146]] - <b>"Sburban Countdown"</b><br>\n` +
      `Available on Bandcamp in [[album:homestuck-vol-1-4|Homestuck Vol. 1-4]]<br>\n` +
      `Written by [[artist:michael-guy-bowman|Michael Guy Bowman]]<br>\n` +
      `Arrangement by [[artist:mark-j-hadley|Mark Hadley]]\n` +
      `\n` +
      `<i>Homestuck:</i> ([fake](https://web.archive.org/web/20201024170202/https://homestuck.bandcamp.com/fake), 7/20/2019 - 7/20/2022 captured 4/13/2024)\n` +
      `It's goin' once.\n` +
      `\n` +
      `<i>Homestuck:</i> (10/25/2011 - 10/28/2011 accessed 10/27/2011)\n` +
      `It's goin' twice.\n` +
      `\n` +
      `<i>Homestuck:</i> ([fake](https://web.archive.org/web/20201024170202/https://homestuck.bandcamp.com/fake), 7/20/2019 - 7/20/2022 accessed 4/13/2024)\n` +
      `It's goin' thrice!\n`
  }), [
    {
      artists: [artist3],
      artistDisplayText: null,
      annotation: `[MSPA sound credits](https://web.archive.org/web/20120805031705/http://www.mspaintadventures.com:80/soundcredits.html)`,
      body:
        `[[flash:246|Page 2146]] - <b>"Sburban Countdown"</b><br>\n` +
        `Available on Bandcamp in [[album:homestuck-vol-1-4|Homestuck Vol. 1-4]]<br>\n` +
        `Written by [[artist:michael-guy-bowman|Michael Guy Bowman]]<br>\n` +
        `Arrangement by [[artist:mark-j-hadley|Mark Hadley]]`,
      date: new Date('6/21/2012'),
      secondDate: new Date('8/5/2012'),
      dateKind: 'sometime',
      accessDate: new Date('8/5/2012'),
      accessKind: 'captured',
    },
    {
      artists: [artist3],
      artistDisplayText: null,
      annotation: `[fake](https://web.archive.org/web/20201024170202/https://homestuck.bandcamp.com/fake)`,
      body: `It's goin' once.`,
      date: new Date('7/20/2019'),
      secondDate: new Date('7/20/2022'),
      dateKind: null,
      accessDate: new Date('4/13/2024'),
      accessKind: 'captured',
    },
    {
      artists: [artist3],
      artistDisplayText: null,
      annotation: '', // TODO: This should be null, but the regex isn't structured for that, at the moment.
      body: `It's goin' twice.`,
      date: new Date('10/25/2011'),
      secondDate: new Date('10/28/2011'),
      dateKind: null,
      accessDate: new Date('10/27/2011'),
      accessKind: 'accessed',

    },
    {
      artists: [artist3],
      artistDisplayText: null,
      annotation: `[fake](https://web.archive.org/web/20201024170202/https://homestuck.bandcamp.com/fake)`,
      body: `It's goin' thrice!`,
      date: new Date('7/20/2019'),
      secondDate: new Date('7/20/2022'),
      dateKind: null,
      accessDate: new Date('4/13/2024'),
      accessKind: 'accessed',
    },
  ]);

  t.same(composite.expose.compute({
    artistData,
    from:
      `<i>Homestuck:</i> ([Homestuck sound credits](https://web.archive.org/web/20180717171235/https://www.homestuck.com/credits/sound), excerpt, around 4/3/2018)\n` +
      `blablabla\n` +
      `<i>Homestuck:</i> ([fake](https://web.archive.org/web/20201024170202/https://homestuck.bandcamp.com/fake), around 7/20/2019 - 7/20/2022 captured 4/13/2024)\n` +
      `Snoopin', snoopin', snoo,\n` +
      `<i>Homestuck:</i> ([fake](https://web.archive.org/web/20201024170202/https://homestuck.bandcamp.com/fake), throughout 7/20/2019 - 7/20/2022 accessed 4/13/2024)\n` +
      `~ pingas ~\n`
  }), [
    {
      artists: [artist3],
      artistDisplayText: null,
      annotation: `[Homestuck sound credits](https://web.archive.org/web/20180717171235/https://www.homestuck.com/credits/sound), excerpt`,
      body: `blablabla`,
      date: new Date('4/3/2018'),
      secondDate: null,
      dateKind: 'around',
      accessDate: new Date('7/17/2018'),
      accessKind: 'captured',
    },
    {
      artists: [artist3],
      artistDisplayText: null,
      annotation: `[fake](https://web.archive.org/web/20201024170202/https://homestuck.bandcamp.com/fake)`,
      body: `Snoopin', snoopin', snoo,`,
      date: new Date('7/20/2019'),
      secondDate: new Date('7/20/2022'),
      dateKind: 'around',
      accessDate: new Date('4/13/2024'),
      accessKind: 'captured',
    },
    {
      artists: [artist3],
      artistDisplayText: null,
      annotation: `[fake](https://web.archive.org/web/20201024170202/https://homestuck.bandcamp.com/fake)`,
      body: `~ pingas ~`,
      date: new Date('7/20/2019'),
      secondDate: new Date('7/20/2022'),
      dateKind: 'throughout',
      accessDate: new Date('4/13/2024'),
      accessKind: 'accessed',
    },
  ]);
});