mirror of https://github.com/BTCPrivate/copay.git
paypro: fix mock server. unit controller tests.
This commit is contained in:
parent
b89ad8f3cc
commit
1c4d292a96
|
@ -93,13 +93,18 @@ x509.der = new Buffer(x509.der, 'base64');
|
||||||
x509.pem = new Buffer(x509.pem, 'base64');
|
x509.pem = new Buffer(x509.pem, 'base64');
|
||||||
|
|
||||||
function startServer(cb) {
|
function startServer(cb) {
|
||||||
if (G.$http.__server) {
|
if (G.$http && G.$http.__server) {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
return cb(null, G.$http.__server);
|
return cb(null, G.$http.__server);
|
||||||
}, 1);
|
}, 1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var old;
|
||||||
|
if (G.$http) {
|
||||||
|
old = G.$http;
|
||||||
|
}
|
||||||
|
|
||||||
var server = {
|
var server = {
|
||||||
POST: {
|
POST: {
|
||||||
|
|
||||||
|
@ -271,9 +276,12 @@ function startServer(cb) {
|
||||||
return cb(null, res, res.body);
|
return cb(null, res, res.body);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
listen: function() {
|
listen: function(port, cb) {
|
||||||
|
if (cb) return cb();
|
||||||
},
|
},
|
||||||
close: function() {
|
close: function(cb) {
|
||||||
|
if (old) G.$http = old;
|
||||||
|
return cb();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -168,8 +168,9 @@ describe('PayPro (in Wallet) model', function() {
|
||||||
should.exist(ntxid);
|
should.exist(ntxid);
|
||||||
console.log('Sent TX proposal to other copayers:');
|
console.log('Sent TX proposal to other copayers:');
|
||||||
console.log([ntxid, ca]);
|
console.log([ntxid, ca]);
|
||||||
server.close();
|
server.close(function() {
|
||||||
done();
|
done();
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
console.log('Sending TX to merchant server:');
|
console.log('Sending TX to merchant server:');
|
||||||
console.log(ntxid);
|
console.log(ntxid);
|
||||||
|
@ -177,9 +178,10 @@ describe('PayPro (in Wallet) model', function() {
|
||||||
should.exist(txid);
|
should.exist(txid);
|
||||||
console.log('TX sent:');
|
console.log('TX sent:');
|
||||||
console.log([ntxid, ca]);
|
console.log([ntxid, ca]);
|
||||||
server.close();
|
server.close(function() {
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -10,6 +10,7 @@ saveAs = function(o) {
|
||||||
saveAsLastCall = o;
|
saveAsLastCall = o;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var startServer = require('../../mocks/FakePayProServer');
|
||||||
|
|
||||||
describe("Unit: Controllers", function() {
|
describe("Unit: Controllers", function() {
|
||||||
var invalidForm = {
|
var invalidForm = {
|
||||||
|
@ -18,6 +19,8 @@ describe("Unit: Controllers", function() {
|
||||||
|
|
||||||
var scope;
|
var scope;
|
||||||
|
|
||||||
|
var server;
|
||||||
|
|
||||||
beforeEach(module('copayApp.services'));
|
beforeEach(module('copayApp.services'));
|
||||||
beforeEach(module('copayApp.controllers'));
|
beforeEach(module('copayApp.controllers'));
|
||||||
|
|
||||||
|
@ -217,6 +220,15 @@ describe("Unit: Controllers", function() {
|
||||||
sinon.assert.callCount(scope.loadTxs, 1);
|
sinon.assert.callCount(scope.loadTxs, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('#start the example server', function(done) {
|
||||||
|
startServer(function(err, s) {
|
||||||
|
if (err) return done(err);
|
||||||
|
server = s;
|
||||||
|
server.uri = 'https://localhost:8080/-';
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('should create a payment protocol transaction proposal', function() {
|
it('should create a payment protocol transaction proposal', function() {
|
||||||
var uri = 'bitcoin:1JqniWpWNA6Yvdivg3y9izLidETnurxRQm?amount=0.00001000&r=https://localhost:8080/-/request';
|
var uri = 'bitcoin:1JqniWpWNA6Yvdivg3y9izLidETnurxRQm?amount=0.00001000&r=https://localhost:8080/-/request';
|
||||||
sendForm.address.$setViewValue(uri);
|
sendForm.address.$setViewValue(uri);
|
||||||
|
@ -243,6 +255,12 @@ describe("Unit: Controllers", function() {
|
||||||
sinon.assert.callCount(spy, 1);
|
sinon.assert.callCount(spy, 1);
|
||||||
sinon.assert.callCount(spy2, 1);
|
sinon.assert.callCount(spy2, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('#stop the example server', function(done) {
|
||||||
|
server.close(function() {
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Unit: Version Controller", function() {
|
describe("Unit: Version Controller", function() {
|
||||||
|
|
Loading…
Reference in New Issue