combine.fm/test/services/google.js

51 lines
2.1 KiB
JavaScript
Raw Normal View History

2015-06-03 21:45:54 -07:00
import 'should';
2015-08-20 23:22:57 +01:00
import * as google from '../../lib/services/google';
describe('Google Play Music', function(){
describe('lookupId', function(){
2015-06-03 21:45:54 -07:00
it('should find album by ID', function* (){
2015-08-20 23:22:57 +01:00
const result = yield google.lookupId('Byp6lvzimyf74wxi5634ul4tgam', 'album');
2016-01-09 12:27:28 +00:00
result.name.should.equal('Listen');
});
2014-12-13 12:05:47 +00:00
2015-06-03 21:45:54 -07:00
it('should find track by ID', function* (){
2015-08-20 23:22:57 +01:00
const result = yield google.lookupId('Tjosptub24g2dft37lforqnudpe', 'track');
2015-06-03 21:45:54 -07:00
result.name.should.equal('Cherub Rock');
2014-12-13 12:05:47 +00:00
});
});
describe('search', function(){
2015-06-03 21:45:54 -07:00
it('should find album by search', function* (){
2015-08-20 23:22:57 +01:00
const result = yield google.search({type: 'album', artist: {name: 'Jamie xx'}, name: 'In Colour'});
result.name.should.equal('In Colour');
});
it('should find track by search', function* (){
const result = yield google.search({type: 'track', artist: {name: 'Jamie xx'}, albumName: 'In Colour', name: 'Loud Places'});
result.name.should.equal('Loud Places');
});
it('should find awkward track by search', function* (){
2018-04-08 16:31:46 +01:00
const result = yield google.search({type: 'track', artist: {name: 'Jamie xx'}, albumName: 'Loud Places (Remixes)', name: 'Loud Places [Tessela Remix]'});
result.name.should.equal('Loud Places [Tessela Remix]');
});
});
describe('lookupUrl', function(){
2015-06-03 21:45:54 -07:00
it('should parse regular url into album ID', function* (){
2015-08-20 23:22:57 +01:00
const result = yield google.parseUrl('https://play.google.com/music/listen#/album/Byp6lvzimyf74wxi5634ul4tgam/Jamie+xx/In+Colour');
2015-06-03 21:45:54 -07:00
result.id.should.equal('Byp6lvzimyf74wxi5634ul4tgam');
});
2015-06-03 21:45:54 -07:00
it('should parse url without ID into album ID', function* (){
2015-08-20 23:22:57 +01:00
const result = yield google.parseUrl('https://play.google.com/music/listen#/album//Jamie+xx/In+Colour');
result.id.should.equal('Bvfmezcj3n42lo4xeuslpclbyrm');
});
2015-06-03 21:45:54 -07:00
it('should parse share url into album ID', function* (){
2015-08-20 23:22:57 +01:00
const result = yield google.parseUrl('https://play.google.com/music/m/Byp6lvzimyf74wxi5634ul4tgam');
2015-06-03 21:45:54 -07:00
result.id.should.equal('Byp6lvzimyf74wxi5634ul4tgam');
});
});
});