-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathtest-034-artistbrowse.js
More file actions
39 lines (36 loc) · 1.48 KB
/
Copy pathtest-034-artistbrowse.js
File metadata and controls
39 lines (36 loc) · 1.48 KB
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
var sp = require('../lib/libspotify');
var testutil = require('./util');
var getArtist = function(test, cb) {
var search = new sp.Search('artist:"Hurts"');
search.trackCount = 1;
search.execute(function() {
test.ok(search.tracks.length > 0, 'the track was found');
test.ok(search.tracks[0] instanceof sp.Track, 'track is an track');
test.ok(search.tracks[0].album instanceof sp.Album, 'album is an album');
test.ok(search.tracks[0].album.artist instanceof sp.Artist, 'artist is an artist');
cb(search.tracks[0].album.artist);
});
};
var session = null;
exports.artistbrowse = {
setUp: function(cb) {
testutil.getDefaultTestSession(function(s) {
session = s;
cb();
});
},
'get albums from artist': function(test) {
getArtist(test, function(artist) {
artist.getAvailableAlbums(function(err, albums) {
test.ifError(err);
/* FIXME: Should be 22, see comment in lib/Artist.js line 50 */
test.equal(albums.length, 23, 'the artist has 23 available albums');
test.equal(albums.map(function(e) {return e instanceof sp.Album;}).indexOf(false), -1, 'It should only contain albums');
test.equal(albums.reduce(function(prev, current) {
return prev && current.isReady();
}, true), true, 'All albums should be loaded');
test.done();
});
});
}
}