Commit 152d92ea by Ben Drucker

Provide a client constructor as the base export

parent 40d8e567
'use strict';
var Client = require('./client');
module.exports = function (key) {
return new Client({
key: key
});
};
module.exports.Client = Client;
'use strict'; 'use strict';
var expect = require('chai').expect; var expect = require('chai').expect;
var nock = require('nock'); var nock = require('nock');
var ClearbitClient = require('../src/client'); var clearbit = require('../');
var pkg = require('../package.json'); var Client = clearbit.Client;
var pkg = require('../package.json');
describe('ClearbitClient', function () { describe('Client', function () {
var client; var client;
beforeEach(function () { beforeEach(function () {
client = new ClearbitClient({ client = clearbit('k');
key: 'k'
});
}); });
describe('Constructor', function () { describe('Constructor', function () {
it('must be called with new', function () { it('must be called with new', function () {
expect(ClearbitClient).to.throw(/called with new/); expect(Client).to.throw(/called with new/);
}); });
it('must provide an API key', function () { it('must provide an API key', function () {
expect(function () { expect(function () {
return new ClearbitClient(); return new Client();
}) })
.to.throw(/API key/); .to.throw(/API key/);
}); });
it('configures the API key', function () { it('configures the API key', function () {
expect(new ClearbitClient({key: 'k'})).to.have.property('key', 'k'); expect(new Client({key: 'k'})).to.have.property('key', 'k');
}); });
}); });
...@@ -123,4 +122,4 @@ describe('ClearbitClient', function () { ...@@ -123,4 +122,4 @@ describe('ClearbitClient', function () {
}); });
}); });
\ No newline at end of file
...@@ -2,8 +2,7 @@ ...@@ -2,8 +2,7 @@
var expect = require('chai').expect; var expect = require('chai').expect;
var nock = require('nock'); var nock = require('nock');
var Client = require('../src/client'); var Company = require('../')('k').Company;
var Company = new Client({key: 'k'}).Company;
describe('Company', function () { describe('Company', function () {
......
...@@ -2,8 +2,7 @@ ...@@ -2,8 +2,7 @@
var expect = require('chai').expect; var expect = require('chai').expect;
var nock = require('nock'); var nock = require('nock');
var Client = require('../src/client'); var Person = require('../')('k').Person;
var Person = new Client({key: 'k'}).Person;
describe('Person', function () { describe('Person', function () {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment