Skip to content

Commit

Permalink
Add Pdfkiwi constructor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Donovan Lambert committed May 22, 2017
1 parent 2e6f0ee commit d0aa144
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/specs/pdfkiwi.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
const expect = require('chai').expect;
const Pdfkiwi = require('../../src/pdfkiwi');

describe('Pdfkiwi', () => {
describe('constructor', () => {
it('should throw an error when called with missing API credentials', () => {
const _wrapCall = (...args) => (
() => { new Pdfkiwi(...args); } // eslint-disable-line no-new
);

expect(_wrapCall('foo', 'bar')).to.not.throw(/Incomplete Pdf\.kiwi API credentials\./);

expect(_wrapCall()).to.throw(Error, /Incomplete Pdf\.kiwi API credentials\./);
['', null, 0].forEach((wrongArg) => {
expect(_wrapCall(wrongArg, wrongArg)).to.throw(Error, /Incomplete Pdf\.kiwi API credentials\./);
expect(_wrapCall('foo', wrongArg)).to.throw(Error, /Incomplete Pdf\.kiwi API credentials\./);
expect(_wrapCall(wrongArg, 'bar')).to.throw(Error, /Incomplete Pdf\.kiwi API credentials\./);
});
});
});
});

0 comments on commit d0aa144

Please sign in to comment.