From 39a22f65d97692624299d75f23a2f4001e883b60 Mon Sep 17 00:00:00 2001 From: Jonathan Cremin Date: Mon, 1 Dec 2014 13:54:20 +0000 Subject: [PATCH] Add test coverage for GPM and Spotify --- lib/rdio.js | 2 +- test/test.js | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+), 1 deletion(-) diff --git a/lib/rdio.js b/lib/rdio.js index 1b50a31..e2e926f 100644 --- a/lib/rdio.js +++ b/lib/rdio.js @@ -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"); } diff --git a/test/test.js b/test/test.js index c27b073..13c2c0a 100644 --- a/test/test.js +++ b/test/test.js @@ -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(); + }); + }); + }); +});