qobuz
Version:
Qobuz client library for Node.js
42 lines (34 loc) • 1.34 kB
JavaScript
;
const chai = require('chai');
const chaiAsPromised = require('chai-as-promised');
const sinon = require('sinon');
const sinonChai = require('sinon-chai');
const request = require('request');
const Qobuz = require('../../../lib');
chai.should();
chai.use(chaiAsPromised);
chai.use(sinonChai);
describe('Qobuz', function () {
const appId = '100000000';
describe('Genre', function () {
describe('Get', function () {
it('should throw an error for undefined genre ID', function (done) {
const client = new Qobuz(appId);
client.genre.get().should.be.rejectedWith('get() requires a genre ID.').and.notify(done);
});
it('should return genre in JSON', function (done) {
const client = new Qobuz(appId);
const expected = require('./get.json');
const stub = sinon.stub(request, 'get').callsFake((options, callback) => callback(null, { statusCode: 200 }, expected));
client.genre.get('64').should.eventually.deep.equal(expected).and.notify((err) => {
stub.restore();
stub.should.have.been.calledWith({
uri: 'http://www.qobuz.com/api.json/0.2/genre/get?app_id=100000000&genre_id=64',
json: true
});
done(err);
});
});
});
});
});