Add test coverage for GPM and Spotify

This commit is contained in:
Jonathan Cremin 2014-12-01 13:54:20 +00:00
parent 2e302d7f8c
commit 39a22f65d9
2 changed files with 82 additions and 1 deletions

View file

@ -1,7 +1,7 @@
var parse = require('url').parse;
if (!process.env.RDIO_API_KEY || !process.env.RDIO_API_SHARED) {
throw new Error("You need to set GOOGLE_EMAIL and GOOGLE_PASSWORD environment variables");
throw new Error("You need to set RDIO_API_KEY and RDIO_API_SHARED environment variables");
}

View file

@ -1,6 +1,8 @@
var assert = require("assert");
var should = require('should');
var spotify = require("../lib/spotify");
var rdio = require("../lib/rdio");
var googleplaymusic = require("../lib/googleplaymusic");
describe('Spotify', function(){
describe('lookupId', function(){
@ -30,3 +32,82 @@ describe('Spotify', function(){
});
});
});
describe('Rdio', function(){
describe('lookupId', function(){
it('should find album by ID', function(done){
rdio.lookupId("Qj4NXr0", function(result) {
result.name.should.equal("Listen (Deluxe)");
done();
});
});
});
describe('search', function(){
it('should find album by search', function(done){
rdio.search("David Guetta Listen (Deluxe)", "album", function(result) {
result.name.should.equal("Listen (Deluxe)");
done();
});
});
});
describe('lookupUrl', function(){
it('should parse regular url into album object', function(done){
rdio.lookupUrl("https://www.rdio.com/artist/David_Guetta/album/Listen_(Deluxe)/", function(result) {
result.name.should.equal("Listen (Deluxe)");
done();
});
});
it('should parse short url into album object', function(done){
rdio.lookupUrl("http://rd.io/x/Qj4NXr0/", function(result) {
result.name.should.equal("Listen (Deluxe)");
done();
});
});
});
});
describe('Google Play Music', function(){
describe('lookupId', function(){
it('should find album by ID', function(done){
googleplaymusic.lookupId("Byp6lvzimyf74wxi5634ul4tgam", "album", function(result) {
result.name.should.equal("Listen (Deluxe)");
done();
});
});
});
describe('search', function(){
it('should find album by search', function(done){
googleplaymusic.search("David Guetta Listen (Deluxe)", "album", function(result) {
result.name.should.equal("Listen (Deluxe)");
done();
});
});
});
describe('lookupUrl', function(){
it('should parse regular url into album ID', function(done){
googleplaymusic.parseUrl("https://play.google.com/music/listen#/album/Byp6lvzimyf74wxi5634ul4tgam/David+Guetta/Listen+(Deluxe)", function(result) {
result.id.should.equal("Byp6lvzimyf74wxi5634ul4tgam");
done();
});
});
it('should parse url without ID into album ID', function(done){
googleplaymusic.parseUrl("https://play.google.com/music/listen#/album//David+Guetta/Listen+(Deluxe)", function(result) {
result.id.should.equal("Byp6lvzimyf74wxi5634ul4tgam");
done();
});
});
it('should parse share url into album ID', function(done){
googleplaymusic.parseUrl("https://play.google.com/music/m/Byp6lvzimyf74wxi5634ul4tgam", function(result) {
result.id.should.equal("Byp6lvzimyf74wxi5634ul4tgam");
done();
});
});
});
});