2015-06-03 21:45:54 -07:00
|
|
|
import 'should';
|
2015-08-20 23:22:57 +01:00
|
|
|
import * as itunes from '../../lib/services/itunes';
|
2014-12-11 19:53:12 +00:00
|
|
|
|
|
|
|
describe('iTunes 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 itunes.lookupId('id215206912', 'album');
|
2015-06-03 21:45:54 -07:00
|
|
|
result.name.should.equal('Peace Orchestra');
|
2014-12-11 19:53:12 +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 itunes.lookupId('id215206958', 'track');
|
2015-06-03 21:45:54 -07:00
|
|
|
result.name.should.equal('Double Drums');
|
2014-12-11 19:53:12 +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 itunes.search({type: 'album', artist: {name: 'Deftones'}, name: 'Deftones'});
|
2015-06-03 21:45:54 -07:00
|
|
|
result.name.should.equal('Deftones');
|
2014-12-11 19:53:12 +00:00
|
|
|
});
|
|
|
|
|
2015-06-03 21:45:54 -07:00
|
|
|
it('should find track by search', function* (){
|
2015-08-20 23:22:57 +01:00
|
|
|
const result = yield itunes.search({type: 'track', artist: {name: 'Deftones'}, album: {name: 'Deftones'}, name: 'Hexagram'});
|
2015-06-03 21:45:54 -07:00
|
|
|
result.name.should.equal('Hexagram');
|
2014-12-11 19:53:12 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('lookupUrl', function(){
|
|
|
|
describe('parseUrl', function(){
|
2015-06-03 21:45:54 -07:00
|
|
|
it('should parse album url into ID', function* (){
|
2015-08-20 23:22:57 +01:00
|
|
|
const result = yield itunes.parseUrl('https://itunes.apple.com/us/album/double-drums/id215206912');
|
2015-06-03 21:45:54 -07:00
|
|
|
result.id.should.equal('us215206912');
|
2014-12-11 19:53:12 +00:00
|
|
|
});
|
|
|
|
|
2015-06-03 21:45:54 -07:00
|
|
|
it('should parse track url into ID', function* (){
|
2015-08-20 23:22:57 +01:00
|
|
|
const result = yield itunes.parseUrl('https://itunes.apple.com/us/album/double-drums/id215206912?i=215206958&uo=4');
|
2015-06-03 21:45:54 -07:00
|
|
|
result.id.should.equal('us215206958');
|
2014-12-11 19:53:12 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|