Finally finished giant ES6 refactor

This commit is contained in:
Jonathan Cremin 2015-08-20 23:22:57 +01:00
parent c6d48cc424
commit 03e2666958
39 changed files with 553 additions and 635 deletions

View file

@ -3,7 +3,7 @@ import lookup from '../lib/lookup';
describe('Search with url', function(){
it('should find album by url', function* (){
let result = yield lookup('https://play.google.com/music/listen#/album/Bz6wrjczddcj5hurijsv6ohdoay');
const result = yield lookup('https://play.google.com/music/listen#/album/Bz6wrjczddcj5hurijsv6ohdoay');
result.name.should.equal('Phase 5');
});
});

View file

@ -1,27 +1,27 @@
import 'should';
import deezer from '../../lib/services/deezer';
import * as deezer from '../../lib/services/deezer';
describe('Deezer', function(){
describe('lookupId', function(){
it('should find album by ID', function* (){
let result = yield deezer.lookupId('302127', 'album');
const result = yield deezer.lookupId('302127', 'album');
result.name.should.equal('Discovery');
});
it('should find track by ID', function* (){
let result = yield deezer.lookupId('3135554', 'track');
const result = yield deezer.lookupId('3135554', 'track');
result.name.should.equal('Aerodynamic');
});
});
describe('search', function(){
it('should find album by search', function* (){
let result = yield deezer.search({type: 'album', artist: {name: 'David Guetta'}, name: 'Listen (Deluxe)'});
const result = yield deezer.search({type: 'album', artist: {name: 'David Guetta'}, name: 'Listen (Deluxe)'});
result.name.should.startWith('Listen');
});
it('should find track by search', function* (){
let result = yield deezer.search({type: 'track', artist: {name: 'Deftones'}, album: {name: 'Deftones'}, name: 'Hexagram'});
const result = yield deezer.search({type: 'track', artist: {name: 'Deftones'}, album: {name: 'Deftones'}, name: 'Hexagram'});
result.name.should.equal('Hexagram');
});
});
@ -29,12 +29,12 @@ describe('Deezer', function(){
describe('lookupUrl', function(){
describe('parseUrl', function(){
it('should parse album url into ID', function* (){
let result = yield deezer.parseUrl('http://www.deezer.com/album/302127');
const result = yield deezer.parseUrl('http://www.deezer.com/album/302127');
result.id.should.equal(302127);
});
it('should parse track url into ID', function* (){
let result = yield deezer.parseUrl('http://www.deezer.com/track/3135554');
const result = yield deezer.parseUrl('http://www.deezer.com/track/3135554');
result.id.should.equal(3135554);
});
});

View file

@ -1,39 +1,39 @@
import 'should';
import google from '../../lib/services/google';
import * as google from '../../lib/services/google';
describe('Google Play Music', function(){
describe('lookupId', function(){
it('should find album by ID', function* (){
let result = yield google.lookupId('Byp6lvzimyf74wxi5634ul4tgam', 'album');
const result = yield google.lookupId('Byp6lvzimyf74wxi5634ul4tgam', 'album');
result.name.should.equal('Listen (Deluxe)');
});
it('should find track by ID', function* (){
let result = yield google.lookupId('Tjosptub24g2dft37lforqnudpe', 'track');
const result = yield google.lookupId('Tjosptub24g2dft37lforqnudpe', 'track');
result.name.should.equal('Cherub Rock');
});
});
describe('search', function(){
it('should find album by search', function* (){
let result = yield google.search({type: 'album', artist: {name: 'Jamie xx'}, name: 'In Colour'});
const result = yield google.search({type: 'album', artist: {name: 'Jamie xx'}, name: 'In Colour'});
result.name.should.equal('In Colour');
});
});
describe('lookupUrl', function(){
it('should parse regular url into album ID', function* (){
let result = yield google.parseUrl('https://play.google.com/music/listen#/album/Byp6lvzimyf74wxi5634ul4tgam/Jamie+xx/In+Colour');
const result = yield google.parseUrl('https://play.google.com/music/listen#/album/Byp6lvzimyf74wxi5634ul4tgam/Jamie+xx/In+Colour');
result.id.should.equal('Byp6lvzimyf74wxi5634ul4tgam');
});
it('should parse url without ID into album ID', function* (){
let result = yield google.parseUrl('https://play.google.com/music/listen#/album//Jamie+xx/In+Colour');
const result = yield google.parseUrl('https://play.google.com/music/listen#/album//Jamie+xx/In+Colour');
result.id.should.equal('Bvfmezcj3n42lo4xeuslpclbyrm');
});
it('should parse share url into album ID', function* (){
let result = yield google.parseUrl('https://play.google.com/music/m/Byp6lvzimyf74wxi5634ul4tgam');
const result = yield google.parseUrl('https://play.google.com/music/m/Byp6lvzimyf74wxi5634ul4tgam');
result.id.should.equal('Byp6lvzimyf74wxi5634ul4tgam');
});
});

View file

@ -1,27 +1,27 @@
import 'should';
import itunes from '../../lib/services/itunes';
import * as itunes from '../../lib/services/itunes';
describe('iTunes Music', function(){
describe('lookupId', function(){
it('should find album by ID', function* (){
let result = yield itunes.lookupId('id215206912', 'album');
const result = yield itunes.lookupId('id215206912', 'album');
result.name.should.equal('Peace Orchestra');
});
it('should find track by ID', function* (){
let result = yield itunes.lookupId('id215206958', 'track');
const result = yield itunes.lookupId('id215206958', 'track');
result.name.should.equal('Double Drums');
});
});
describe('search', function(){
it('should find album by search', function* (){
let result = yield itunes.search({type: 'album', artist: {name: 'Deftones'}, name: 'Deftones'});
const result = yield itunes.search({type: 'album', artist: {name: 'Deftones'}, name: 'Deftones'});
result.name.should.equal('Deftones');
});
it('should find track by search', function* (){
let result = yield itunes.search({type: 'track', artist: {name: 'Deftones'}, album: {name: 'Deftones'}, name: 'Hexagram'});
const result = yield itunes.search({type: 'track', artist: {name: 'Deftones'}, album: {name: 'Deftones'}, name: 'Hexagram'});
result.name.should.equal('Hexagram');
});
});
@ -29,12 +29,12 @@ describe('iTunes Music', function(){
describe('lookupUrl', function(){
describe('parseUrl', function(){
it('should parse album url into ID', function* (){
let result = yield itunes.parseUrl('https://itunes.apple.com/us/album/double-drums/id215206912');
const result = yield itunes.parseUrl('https://itunes.apple.com/us/album/double-drums/id215206912');
result.id.should.equal('us215206912');
});
it('should parse track url into ID', function* (){
let result = yield itunes.parseUrl('https://itunes.apple.com/us/album/double-drums/id215206912?i=215206958&uo=4');
const result = yield itunes.parseUrl('https://itunes.apple.com/us/album/double-drums/id215206912?i=215206958&uo=4');
result.id.should.equal('us215206958');
});
});

View file

@ -4,26 +4,26 @@ import * as rdio from '../../lib/services/rdio';
describe('Rdio', function(){
describe('lookupId', function(){
it('should find album by ID', function* (){
let result = yield rdio.lookupId('Qj4NXr0');
const result = yield rdio.lookupId('Qj4NXr0');
result.name.should.equal('Listen (Deluxe)');
});
});
describe('search', function(){
it('should find album by search', function* (){
let result = yield rdio.search({type: 'album', artist: {name: 'David Guetta'}, name: 'Listen (Deluxe)'});
const result = yield rdio.search({type: 'album', artist: {name: 'David Guetta'}, name: 'Listen (Deluxe)'});
result.name.should.equal('Listen (Deluxe)');
});
});
describe('parseUrl', function(){
it('should parse regular url into album object', function* (){
let result = yield rdio.parseUrl('https://www.rdio.com/artist/David_Guetta/album/Listen_(Deluxe)/');
const result = yield rdio.parseUrl('https://www.rdio.com/artist/David_Guetta/album/Listen_(Deluxe)/');
result.name.should.equal('Listen (Deluxe)');
});
it('should parse short url into album object', function* (){
let result = yield rdio.parseUrl('http://rd.io/x/Qj4NXr0/');
const result = yield rdio.parseUrl('http://rd.io/x/Qj4NXr0/');
result.name.should.equal('Listen (Deluxe)');
});
});

View file

@ -1,29 +1,29 @@
import 'should';
import spotify from '../../lib/services/spotify';
import * as spotify from '../../lib/services/spotify';
describe('Spotify', function(){
describe('lookupId', function(){
it('should find album by ID', function* (){
let result = yield spotify.lookupId('77UW17CZFyCaRLHdHeofZu', 'album');
const result = yield spotify.lookupId('77UW17CZFyCaRLHdHeofZu', 'album');
result.name.should.equal('Listen (Deluxe)');
});
it('should find track by ID', function* (){
let result = yield spotify.lookupId('7dS5EaCoMnN7DzlpT6aRn2', 'track');
const result = yield spotify.lookupId('7dS5EaCoMnN7DzlpT6aRn2', 'track');
result.name.should.equal('Take Me To Church');
});
});
describe('search', function(){
it('should find album by search', function* (){
let result = yield spotify.search({type: 'album', artist: {name: 'David Guetta'}, name: 'Listen (Deluxe)'});
const result = yield spotify.search({type: 'album', artist: {name: 'David Guetta'}, name: 'Listen (Deluxe)'});
result.name.should.equal('Listen (Deluxe)');
});
});
describe('parseUrl', function(){
it('should parse url into ID', function* (){
let result = yield spotify.parseUrl('https://play.spotify.com/album/77UW17CZFyCaRLHdHeofZu');
const result = yield spotify.parseUrl('https://play.spotify.com/album/77UW17CZFyCaRLHdHeofZu');
result.id.should.equal('77UW17CZFyCaRLHdHeofZu');
});
});

View file

@ -1,29 +1,29 @@
import 'should';
import xbox from '../../lib/services/xbox';
import * as xbox from '../../lib/services/xbox';
describe('Xbox Music', function(){
describe('lookupId', function(){
it('should find album by ID', function* (){
let result = yield xbox.lookupId('music.8b558d00-0100-11db-89ca-0019b92a3933', 'album');
const result = yield xbox.lookupId('music.8b558d00-0100-11db-89ca-0019b92a3933', 'album');
result.name.should.equal('Muchas Gracias: The Best Of Kyuss');
});
it('should find track by ID', function* (){
let result = yield xbox.lookupId('music.8f558d00-0100-11db-89ca-0019b92a3933', 'track');
const result = yield xbox.lookupId('music.8f558d00-0100-11db-89ca-0019b92a3933', 'track');
result.name.should.equal('Shine');
});
});
describe('search', function(){
it('should find album by search', function* (){
let result = yield xbox.search({type: 'album', artist: {name: 'Kyuss'}, name: 'Muchas Gracias: The Best Of Kyuss'});
const result = yield xbox.search({type: 'album', artist: {name: 'Kyuss'}, name: 'Muchas Gracias: The Best Of Kyuss'});
result.name.should.equal('Muchas Gracias: The Best Of Kyuss');
});
});
describe('lookupUrl', function(){
it('should parse regular url into album ID', function* (){
let result = yield xbox.parseUrl('https://music.xbox.com/album/kyuss/muchas-gracias-the-best-of-kyuss/8b558d00-0100-11db-89ca-0019b92a3933');
const result = yield xbox.parseUrl('https://music.xbox.com/album/kyuss/muchas-gracias-the-best-of-kyuss/8b558d00-0100-11db-89ca-0019b92a3933');
result.id.should.equal('music.8B558D00-0100-11DB-89CA-0019B92A3933');
});
});

View file

@ -1,10 +1,10 @@
import 'should';
import youtube from '../../lib/services/youtube';
import * as youtube from '../../lib/services/youtube';
describe('Youtube', function(){
describe('search', function(){
it('should find album by search', function* (){
let result = yield youtube.search({type: 'track', artist: {name: 'Aesop Rock'}, album: {name: 'Skelethon'}, name: 'Zero Dark Thirty'});
const result = yield youtube.search({type: 'track', artist: {name: 'Aesop Rock'}, album: {name: 'Skeconsthon'}, name: 'Zero Dark Thirty'});
result.name.should.equal('Aesop Rock - Zero Dark Thirty');
});
});