Use promises, split tests, make music services modular, add deezer.
This commit is contained in:
parent
7cc68d1968
commit
2b65c0632a
15 changed files with 407 additions and 307 deletions
57
test/services/beats.js
Normal file
57
test/services/beats.js
Normal file
|
@ -0,0 +1,57 @@
|
|||
"use strict";
|
||||
var assert = require("assert");
|
||||
var should = require('should');
|
||||
|
||||
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) {
|
||||
result.name.should.equal("Deftones");
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should find track by ID', function(done){
|
||||
beats.lookupId("tr6910289").then(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"}).then(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"}).then(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").then(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").then(function(result) {
|
||||
result.id.should.equal("tr6910289");
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
0
test/services/deezer.js
Normal file
0
test/services/deezer.js
Normal file
48
test/services/googleplaymusic.js
Normal file
48
test/services/googleplaymusic.js
Normal file
|
@ -0,0 +1,48 @@
|
|||
"use strict";
|
||||
var assert = require("assert");
|
||||
var should = require('should');
|
||||
|
||||
var googleplaymusic = require("../../lib/services/googleplaymusic");
|
||||
|
||||
describe('Google Play Music', function(){
|
||||
describe('lookupId', function(){
|
||||
it('should find album by ID', function(done){
|
||||
googleplaymusic.lookupId("Byp6lvzimyf74wxi5634ul4tgam", "album").then(function(result) {
|
||||
result.name.should.equal("Listen (Deluxe)");
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
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) {
|
||||
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)").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) {
|
||||
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) {
|
||||
result.id.should.equal("Byp6lvzimyf74wxi5634ul4tgam");
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
41
test/services/rdio.js
Normal file
41
test/services/rdio.js
Normal file
|
@ -0,0 +1,41 @@
|
|||
"use strict";
|
||||
var assert = require("assert");
|
||||
var should = require('should');
|
||||
|
||||
var rdio = require("../../lib/services/rdio");
|
||||
|
||||
describe('Rdio', function(){
|
||||
describe('lookupId', function(){
|
||||
it('should find album by ID', function(done){
|
||||
rdio.lookupId("Qj4NXr0").then(function(result) {
|
||||
result.name.should.equal("Listen (Deluxe)");
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('search', function(){
|
||||
it('should find album by search', function(done){
|
||||
rdio.search({type: "album", artist: {name: "David Guetta"}, name: "Listen (Deluxe)"}).then(function(result) {
|
||||
result.name.should.equal("Listen (Deluxe)");
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('parseUrl', function(){
|
||||
it('should parse regular url into album object', function(done){
|
||||
rdio.parseUrl("https://www.rdio.com/artist/David_Guetta/album/Listen_(Deluxe)/").then(function(result) {
|
||||
result.name.should.equal("Listen (Deluxe)");
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should parse short url into album object', function(done){
|
||||
rdio.parseUrl("http://rd.io/x/Qj4NXr0/").then(function(result) {
|
||||
result.name.should.equal("Listen (Deluxe)");
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
34
test/services/spotify.js
Normal file
34
test/services/spotify.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
"use strict";
|
||||
var assert = require("assert");
|
||||
var should = require('should');
|
||||
|
||||
var spotify = require("../../lib/services/spotify");
|
||||
|
||||
describe('Spotify', function(){
|
||||
describe('lookupId', function(){
|
||||
it('should find album by ID', function(done){
|
||||
spotify.lookupId("77UW17CZFyCaRLHdHeofZu", "album").then(function(result) {
|
||||
result.name.should.equal("Listen (Deluxe)");
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('search', function(){
|
||||
it('should find album by search', function(done){
|
||||
spotify.search({type: "album", artist: {name: "David Guetta"}, name: "Listen (Deluxe)"}).then(function(result) {
|
||||
result.name.should.equal("Listen (Deluxe)");
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('parseUrl', function(){
|
||||
it('should parse url into ID', function(done){
|
||||
spotify.parseUrl("https://play.spotify.com/album/77UW17CZFyCaRLHdHeofZu").then(function(result) {
|
||||
result.id.should.equal("77UW17CZFyCaRLHdHeofZu");
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue