-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathtest-020-search-02-process.js
More file actions
62 lines (57 loc) · 2.41 KB
/
test-020-search-02-process.js
File metadata and controls
62 lines (57 loc) · 2.41 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
var sp = require('../lib/libspotify');
var cred = require('../spotify_key/passwd');
var testutil = require('./util');
var trycatch = require('trycatch');
var session = null;
exports.setUp = function(cb) {
testutil.getDefaultTestSession(function(s) {
session = s;
cb();
});
};
exports.testGetTrackFromSearchResult = function(test) {
var search = new sp.Search('artist:"Guillemots" track:"Fleet"');
search.execute(function() {
test.doesNotThrow(function() {
test.ok(search.tracks.length > 0, "the search should return at least one result");
var first = search.tracks[0];
test.ok(first instanceof sp.Track, "the track results should be loaded track objects");
test.ok(first.isReady());
test.equal('Guillemots', first.artist, "the track should be a guillemots song");
test.equal('Fleet', first.title, "the track should be a guillemots song");
test.equal('Hello Land!', first.album, "the album should be Hello land");
});
test.done();
});
};
exports.testGetAlbumFromSearchResult = function(test) {
var search = new sp.Search('artist:"Hurts" album:"Exile"');
search.trackCount = 0;
search.albumCount = 1;
search.execute(function() {
test.doesNotThrow(function() {
test.ok(search.albums.length > 0, "the search should return at least one result");
var first = search.albums[0];
test.ok(first instanceof sp.Album, "the album results should be loaded album objects");
test.ok(first.isReady());
test.equal('Hurts', first.artist, "the album should be a Hurts album");
test.equal('Exile (Deluxe)', first.name, "the album should be Exile (Deluxe)");
});
test.done();
});
};
exports.testGetArtistFromSearchResult = function(test) {
var search = new sp.Search('artist:"Coldplay"');
search.trackCount = 0;
search.artistCount = 1;
search.execute(function() {
test.doesNotThrow(function() {
test.ok(search.artists.length > 0, "the search should return at least one result");
var first = search.artists[0];
test.ok(first instanceof sp.Artist, "the artist results should be loaded artist objects");
test.ok(first.isReady());
test.equal('Coldplay', first.name, "the artist should be Coldplay");
});
test.done();
});
};