paypro: controller unit tests for payment protocol.

This commit is contained in:
Christopher Jeffrey 2014-07-29 17:28:47 -07:00 committed by Manuel Araoz
parent 4cbc9ebf63
commit b89ad8f3cc
3 changed files with 29 additions and 1 deletions

View File

@ -1027,7 +1027,8 @@ Wallet.prototype.createPaymentTxSync = function(options, merchantData, unspent)
var outs = [];
merchantData.pr.pd.outputs.forEach(function(output) {
outs.push({
address: self.getAddressesStr()[0] || '1NGYre1pSqTnCXaqN5gLQ1e2KNTJXjDhtF', // dummy address
address: self.getAddressesStr()[0]
|| 'mfWxJ45yp2SFn7UciZyNpvDKrzbhyfKrY8', // dummy address (testnet 0 * hash160)
amountSatStr: '0' // dummy amount
});
});

View File

@ -20,6 +20,7 @@ var TransactionBuilder = bitcore.TransactionBuilder;
var Transaction = bitcore.Transaction;
var Address = bitcore.Address;
var PayPro = bitcore.PayPro;
var startServer = require('./mocks/FakePayProServer');
var G = is_browser ? window : global;
G.SSL_UNTRUSTED = true;

View File

@ -217,6 +217,32 @@ describe("Unit: Controllers", function() {
sinon.assert.callCount(scope.loadTxs, 1);
});
it('should create a payment protocol transaction proposal', function() {
var uri = 'bitcoin:1JqniWpWNA6Yvdivg3y9izLidETnurxRQm?amount=0.00001000&r=https://localhost:8080/-/request';
sendForm.address.$setViewValue(uri);
sendForm.amount.$setViewValue(1000);
scope.wallet.totalCopayers = scope.wallet.requiredCopayers = 3;
var spy = sinon.spy(scope.wallet, 'createTx');
var spy2 = sinon.spy(scope.wallet, 'sendTx');
scope.submitForm(sendForm);
sinon.assert.callCount(spy, 1);
sinon.assert.callCount(spy2, 0);
});
it('should create and send a payment protocol transaction proposal', function() {
var uri = 'bitcoin:1JqniWpWNA6Yvdivg3y9izLidETnurxRQm?amount=0.00001000&r=https://localhost:8080/-/request';
sendForm.address.$setViewValue(uri);
sendForm.amount.$setViewValue(1000);
scope.wallet.totalCopayers = scope.wallet.requiredCopayers = 1;
var spy = sinon.spy(scope.wallet, 'createTx');
var spy2 = sinon.spy(scope.wallet, 'sendTx');
scope.submitForm(sendForm);
sinon.assert.callCount(spy, 1);
sinon.assert.callCount(spy2, 1);
});
});
describe("Unit: Version Controller", function() {