forked from nukeop/nuclear
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
131 lines (120 loc) · 3.29 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
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
require('isomorphic-fetch');
import assert from 'assert';
import { expect } from 'chai';
var billboard = require('../app/rest/Billboard');
var lastfm = require('../app/rest/Lastfm');
describe('Billboard api tests', () => {
it('tests exports', () => {
expect(billboard).to.be.an('object');
expect(billboard).to.have.property('getTop');
expect(billboard).to.have.property('lists');
});
it('gets a pop songs list', () => {
billboard.getTop(billboard.lists.genres[0].link)
.then(songs => {
expect(songs).to.be.an('array').that.has.lengthOf(40);
})
.catch(err => {
console.error(err);
});
});
});
describe('Last.fm api tests', () => {
it('tests exports', () => {
expect(lastfm).to.be.an('object');
});
it('tests getting top tags', () => {
lastfm.getTopTags()
.then(response => response.json())
.then(results => {
expect(results).to.be.an('object').that.has.nested.property('toptags.tag');
var sample = results.toptags.tag[0];
expect(sample).to.be.an('object').that.has.all.keys('name', 'count', 'reach');
});
});
it('tests getting tag info', () => {
lastfm.getTagInfo('indie')
.then(response => response.json())
.then(results => {
expect(results).to.be.an('object').that.has.property('tag');
expect(results.tag).to.be.an('object').that.has.all.keys(
'name',
'total',
'reach',
'wiki'
);
})
.catch(err => {
console.error(err);
});
});
it('tests getting top tag tracks', () => {
lastfm.getTagTracks('indie')
.then(response => response.json())
.then(results => {
expect(results).to.be.an('object').that.has.nested.property('tracks.track');
var sample = results.tracks.track[0];
expect(sample).to.be.an('object').that.has.all.keys(
'name',
'artist',
'duration',
'streamable',
'mbid',
'url',
'image',
'@attr'
);
})
.catch(err => {
console.error(err);
});
});
it('tests getting top tag albums', () => {
lastfm.getTagAlbums('indie')
.then(response => response.json())
.then(results => {
expect(results).to.be.an('object').that.has.nested.property('albums.album');
var sample = results.albums.album[0];
expect(sample).to.be.an('object').that.has.all.keys(
'name',
'mbid',
'url',
'artist',
'image',
'@attr'
);
})
.catch(err => {
console.error(err);
});
});
it('tests getting top tag artists', () => {
lastfm.getTagArtists('indie')
.then(response => response.json())
.then(results => {
expect(results).to.be.an('object').that.has.nested.property('topartists.artist');
var sample = results.topartists.artist[0];
expect(sample).to.be.an('object').that.has.all.keys(
'name',
'mbid',
'url',
'streamable',
'image',
'@attr'
);
})
.catch(err => {
console.error(err);
});
});
it('tests getting similar tags', () => {
lastfm.getSimilarTags('electronic')
.then(response => response.json())
.then(results => {
expect(results).to.be.an('object').that.has.property('similartags');
})
.catch(err => {
console.error(err);
});
});
});