-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
57 lines (49 loc) · 2.1 KB
/
test.js
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
const { MusixmatchClient, Track } = require('.');
const { test, describe, expect } = require('@jest/globals');
const client = new MusixmatchClient(process.env.MUSIXMATCH_TOKEN, 'desktop');
describe('Track search', () => {
test('Find track (query)', async () => {
let tracks = await client.trackSearch({ query: 'Kobaryo - Bookmaker' });
expect(tracks.length).toBeGreaterThanOrEqual(0);
});
test('Find track (trackTitle, artist)', async () => {
let tracks = await client.trackSearch({ trackTitle: 'Bookmaker', artist: 'Kobaryo' });
expect(tracks.length).toBeGreaterThanOrEqual(0);
});
test('Find track (lyrics)', async () => {
let tracks = await client.trackSearch({ lyrics: 'It\'s just a shot away' });
expect(tracks.length).toBeGreaterThanOrEqual(0);
});
test('Find track (non-existent track)', async () => {
let tracks = await client.trackSearch({ artist: 'THIS1ARTIST3DOES3NOT7EXIST', trackTitle: 'THIS1TRACK3DOES3NOT7EXIST' });
expect(tracks).toHaveLength(0);
});
test('Find track (empty arguments)', async () => {
await client.trackSearch({});
});
});
describe('Track information (稲葉曇 - Lost Umbrella)', () => {
const track = new Track();
track.bind(client);
track.track_id = 247979107;
test('Fetch track lyrics', async () => {
let trackLyrics = await track.fetchLyrics();
expect(trackLyrics).not.toBeNull();
});
test('Fetch track subtitles', async () => {
let trackSubtitles = await track.fetchSubtitles();
expect(trackSubtitles).not.toBeNull();
});
test('Fetch track richsync', async () => {
let trackRichsync = await track.fetchRichsync();
expect(trackRichsync).not.toBeNull();
});
test('Fetch track translations (to \'rja\')', async () => {
let trackTranslations = await track.fetchTranslations('rja');
expect(trackTranslations).not.toBeNull();
});
test('Fetch track snippet', async () => {
let trackSnippet = await track.fetchSnippet();
expect(trackSnippet).not.toBeNull();
});
});