@noise-machines/lyricist
Advanced tools
Comparing version 2.2.0 to 2.3.0
@@ -101,3 +101,3 @@ const fetch = require('node-fetch'); | ||
async search(query, { page = 1 }) { | ||
async search(query, { page = 1 } = {}) { | ||
if (!query) throw new Error('No query was provided to lyricist.search()'); | ||
@@ -104,0 +104,0 @@ |
@@ -0,1 +1,2 @@ | ||
/* eslint-env jest */ | ||
const Lyricist = require('./'); | ||
@@ -9,3 +10,3 @@ require('dotenv').config(); | ||
expect(() => { | ||
new Lyricist(); | ||
new Lyricist(); // eslint-disable-line no-new | ||
}).toThrow(); | ||
@@ -128,4 +129,4 @@ }); | ||
test('load an artist', async () => { | ||
const result = await lyricist.artist(2); | ||
expect(result.api_path).toEqual('/artists/2'); | ||
const result = await lyricist.artist(644); | ||
expect(result.api_path).toEqual('/artists/644'); | ||
}); | ||
@@ -154,3 +155,3 @@ }); | ||
test('load artist songs', async () => { | ||
const result = await lyricist.songsByArtist(2); | ||
const result = await lyricist.songsByArtist(644); | ||
expect(result[0]).toHaveProperty('title'); | ||
@@ -161,3 +162,3 @@ }); | ||
const perPage = 10; | ||
const result = await lyricist.songsByArtist(2, { perPage }); | ||
const result = await lyricist.songsByArtist(644, { perPage }); | ||
expect(result.length).toEqual(perPage); | ||
@@ -168,6 +169,5 @@ }); | ||
const page = 2; | ||
const result = await lyricist.songsByArtist(2, { page }); | ||
expect(result.find(t => t.title === 'Addicted to the Game').id).toEqual( | ||
3129, | ||
); | ||
const result = await lyricist.songsByArtist(644, { page }); | ||
const song = result.find(t => t.title === 'Brother Sport'); | ||
expect(song.id).toEqual(77001); | ||
}); | ||
@@ -177,4 +177,4 @@ | ||
const sort = 'popularity'; | ||
const result = await lyricist.songsByArtist(2); | ||
const resultWithSort = await lyricist.songsByArtist(2, { sort }); | ||
const result = await lyricist.songsByArtist(644); | ||
const resultWithSort = await lyricist.songsByArtist(644, { sort }); | ||
expect(result).toBeInstanceOf(Array); | ||
@@ -202,3 +202,11 @@ expect(resultWithSort).toBeInstanceOf(Array); | ||
}); | ||
test('page option', async () => { | ||
const firstPage = await lyricist.search('animal collective', { page: 1 }); | ||
const secondPage = await lyricist.search('animal collective', { | ||
page: 2, | ||
}); | ||
expect(firstPage[0].title).not.toEqual(secondPage[0].title); | ||
}); | ||
}); | ||
}); |
@@ -25,5 +25,6 @@ 'use strict'; | ||
Authorization: `Bearer ${_this.accessToken}` | ||
}; | ||
// Fetch result and parse it as JSON | ||
};const body = yield fetch(url, { headers }); | ||
// Fetch result and parse it as JSON | ||
const body = yield fetch(url, { headers }); | ||
const result = yield body.json(); | ||
@@ -143,3 +144,3 @@ | ||
search(query, { page = 1 }) { | ||
search(query, { page = 1 } = {}) { | ||
var _this7 = this; | ||
@@ -146,0 +147,0 @@ |
{ | ||
"name": "@noise-machines/lyricist", | ||
"public": true, | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"description": "Fetches song lyrics using the Genius.com API and website.", | ||
@@ -54,2 +54,2 @@ "main": "lib/index.js", | ||
} | ||
} | ||
} |
Copyleft License
License(Experimental) Copyleft license information was found
Found 1 instance in 1 package
No License Found
License(Experimental) License information could not be found
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found
Found 1 instance in 1 package
455
23196
9
3