Major refactor of service libs, more tests
This commit is contained in:
parent
cda69ea472
commit
ce3ff0442c
19 changed files with 288 additions and 118 deletions
|
@ -7,14 +7,14 @@ var beats = require("../../lib/services/beats");
|
|||
describe('Beats Music', function(){
|
||||
describe('lookupId', function(){
|
||||
it('should find album by ID', function(done){
|
||||
beats.lookupId("al920431").then(function(result) {
|
||||
beats.lookupId("al920431", "album").then(function(result) {
|
||||
result.name.should.equal("Deftones");
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should find track by ID', function(done){
|
||||
beats.lookupId("tr6910289").then(function(result) {
|
||||
beats.lookupId("tr6910289", "track").then(function(result) {
|
||||
result.name.should.equal("Californication");
|
||||
done();
|
||||
});
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
var assert = require("assert");
|
||||
var should = require('should');
|
||||
|
||||
var googleplaymusic = require("../../lib/services/googleplaymusic");
|
||||
var google = require("../../lib/services/google");
|
||||
|
||||
describe('Google Play Music', function(){
|
||||
describe('lookupId', function(){
|
||||
it('should find album by ID', function(done){
|
||||
googleplaymusic.lookupId("Byp6lvzimyf74wxi5634ul4tgam", "album").then(function(result) {
|
||||
google.lookupId("Byp6lvzimyf74wxi5634ul4tgam", "album").then(function(result) {
|
||||
result.name.should.equal("Listen (Deluxe)");
|
||||
done();
|
||||
});
|
||||
|
@ -16,7 +16,7 @@ describe('Google Play Music', function(){
|
|||
|
||||
describe('search', function(){
|
||||
it('should find album by search', function(done){
|
||||
googleplaymusic.search({type: "album", artist: {name: "David Guetta"}, name: "Listen (Deluxe)"}).then(function(result) {
|
||||
google.search({type: "album", artist: {name: "David Guetta"}, name: "Listen (Deluxe)"}).then(function(result) {
|
||||
result.name.should.equal("Listen (Deluxe)");
|
||||
done();
|
||||
});
|
||||
|
@ -25,21 +25,21 @@ describe('Google Play Music', function(){
|
|||
|
||||
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)").then(function(result) {
|
||||
google.parseUrl("https://play.google.com/music/listen#/album/Byp6lvzimyf74wxi5634ul4tgam/David+Guetta/Listen+(Deluxe)").then(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)").then(function(result) {
|
||||
google.parseUrl("https://play.google.com/music/listen#/album//David+Guetta/Listen+(Deluxe)").then(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").then(function(result) {
|
||||
google.parseUrl("https://play.google.com/music/m/Byp6lvzimyf74wxi5634ul4tgam").then(function(result) {
|
||||
result.id.should.equal("Byp6lvzimyf74wxi5634ul4tgam");
|
||||
done();
|
||||
});
|
57
test/services/itunes.js
Normal file
57
test/services/itunes.js
Normal file
|
@ -0,0 +1,57 @@
|
|||
"use strict";
|
||||
var assert = require("assert");
|
||||
var should = require('should');
|
||||
|
||||
var itunes = require("../../lib/services/itunes");
|
||||
|
||||
describe('iTunes Music', function(){
|
||||
describe('lookupId', function(){
|
||||
it('should find album by ID', function(done){
|
||||
itunes.lookupId("id215206912").then(function(result) {
|
||||
result.name.should.equal("Peace Orchestra");
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should find track by ID', function(done){
|
||||
itunes.lookupId("id215206958").then(function(result) {
|
||||
result.name.should.equal("Double Drums");
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('search', function(){
|
||||
it('should find album by search', function(done){
|
||||
itunes.search({type: "album", artist: {name: "Deftones"}, name: "Deftones"}).then(function(result) {
|
||||
result.name.should.equal("Deftones");
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should find track by search', function(done){
|
||||
itunes.search({type: "track", artist: {name: "Deftones"}, album: {name: "Deftones"}, name: "Hexagram"}).then(function(result) {
|
||||
result.name.should.equal("Hexagram");
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('lookupUrl', function(){
|
||||
describe('parseUrl', function(){
|
||||
it('should parse album url into ID', function(done){
|
||||
itunes.parseUrl("https://itunes.apple.com/us/album/double-drums/id215206912").then(function(result) {
|
||||
result.id.should.equal("us215206912");
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should parse track url into ID', function(done){
|
||||
itunes.parseUrl("https://itunes.apple.com/us/album/double-drums/id215206912?i=215206958&uo=4").then(function(result) {
|
||||
result.id.should.equal("us215206958");
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
16
test/services/youtube.js
Normal file
16
test/services/youtube.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
"use strict";
|
||||
var assert = require("assert");
|
||||
var should = require('should');
|
||||
|
||||
var youtube = require("../../lib/services/youtube");
|
||||
|
||||
describe('Youtube', function(){
|
||||
describe('search', function(){
|
||||
it('should find album by search', function(done){
|
||||
youtube.search({type: "track", artist: {name: "Aesop Rock"}, album: {name: "Skelethon"}, name: "Zero Dark Thirty"}).then(function(result) {
|
||||
result.name.should.equal("Aesop Rock - Zero Dark Thirty");
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue