withParsedCommentaryEntries.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. import t from 'tap';
  2. import {compositeFrom, input} from '#composite';
  3. import thingConstructors from '#things';
  4. import {exposeDependency} from '#composite/control-flow';
  5. import {withParsedCommentaryEntries} from '#composite/wiki-data';
  6. const {Artist} = thingConstructors;
  7. const composite = compositeFrom({
  8. compose: false,
  9. steps: [
  10. withParsedCommentaryEntries({
  11. from: 'from',
  12. }),
  13. exposeDependency({dependency: '#parsedCommentaryEntries'}),
  14. ],
  15. });
  16. function stubArtist(artistName = `Test Artist`) {
  17. const artist = new Artist();
  18. artist.name = artistName;
  19. return artist;
  20. }
  21. t.test(`withParsedCommentaryEntries: basic behavior`, t => {
  22. t.plan(7);
  23. const artist1 = stubArtist(`Mobius Trip`);
  24. const artist2 = stubArtist(`Hadron Kaleido`);
  25. const artist3 = stubArtist('Homestuck');
  26. const artistData = [artist1, artist2, artist3];
  27. t.match(composite, {
  28. expose: {
  29. dependencies: ['from', 'artistData'],
  30. },
  31. });
  32. t.same(composite.expose.compute({
  33. artistData,
  34. from:
  35. `<i>Mobius Trip:</i>\n` +
  36. `Some commentary.\n` +
  37. `Very cool.\n`,
  38. }), [
  39. {
  40. artists: [artist1],
  41. artistDisplayText: null,
  42. annotation: null,
  43. date: null,
  44. accessDate: null,
  45. accessKind: null,
  46. secondDate: null,
  47. dateKind: null,
  48. body: `Some commentary.\nVery cool.`,
  49. },
  50. ]);
  51. t.same(composite.expose.compute({
  52. artistData,
  53. from:
  54. `<i>Mobius Trip|Moo-bius Trip:</i> (music, art, 12 January 2015)\n` +
  55. `First commentary entry.\n` +
  56. `Very cool.\n` +
  57. `<i>Hadron Kaleido|<b>[[artist:hadron-kaleido|The Ol' Hadron]]</b>:</i> (moral support, 4/4/2022)\n` +
  58. `Second commentary entry. Yes. So cool.\n` +
  59. `<i>Mystery Artist:</i> (pingas, August 25, 2023)\n` +
  60. `Oh no.. Oh dear...\n` +
  61. `<i>Mobius Trip, Hadron Kaleido:</i>\n` +
  62. `And back around we go.`,
  63. }), [
  64. {
  65. artists: [artist1],
  66. artistDisplayText: `Moo-bius Trip`,
  67. annotation: `music, art`,
  68. date: new Date('12 January 2015'),
  69. body: `First commentary entry.\nVery cool.`,
  70. secondDate: null,
  71. dateKind: null,
  72. accessDate: null,
  73. accessKind: null,
  74. },
  75. {
  76. artists: [artist2],
  77. artistDisplayText: `<b>[[artist:hadron-kaleido|The Ol' Hadron]]</b>`,
  78. annotation: `moral support`,
  79. date: new Date('4 April 2022'),
  80. body: `Second commentary entry. Yes. So cool.`,
  81. secondDate: null,
  82. dateKind: null,
  83. accessDate: null,
  84. accessKind: null,
  85. },
  86. {
  87. artists: [],
  88. artistDisplayText: null,
  89. annotation: `pingas`,
  90. date: new Date('25 August 2023'),
  91. body: `Oh no.. Oh dear...`,
  92. secondDate: null,
  93. dateKind: null,
  94. accessDate: null,
  95. accessKind: null,
  96. },
  97. {
  98. artists: [artist1, artist2],
  99. artistDisplayText: null,
  100. annotation: null,
  101. date: null,
  102. body: `And back around we go.`,
  103. secondDate: null,
  104. dateKind: null,
  105. accessDate: null,
  106. accessKind: null,
  107. },
  108. ]);
  109. t.same(composite.expose.compute({
  110. artistData,
  111. from:
  112. `<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` +
  113. `\n` +
  114. `Written by [[artist:michael-guy-bowman|Michael Guy Bowman]]<br>\n` +
  115. `Arrangement by [[artist:mark-j-hadley|Mark Hadley]]\n` +
  116. `\n` +
  117. `<i>Homestuck:</i> ([fake](https://web.archive.org/web/20201024170202/https://homestuck.bandcamp.com/fake), 7/20/2019 captured 4/13/2024)\n` +
  118. `This isn't real!\n` +
  119. `\n` +
  120. `<i>Homestuck:</i> ([fake](https://homestuck.com/fake), 10/25/2011 accessed 10/27/2011)\n` +
  121. `This isn't real either!\n` +
  122. `\n` +
  123. `<i>Homestuck:</i> ([fake](https://web.archive.org/web/20201024170202/https://homestuck.bandcamp.com/fake), 7/20/2019 accessed 4/13/2024)\n` +
  124. `Not this one, neither!\n`
  125. }), [
  126. {
  127. artists: [artist3],
  128. artistDisplayText: null,
  129. 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)"`,
  130. date: new Date('10/25/2019'),
  131. body:
  132. `Written by [[artist:michael-guy-bowman|Michael Guy Bowman]]<br>\n` +
  133. `Arrangement by [[artist:mark-j-hadley|Mark Hadley]]`,
  134. secondDate: null,
  135. dateKind: null,
  136. accessDate: new Date('10/24/2020'),
  137. accessKind: 'captured',
  138. },
  139. {
  140. artists: [artist3],
  141. artistDisplayText: null,
  142. annotation: `[fake](https://web.archive.org/web/20201024170202/https://homestuck.bandcamp.com/fake)`,
  143. date: new Date('7/20/2019'),
  144. body: `This isn't real!`,
  145. secondDate: null,
  146. dateKind: null,
  147. accessDate: new Date('4/13/2024'),
  148. accessKind: 'captured',
  149. },
  150. {
  151. artists: [artist3],
  152. artistDisplayText: null,
  153. annotation: `[fake](https://homestuck.com/fake)`,
  154. date: new Date('10/25/2011'),
  155. body: `This isn't real either!`,
  156. secondDate: null,
  157. dateKind: null,
  158. accessDate: new Date('10/27/2011'),
  159. accessKind: 'accessed',
  160. },
  161. {
  162. artists: [artist3],
  163. artistDisplayText: null,
  164. annotation: `[fake](https://web.archive.org/web/20201024170202/https://homestuck.bandcamp.com/fake)`,
  165. date: new Date('7/20/2019'),
  166. body: `Not this one, neither!`,
  167. secondDate: null,
  168. dateKind: null,
  169. accessDate: new Date('4/13/2024'),
  170. accessKind: 'accessed',
  171. },
  172. ]);
  173. t.same(composite.expose.compute({
  174. artistData,
  175. from:
  176. `<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` +
  177. `\n` +
  178. `[[flash:246|Page 2146]] - <b>"Sburban Countdown"</b><br>\n` +
  179. `Available on Bandcamp in [[album:homestuck-vol-1-4|Homestuck Vol. 1-4]]<br>\n` +
  180. `Written by [[artist:michael-guy-bowman|Michael Guy Bowman]]<br>\n` +
  181. `Arrangement by [[artist:mark-j-hadley|Mark Hadley]]\n` +
  182. `\n` +
  183. `<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` +
  184. `It's goin' once.\n` +
  185. `\n` +
  186. `<i>Homestuck:</i> (10/25/2011 - 10/28/2011 accessed 10/27/2011)\n` +
  187. `It's goin' twice.\n` +
  188. `\n` +
  189. `<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` +
  190. `It's goin' thrice!\n`
  191. }), [
  192. {
  193. artists: [artist3],
  194. artistDisplayText: null,
  195. annotation: `[MSPA sound credits](https://web.archive.org/web/20120805031705/http://www.mspaintadventures.com:80/soundcredits.html)`,
  196. body:
  197. `[[flash:246|Page 2146]] - <b>"Sburban Countdown"</b><br>\n` +
  198. `Available on Bandcamp in [[album:homestuck-vol-1-4|Homestuck Vol. 1-4]]<br>\n` +
  199. `Written by [[artist:michael-guy-bowman|Michael Guy Bowman]]<br>\n` +
  200. `Arrangement by [[artist:mark-j-hadley|Mark Hadley]]`,
  201. date: new Date('6/21/2012'),
  202. secondDate: new Date('8/5/2012'),
  203. dateKind: 'sometime',
  204. accessDate: new Date('8/5/2012'),
  205. accessKind: 'captured',
  206. },
  207. {
  208. artists: [artist3],
  209. artistDisplayText: null,
  210. annotation: `[fake](https://web.archive.org/web/20201024170202/https://homestuck.bandcamp.com/fake)`,
  211. body: `It's goin' once.`,
  212. date: new Date('7/20/2019'),
  213. secondDate: new Date('7/20/2022'),
  214. dateKind: null,
  215. accessDate: new Date('4/13/2024'),
  216. accessKind: 'captured',
  217. },
  218. {
  219. artists: [artist3],
  220. artistDisplayText: null,
  221. annotation: '', // TODO: This should be null, but the regex isn't structured for that, at the moment.
  222. body: `It's goin' twice.`,
  223. date: new Date('10/25/2011'),
  224. secondDate: new Date('10/28/2011'),
  225. dateKind: null,
  226. accessDate: new Date('10/27/2011'),
  227. accessKind: 'accessed',
  228. },
  229. {
  230. artists: [artist3],
  231. artistDisplayText: null,
  232. annotation: `[fake](https://web.archive.org/web/20201024170202/https://homestuck.bandcamp.com/fake)`,
  233. body: `It's goin' thrice!`,
  234. date: new Date('7/20/2019'),
  235. secondDate: new Date('7/20/2022'),
  236. dateKind: null,
  237. accessDate: new Date('4/13/2024'),
  238. accessKind: 'accessed',
  239. },
  240. ]);
  241. t.same(composite.expose.compute({
  242. artistData,
  243. from:
  244. `<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` +
  245. `\n` +
  246. `[[flash:246|Page 2146]] - <b>"Sburban Countdown"</b><br>\n` +
  247. `Available on Bandcamp in [[album:homestuck-vol-1-4|Homestuck Vol. 1-4]]<br>\n` +
  248. `Written by [[artist:michael-guy-bowman|Michael Guy Bowman]]<br>\n` +
  249. `Arrangement by [[artist:mark-j-hadley|Mark Hadley]]\n` +
  250. `\n` +
  251. `<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` +
  252. `It's goin' once.\n` +
  253. `\n` +
  254. `<i>Homestuck:</i> (10/25/2011 - 10/28/2011 accessed 10/27/2011)\n` +
  255. `It's goin' twice.\n` +
  256. `\n` +
  257. `<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` +
  258. `It's goin' thrice!\n`
  259. }), [
  260. {
  261. artists: [artist3],
  262. artistDisplayText: null,
  263. annotation: `[MSPA sound credits](https://web.archive.org/web/20120805031705/http://www.mspaintadventures.com:80/soundcredits.html)`,
  264. body:
  265. `[[flash:246|Page 2146]] - <b>"Sburban Countdown"</b><br>\n` +
  266. `Available on Bandcamp in [[album:homestuck-vol-1-4|Homestuck Vol. 1-4]]<br>\n` +
  267. `Written by [[artist:michael-guy-bowman|Michael Guy Bowman]]<br>\n` +
  268. `Arrangement by [[artist:mark-j-hadley|Mark Hadley]]`,
  269. date: new Date('6/21/2012'),
  270. secondDate: new Date('8/5/2012'),
  271. dateKind: 'sometime',
  272. accessDate: new Date('8/5/2012'),
  273. accessKind: 'captured',
  274. },
  275. {
  276. artists: [artist3],
  277. artistDisplayText: null,
  278. annotation: `[fake](https://web.archive.org/web/20201024170202/https://homestuck.bandcamp.com/fake)`,
  279. body: `It's goin' once.`,
  280. date: new Date('7/20/2019'),
  281. secondDate: new Date('7/20/2022'),
  282. dateKind: null,
  283. accessDate: new Date('4/13/2024'),
  284. accessKind: 'captured',
  285. },
  286. {
  287. artists: [artist3],
  288. artistDisplayText: null,
  289. annotation: '', // TODO: This should be null, but the regex isn't structured for that, at the moment.
  290. body: `It's goin' twice.`,
  291. date: new Date('10/25/2011'),
  292. secondDate: new Date('10/28/2011'),
  293. dateKind: null,
  294. accessDate: new Date('10/27/2011'),
  295. accessKind: 'accessed',
  296. },
  297. {
  298. artists: [artist3],
  299. artistDisplayText: null,
  300. annotation: `[fake](https://web.archive.org/web/20201024170202/https://homestuck.bandcamp.com/fake)`,
  301. body: `It's goin' thrice!`,
  302. date: new Date('7/20/2019'),
  303. secondDate: new Date('7/20/2022'),
  304. dateKind: null,
  305. accessDate: new Date('4/13/2024'),
  306. accessKind: 'accessed',
  307. },
  308. ]);
  309. t.same(composite.expose.compute({
  310. artistData,
  311. from:
  312. `<i>Homestuck:</i> ([Homestuck sound credits](https://web.archive.org/web/20180717171235/https://www.homestuck.com/credits/sound), excerpt, around 4/3/2018)\n` +
  313. `blablabla\n` +
  314. `<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` +
  315. `Snoopin', snoopin', snoo,\n` +
  316. `<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` +
  317. `~ pingas ~\n`
  318. }), [
  319. {
  320. artists: [artist3],
  321. artistDisplayText: null,
  322. annotation: `[Homestuck sound credits](https://web.archive.org/web/20180717171235/https://www.homestuck.com/credits/sound), excerpt`,
  323. body: `blablabla`,
  324. date: new Date('4/3/2018'),
  325. secondDate: null,
  326. dateKind: 'around',
  327. accessDate: new Date('7/17/2018'),
  328. accessKind: 'captured',
  329. },
  330. {
  331. artists: [artist3],
  332. artistDisplayText: null,
  333. annotation: `[fake](https://web.archive.org/web/20201024170202/https://homestuck.bandcamp.com/fake)`,
  334. body: `Snoopin', snoopin', snoo,`,
  335. date: new Date('7/20/2019'),
  336. secondDate: new Date('7/20/2022'),
  337. dateKind: 'around',
  338. accessDate: new Date('4/13/2024'),
  339. accessKind: 'captured',
  340. },
  341. {
  342. artists: [artist3],
  343. artistDisplayText: null,
  344. annotation: `[fake](https://web.archive.org/web/20201024170202/https://homestuck.bandcamp.com/fake)`,
  345. body: `~ pingas ~`,
  346. date: new Date('7/20/2019'),
  347. secondDate: new Date('7/20/2022'),
  348. dateKind: 'throughout',
  349. accessDate: new Date('4/13/2024'),
  350. accessKind: 'accessed',
  351. },
  352. ]);
  353. });