Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"Lob.com",
"printing"
],
"version": "8.0.0",
"version": "8.1.0",
"homepage": "https://github.com/lob/lob-node",
"author": "Lob <support@lob.com> (https://lob.com/)",
"dependencies": {
Expand Down
63 changes: 61 additions & 2 deletions test/bankAccounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ describe('bank accounts', () => {

describe('verify', () => {

it('verifies a bank account', (done) => {
it('verifies a bank account with amounts', (done) => {
const bankAccountId = fixtures.BANK_ACCOUNT.id;
const amounts = [23, 34];
const verifiedBankAccount = fixtures.clone(fixtures.BANK_ACCOUNT, { verified: true });
const verifiedBankAccount = fixtures.clone(fixtures.BANK_ACCOUNT, { verified: true, microdeposit_type: null });

mockLob()
.post('/v1/bank_accounts')
Expand All @@ -142,6 +142,65 @@ describe('bank accounts', () => {
});
});

it('verifies a bank account with descriptor_code', (done) => {
const bankAccountId = fixtures.BANK_ACCOUNT.id;
const verifiedBankAccount = fixtures.clone(fixtures.BANK_ACCOUNT, { verified: true, microdeposit_type: null });

mockLob()
.post('/v1/bank_accounts')
.reply(200, fixtures.clone(fixtures.BANK_ACCOUNT, { microdeposit_type: 'descriptor_code' }));

mockLob()
.post(`/v1/bank_accounts/${ bankAccountId }/verify`)
.reply(200, verifiedBankAccount);

Lob.bankAccounts.create(BANK_ACCOUNT_INPUT, (err, res) => {
if (err) return done(err);
Lob.bankAccounts.verify(res.id, { descriptor_code: 'SM11AA' }, (err2, res2) => {
if (err2) return done(err2);
expect(res2).to.have.property('id');
expect(res2.verified).to.eql(true);
expect(res2.object).to.eql('bank_account');
return done();
});
});
});

});

describe('microdeposit_type', () => {

it('exposes microdeposit_type on a retrieved bank account', (done) => {
const bankAccountId = fixtures.BANK_ACCOUNT.id;

mockLob()
.get(`/v1/bank_accounts/${ bankAccountId}`)
.reply(200, fixtures.BANK_ACCOUNT);

Lob.bankAccounts.retrieve(bankAccountId, (err, res) => {
if (err) return done(err);
expect(res).to.have.property('microdeposit_type');
expect(['amounts', 'descriptor_code']).to.include(res.microdeposit_type);
return done();
});
Comment thread
kevinpjones marked this conversation as resolved.
});

it('microdeposit_type is null once verified', (done) => {
const bankAccountId = fixtures.BANK_ACCOUNT.id;
const verifiedAccount = fixtures.clone(fixtures.BANK_ACCOUNT, { verified: true, microdeposit_type: null });

mockLob()
.get(`/v1/bank_accounts/${ bankAccountId}`)
.reply(200, verifiedAccount);

Lob.bankAccounts.retrieve(bankAccountId, (err, res) => {
if (err) return done(err);
expect(res.verified).to.eql(true);
expect(res.microdeposit_type).to.eql(null);
return done();
});
Comment thread
kevinpjones marked this conversation as resolved.
});

});

});
1 change: 1 addition & 0 deletions test/mocks/fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const BANK_ACCOUNT = {
account_type: 'company',
signatory: 'John Doe',
verified: false,
microdeposit_type: 'amounts',
date_created: '2024-01-16T12:00:00.000Z',
date_modified: '2024-01-16T12:00:00.000Z'
};
Expand Down
Loading