Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
30 changes: 30 additions & 0 deletions test/integration/debits.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,22 @@ module('Debits', {
Testing.DEBIT_ID = debit.get('id');
Testing.DEBIT_URI = debit.get('uri');
Testing.DEBIT_ROUTE = '/marketplaces/' + Testing.MARKETPLACE_ID + '/debits/' + Testing.DEBIT_ID;
}).then(function(){
Testing._createPendingBankAccount().then(function(bankAccount) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this does not need to block on the card creation.

return Balanced.Debit.create({
uri: bankAccount.get('debits_uri'),
appears_on_statement_as: 'Pixie Dust',
amount: 100000,
description: 'Cocaine'
}).save();
}).then(function(debit) {
Testing.PENDING_DEBIT_ID = debit.get('id');
Testing.PENDING_DEBIT_URI = debit.get('uri');
Testing.PENDING_DEBIT_ROUTE = '/marketplaces/' + Testing.MARKETPLACE_ID + '/debits/' + Testing.PENDING_DEBIT_ID;
console.log(debit.get('status'));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mjallday This still returns "succeeded". Any idea why?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

});
});

});
},
teardown: function() {}
Expand Down Expand Up @@ -41,6 +56,21 @@ test('can refund debit', function(assert) {
});
});

test('can refund a pending debit', function(assert) {
var spy = sinon.spy(Balanced.Adapter, "create");

visit(Testing.PENDING_DEBIT_ROUTE)
.click(".refund-debit-button")
.fillIn('#refund-debit .modal-body input[name="dollar_amount"]', "10")
.click('#refund-debit .modal-footer button[name="modal-submit"]')
.then(function() {
assert.ok(spy.calledOnce);
assert.ok(spy.calledWith(Balanced.Refund));
assert.equal(spy.getCall(0).args[2].debit_uri, Testing.PENDING_DEBIT_URI);
assert.equal(spy.getCall(0).args[2].amount, '1000');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should assert that the state of the debit in this test

});
});

test('can edit debit', function(assert) {
var spy = sinon.spy(Balanced.Adapter, "update");

Expand Down
16 changes: 16 additions & 0 deletions test/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,22 @@ var Testing = {
});
},

_createPendingBankAccount: function() {
var self = this;
return Balanced.BankAccount.create({
uri: '/customers/' + self.CUSTOMER_ID + '/bank_accounts',
name: 'Test Account',
account_number: '9900000001',
routing_number: '321174851',
type: 'checking'
}).save().then(function(bankAccount) {
self.BANK_ACCOUNT_ID = bankAccount.get('id');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is going to overwrite the bank account details created by _createBankAccount. i can't see where it's using the globals so i don't know the impact.

self.BANK_ACCOUNT_ROUTE = self.MARKETPLACE_ROUTE +
'/bank_accounts/' + self.BANK_ACCOUNT_ID;
return bankAccount;
});
},

_createReversal: function() {
var self = this;

Expand Down