« get me outta code hell

generateAlbumTrackListItem.js « snapshot « test - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/test/snapshot/generateAlbumTrackListItem.js
blob: e87c6de0a52f041f912b8d83a3e3a3a3b6f4c240 (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
import t from 'tap';
import {testContentFunctions} from '../lib/content-function.js';

testContentFunctions(t, 'generateAlbumTrackListItem (snapshot)', async (t, evaluate) => {
  const artist1 = {directory: 'toby-fox', name: 'Toby Fox', urls: ['https://toby.fox/']};
  const artist2 = {directory: 'james-roach', name: 'James Roach'};
  const artist3 = {directory: 'clark-powell', name: 'Clark Powell'};
  const artist4 = {directory: ''}
  const albumContribs = [{who: artist1}, {who: artist2}];

  await evaluate.load();

  evaluate.snapshot('basic behavior', {
    name: 'generateAlbumTrackListItem',
    args: [
      {
        // Just pretend Hiveswap Act 1 OST doesn't have its own Artists field OK?
        // We test that kind of case later!
        name: 'Final Spice',
        directory: 'final-spice',
        duration: 54,
        color: '#33cc77',
        artistContribs: [
          {who: artist1, what: 'composition & arrangement'},
          {who: artist2, what: 'arrangement'},
        ],
      },
      {artistContribs: []},
    ],
  });

  evaluate.snapshot('zero duration, zero artists', {
    name: 'generateAlbumTrackListItem',
    args: [
      {
        name: 'You have got to be about the most superficial commentator on con-langues since the idiotic B. Gilson.',
        directory: 'you-have-got-to-be-about-the-most-superficial-commentator-on-con-langues-since-the-idiotic-b-gilson',
        duration: 0,
        artistContribs: [],
      },
      {artistContribs: []},
    ],
  });

  evaluate.snapshot('hide artists if inherited from album', {
    name: 'generateAlbumTrackListItem',
    multiple: [
      {args: [
        {directory: 'track1', name: 'Same artists, same order', artistContribs: [{who: artist1}, {who: artist2}]},
        {artistContribs: albumContribs},
      ]},
      {args: [
        {directory: 'track2', name: 'Same artists, different order', artistContribs: [{who: artist2}, {who: artist1}]},
        {artistContribs: albumContribs},
      ]},
      {args: [
        {directory: 'track3', name: 'Extra artist', artistContribs: [{who: artist1}, {who: artist2}, {who: artist3}]},
        {artistContribs: albumContribs},
      ]},
      {args: [
        {directory: 'track4', name: 'Missing artist', artistContribs: [{who: artist1}]},
        {artistContribs: albumContribs},
      ]},
    ],
  });
});