diff --git a/package-lock.json b/package-lock.json index 2b424b1..ae6eddf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "lob", - "version": "7.1.0", + "version": "8.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "lob", - "version": "7.1.0", + "version": "8.1.0", "license": "MIT", "dependencies": { "axios": "^1.16.1", diff --git a/package.json b/package.json index 1816bf5..c35c5c5 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "Lob.com", "printing" ], - "version": "8.0.0", + "version": "8.1.0", "homepage": "https://github.com/lob/lob-node", "author": "Lob (https://lob.com/)", "dependencies": { diff --git a/test/bankAccounts.js b/test/bankAccounts.js index e7c02be..a2fcb72 100644 --- a/test/bankAccounts.js +++ b/test/bankAccounts.js @@ -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') @@ -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(); + }); + }); + + 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(); + }); + }); + }); }); diff --git a/test/mocks/fixtures.js b/test/mocks/fixtures.js index 422573a..e296128 100644 --- a/test/mocks/fixtures.js +++ b/test/mocks/fixtures.js @@ -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' };