Skip to content
Open
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
28 changes: 28 additions & 0 deletions test/integration/debits.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@ module('Debits', {
Testing.DEBIT_URI = debit.get('uri');
Testing.DEBIT_ROUTE = '/marketplaces/' + Testing.MARKETPLACE_ID + '/debits/' + Testing.DEBIT_ID;
});
Testing._createPendingBankAccount().then(function(bankAccount) {
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 = 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;
});
});
},
teardown: function() {}
Expand Down Expand Up @@ -41,6 +54,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(Testing.PENDING_DEBIT.get('status'), 'pending');
assert.equal($('#refund-debit').is(':visible'), true);
});
});

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

Expand Down
18 changes: 18 additions & 0 deletions test/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var Testing = {
MARKETPLACE_ID: null,
CARD_ID: null,
BANK_ACCOUNT_ID: null,
PENDING_BANK_ACCOUNT_ID: null,
CREDIT_ID: null,
CUSTOMER_ID: null,
DEBIT_ID: null,
Expand All @@ -16,6 +17,7 @@ var Testing = {
ACTIVITY_ROUTE: null,
ADD_CUSTOMER_ROUTE: null,
BANK_ACCOUNT_ROUTE: null,
PENDING_BANK_ACCOUNT_ROUTE: null,
CARD_ROUTE: null,
CREDIT_ROUTE: null,
CUSTOMER_ROUTE: null,
Expand Down Expand Up @@ -184,6 +186,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.PENDING_BANK_ACCOUNT_ID = bankAccount.get('id');
self.PENDING_BANK_ACCOUNT_ROUTE = self.MARKETPLACE_ROUTE +
'/bank_accounts/' + self.PENDING_BANK_ACCOUNT_ID;
return bankAccount;
});
},

_createReversal: function() {
var self = this;

Expand Down