Add tests for Beats
This commit is contained in:
parent
1a7896716f
commit
7cc68d1968
4 changed files with 62 additions and 1 deletions
|
@ -62,6 +62,10 @@ module.exports.search = function(data, next) {
|
||||||
return a.score < b.score;
|
return a.score < b.score;
|
||||||
}).shift();
|
}).shift();
|
||||||
|
|
||||||
|
if (!result.album && !result.track) {
|
||||||
|
next({service:"googleplaymusic"});
|
||||||
|
}
|
||||||
|
|
||||||
var id;
|
var id;
|
||||||
if (type == "album") {
|
if (type == "album") {
|
||||||
id = result.album.albumId;
|
id = result.album.albumId;
|
||||||
|
|
|
@ -58,6 +58,10 @@ module.exports.search = function(data, next) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!data[type + "s"].items[0]) {
|
||||||
|
next({service:"spotify"});
|
||||||
|
}
|
||||||
|
|
||||||
var item = data[type + "s"].items[0];
|
var item = data[type + "s"].items[0];
|
||||||
|
|
||||||
module.exports.lookupId(item.id, type, next);
|
module.exports.lookupId(item.id, type, next);
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node ./bin/www",
|
"start": "node ./bin/www",
|
||||||
"test": "./node_modules/mocha/bin/mocha"
|
"test": "./node_modules/mocha/bin/mocha --timeout=5000"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "0.10.x"
|
"node": "0.10.x"
|
||||||
|
|
53
test/test.js
53
test/test.js
|
@ -4,6 +4,7 @@ var should = require('should');
|
||||||
var spotify = require("../lib/spotify");
|
var spotify = require("../lib/spotify");
|
||||||
var rdio = require("../lib/rdio");
|
var rdio = require("../lib/rdio");
|
||||||
var googleplaymusic = require("../lib/googleplaymusic");
|
var googleplaymusic = require("../lib/googleplaymusic");
|
||||||
|
var beats = require("../lib/beats");
|
||||||
|
|
||||||
describe('Spotify', function(){
|
describe('Spotify', function(){
|
||||||
describe('lookupId', function(){
|
describe('lookupId', function(){
|
||||||
|
@ -112,3 +113,55 @@ describe('Google Play Music', function(){
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('Beats Music', function(){
|
||||||
|
describe('lookupId', function(){
|
||||||
|
it('should find album by ID', function(done){
|
||||||
|
beats.lookupId("al920431", function(result) {
|
||||||
|
result.name.should.equal("Deftones");
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should find track by ID', function(done){
|
||||||
|
beats.lookupId("tr6910289", function(result) {
|
||||||
|
result.name.should.equal("Californication");
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('search', function(){
|
||||||
|
it('should find album by search', function(done){
|
||||||
|
beats.search({type: "album", artist: {name: "Deftones"}, name: "Deftones"}, function(result) {
|
||||||
|
result.name.should.equal("Deftones");
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should find track by search', function(done){
|
||||||
|
beats.search({type: "track", artist: {name: "Deftones"}, album: {name: "Deftones"}, name: "Hexagram"}, function(result) {
|
||||||
|
result.name.should.equal("Hexagram");
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('lookupUrl', function(){
|
||||||
|
describe('parseUrl', function(){
|
||||||
|
it('should parse album url into ID', function(done){
|
||||||
|
beats.parseUrl("https://listen.beatsmusic.com/albums/al920431", function(result) {
|
||||||
|
result.id.should.equal("al920431");
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should parse track url into ID', function(done){
|
||||||
|
beats.parseUrl("https://listen.beatsmusic.com/albums/al6910269/tracks/tr6910289", function(result) {
|
||||||
|
result.id.should.equal("tr6910289");
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue