Skip to content

Commit

Permalink
add another test
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Chen committed Jul 8, 2020
1 parent c7fb5ee commit 1e52247
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
4 changes: 3 additions & 1 deletion lib/PlaidClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ const DEFAULT_VERSION = '2019-05-29';
// Client(String, String, String, String, Object?)
function Client(configs) {
if (!R.is(Object, configs)) {
throw new Error('Unexpected parameter type. Refer to https://github.com/plaid/plaid-node for how to create a Plaid client.');
throw new Error('Unexpected parameter type. ' +
'Refer to https://github.com/plaid/plaid-node ' +
'for how to create a Plaid client.');
}

if (R.isNil(configs.clientID)) {
Expand Down
36 changes: 22 additions & 14 deletions test/PlaidClientTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,28 @@ describe('plaid.Client', () => {
options: {
version: '2019-05-29',
},
}
};

let pCl;
beforeEach(() => {
pCl = new plaid.Client(configs);
});

describe('constructor', () => {
it('throws for invalid parameter', () => {
expect(() => {
plaid.Client('client_id');
}).to.throwException(e => {
expect(e).to.be.ok();
expect(e.message).to.equal('Unexpected parameter type. Refer to https://github.com/plaid/plaid-node for how to create a Plaid client.');
});
});

it('throws for missing client_id', () => {
expect(() => {
plaid.Client({
...configs,
plaid.Client(R.merge(configs, {
clientID: null,
});
}));
}).to.throwException(e => {
expect(e).to.be.ok();
expect(e.message).to.equal('Missing Plaid "client_id"');
Expand All @@ -46,10 +54,9 @@ describe('plaid.Client', () => {

it('throws for missing secret', () => {
expect(() => {
plaid.Client({
...configs,
plaid.Client(R.merge(configs, {
secret: null,
});
}));
}).to.throwException(e => {
expect(e).to.be.ok();
expect(e.message).to.equal('Missing Plaid "secret"');
Expand All @@ -58,10 +65,9 @@ describe('plaid.Client', () => {

it('throws for invalid environment', () => {
expect(() => {
plaid.Client({
...configs,
plaid.Client(R.merge(configs, {
env: 'gingham',
});
}));
}).to.throwException(e => {
expect(e).to.be.ok();
expect(e.message).to.equal('Invalid Plaid environment');
Expand All @@ -80,18 +86,20 @@ describe('plaid.Client', () => {
it('succeeds with all arguments', () => {
expect(() => {
R.forEachObjIndexed(env => {
plaid.Client(configs);
plaid.Client(R.merge(configs, {
env: env,
}));
}, plaid.environments);
}).not.to.throwException();
});

it('succeeds without any options', () => {
expect(() => {
R.forEachObjIndexed(env => {
plaid.Client({
...configs,
plaid.Client(R.merge(configs, {
options: null,
});
env: env,
}));
}, plaid.environments);
}).not.to.throwException();
});
Expand Down

0 comments on commit 1e52247

Please sign in to comment.