« get me outta code hell

generateTrackAdditionalNamesBox.js « snapshot « test - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/test/snapshot/generateTrackAdditionalNamesBox.js
blob: 9c1e3598efab9f68f80cd020d79fa4805e2787d2 (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
import t from 'tap';

import contentFunction from '#content-function';
import {testContentFunctions} from '#test-lib';

testContentFunctions(t, 'generateTrackAdditionalNamesBox (snapshot)', async (t, evaluate) => {
  await evaluate.load({
    mock: {
      generateAdditionalNamesBox:
        evaluate.stubContentFunction('generateAdditionalNamesBox'),
    },
  });

  const stubTrack = {
    additionalNames: [],
    sharedAdditionalNames: [],
    inferredAdditionalNames: [],
  };

  const quickSnapshot = (message, trackProperties) =>
    evaluate.snapshot(message, {
      name: 'generateTrackAdditionalNamesBox',
      args: [{...stubTrack, ...trackProperties}],
    });

  quickSnapshot(`no additional names`, {});

  quickSnapshot(`own additional names only`, {
    additionalNames: [
      {name: `Foo Bar`, annotation: `the Alps`},
    ],
  });

  quickSnapshot(`shared additional names only`, {
    sharedAdditionalNames: [
      {name: `Bar Foo`, annotation: `the Rockies`},
    ],
  });

  quickSnapshot(`inferred additional names only`, {
    inferredAdditionalNames: [
      {name: `Baz Baz`, from: [{directory: `the-pyrenees`}]},
    ],
  });

  quickSnapshot(`multiple own`, {
    additionalNames: [
      {name: `Apple Time!`},
      {name: `Pterodactyl Time!`},
      {name: `Banana Time!`},
    ],
  });

  quickSnapshot(`own and shared, some overlap`, {
    additionalNames: [
      {name: `weed dreams..`, annotation: `own annotation`},
      {name: `夜間のMOON汗`, annotation: `own annotation`},
    ],
    sharedAdditionalNames: [
      {name: `weed dreams..`, annotation: `shared annotation`},
      {name: `GAMINGブラザー96`, annotation: `shared annotation`},
    ],
  });

  quickSnapshot(`shared and inferred, some overlap`, {
    sharedAdditionalNames: [
      {name: `Coruscate`, annotation: `shared annotation`},
      {name: `Arbroath`, annotation: `shared annotation`},
    ],
    inferredAdditionalNames: [
      {name: `Arbroath`, from: [{directory: `inferred-from`}]},
      {name: `Prana Ferox`, from: [{directory: `inferred-from`}]},
    ],
  });

  quickSnapshot(`own and inferred, some overlap`, {
    additionalNames: [
      {name: `Ke$halo Strike Back`, annotation: `own annotation`},
      {name: `Ironic Mania`, annotation: `own annotation`},
    ],
    inferredAdditionalNames: [
      {name: `Ironic Mania`, from: [{directory: `inferred-from`}]},
      {name: `ANARCHY::MEGASTRIFE`, from: [{directory: `inferred-from`}]},
    ],
  });

  quickSnapshot(`own and shared and inferred, various overlap`, {
    additionalNames: [
      {name: `Own!`, annotation: `own annotation`},
      {name: `Own! Shared!`, annotation: `own annotation`},
      {name: `Own! Inferred!`, annotation: `own annotation`},
      {name: `Own! Shared! Inferred!`, annotation: `own annotation`},
    ],
    sharedAdditionalNames: [
      {name: `Shared!`, annotation: `shared annotation`},
      {name: `Own! Shared!`, annotation: `shared annotation`},
      {name: `Shared! Inferred!`, annotation: `shared annotation`},
      {name: `Own! Shared! Inferred!`, annotation: `shared annotation`},
    ],
    inferredAdditionalNames: [
      {name: `Inferred!`, from: [{directory: `inferred-from`}]},
      {name: `Own! Inferred!`, from: [{directory: `inferred-from`}]},
      {name: `Shared! Inferred!`, from: [{directory: `inferred-from`}]},
      {name: `Own! Shared! Inferred!`, from: [{directory: `inferred-from`}]},
    ],
  });
});