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(){
|
2018-04-30 22:20:01 +01:00
|
|
|
it('should find album by ID', async function (){
|
|
|
|
const result = await 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
|
|
|
});
|
|
|
|
|
2018-04-30 22:20:01 +01:00
|
|
|
it('should find track by ID', async function (){
|
|
|
|
const result = await 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(){
|
2018-04-30 22:20:01 +01:00
|
|
|
it('should find album by search', async function (){
|
|
|
|
const result = await itunes.search({type: 'album', artist: {name: 'Deftones'}, name: 'White Pony'});
|
2016-05-23 20:18:16 +01:00
|
|
|
result.name.should.equal('White Pony');
|
2014-12-11 19:53:12 +00:00
|
|
|
});
|
|
|
|
|
2018-04-30 22:20:01 +01:00
|
|
|
it('should find awkward album by search', async function (){
|
|
|
|
const result = await itunes.search({type: 'album', artist: {name: 'Anavitória'}, name: 'Fica'});
|
2017-05-07 22:16:43 +01:00
|
|
|
result.name.should.equal('Fica (feat. Matheus & Kauan) - Single');
|
|
|
|
});
|
|
|
|
|
2018-04-30 22:20:01 +01:00
|
|
|
it('should find track by search', async function (){
|
|
|
|
const result = await itunes.search({type: 'track', artist: {name: 'Deftones'}, albumName: '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(){
|
2018-04-30 22:20:01 +01:00
|
|
|
it('should parse album url into ID', async function (){
|
|
|
|
const result = await 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
|
|
|
});
|
|
|
|
|
2018-04-30 22:20:01 +01:00
|
|
|
it('should parse track url into ID', async function (){
|
|
|
|
const result = await 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
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|