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
|
import t from 'tap';
import {linkAndBindWikiData} from '#test-lib';
import thingConstructors from '#things';
const {
Album,
Artist,
ArtTag,
Track,
trackSection,
} = thingConstructors;
function stubAlbum(tracks, directory = 'bar') {
const album = new Album();
album.directory = directory;
const trackSection = stubTrackSection(album, tracks);
album.trackSections = [`unqualified-track-section:${trackSection.unqualifiedDirectory}`];
album.ownTrackSectionData = [trackSection];
return album;
}
function stubTrackSection(album, tracks, directory = 'baz') {
const trackSection = new TrackSection();
trackSection.unqualifiedDirectory = directory;
trackSection.tracks = tracks.map(t => Thing.getReference(t));
trackSection.ownTrackData = tracks;
trackSection.ownAlbumData = [album];
return trackSection;
}
function stubTrack(directory = 'foo') {
const track = new Track();
track.directory = directory;
return track;
}
function stubTrackAndAlbum(trackDirectory = 'foo', albumDirectory = 'bar') {
const track = stubTrack(trackDirectory);
const album = stubAlbum([track], albumDirectory);
return {track, album};
}
function stubArtist(artistName = `Test Artist`) {
const artist = new Artist();
artist.name = artistName;
return artist;
}
function stubArtistAndContribs(artistName = `Test Artist`) {
const artist = stubArtist(artistName);
const contribs = [{artist: artistName, annotation: null}];
const badContribs = [{artist: `Figment of Your Imagination`, annotation: null}];
return {artist, contribs, badContribs};
}
t.test(`ArtTag.nameShort`, t => {
t.plan(3);
const artTag = new ArtTag();
artTag.name = `Dave Strider`;
t.equal(artTag.nameShort, `Dave Strider`,
`ArtTag #1: defaults to name`);
artTag.name = `Dave Strider (Homestuck)`;
t.equal(artTag.nameShort, `Dave Strider`,
`ArtTag #2: trims parenthical part at end`);
artTag.name = `This (And) That (Then)`;
t.equal(artTag.nameShort, `This (And) That`,
`ArtTag #2: doesn't trim midlde parenthical part`);
});
|