Update tests
This commit is contained in:
parent
2989fe1da4
commit
0623c87727
5 changed files with 19 additions and 27 deletions
|
|
@ -1,6 +1,5 @@
|
|||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
|
||||
var FakeSocket = function (url, opts) {
|
||||
|
|
@ -13,7 +12,19 @@ var FakeSocket = function (url, opts) {
|
|||
}, 0);
|
||||
}
|
||||
|
||||
util.inherits(FakeSocket, EventEmitter);
|
||||
var inherits = function(ctor, superCtor) {
|
||||
ctor.super_ = superCtor;
|
||||
ctor.prototype = Object.create(superCtor.prototype, {
|
||||
constructor: {
|
||||
value: ctor,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
inherits(FakeSocket, EventEmitter);
|
||||
|
||||
FakeSocket.prototype.removeEventListener = function() {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ var FakeWallet = function() {
|
|||
return true;
|
||||
}
|
||||
};
|
||||
this.blockchain = {subscribed: [], subscribe: function(){}};
|
||||
|
||||
this.privateKey = new FakePrivateKey();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -6,11 +6,7 @@ var sinon = require('sinon');
|
|||
var bitcore = bitcore || require('bitcore');
|
||||
var FakeSocket = require('./mocks/FakeBlockchainSocket');
|
||||
|
||||
try {
|
||||
var copay = require('./copay'); //browser
|
||||
} catch (e) {
|
||||
var copay = require('../copay'); //node
|
||||
}
|
||||
var copay = copay || require('../copay');
|
||||
var Buffer = bitcore.Buffer;
|
||||
var Insight = copay.Insight;
|
||||
|
||||
|
|
@ -144,7 +140,7 @@ describe('Insight model', function() {
|
|||
sinon.stub(blockchain, "requestPost", function(url, data, cb) {
|
||||
url.should.be.equal('/api/tx/send');
|
||||
var res = {statusCode: 200};
|
||||
var body = JSON.stringify({txid: 1234});
|
||||
var body = {txid: 1234};
|
||||
setTimeout(function() {
|
||||
cb(null, res, body);
|
||||
}, 0);
|
||||
|
|
@ -283,7 +279,7 @@ describe('Insight model', function() {
|
|||
data.addrs.should.be.equal('2NATQJnaQe2CUKLyhL1zdNkttJM1dUH9HaM,2NE9hTCffeugo5gQtfB4owq98gyTeWC56yb,2N9D5bcCQ2bPWUDByQ6Qb5bMgMtgsk1rw3x');
|
||||
setTimeout(function() {
|
||||
var res = {statusCode: 200};
|
||||
var body = JSON.stringify(UNSPENT);
|
||||
var body = UNSPENT;
|
||||
cb(null, res, body);
|
||||
}, 0);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ describe('Network / Async', function() {
|
|||
fakeSocket.emit = function() {};
|
||||
fakeSocket.on = function() {};
|
||||
fakeSocket.disconnect = function() {};
|
||||
fakeSocket.removeAllListeners = function() {};
|
||||
n.createSocket = function() {
|
||||
return fakeSocket;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ describe("Unit: controllerUtils", function() {
|
|||
|
||||
|
||||
it(' should call updateAddressList ', inject(function(controllerUtils, $rootScope) {
|
||||
$rootScope.wallet = new FakeWallet();
|
||||
var spy = sinon.spy(controllerUtils, 'updateAddressList');
|
||||
controllerUtils.updateGlobalAddresses();
|
||||
sinon.assert.callCount(spy, 1);
|
||||
|
|
@ -77,24 +78,6 @@ describe("Unit: controllerUtils", function() {
|
|||
controllerUtils.updateGlobalAddresses();
|
||||
expect($rootScope.addrInfos[0].address).to.be.equal(Waddr);;
|
||||
}));
|
||||
|
||||
it('should set System Event Handlers', inject(function(controllerUtils, $rootScope, Socket) {
|
||||
var spy = sinon.spy(Socket, 'sysOn');
|
||||
$rootScope.wallet = new FakeWallet();
|
||||
controllerUtils.updateGlobalAddresses();
|
||||
sinon.assert.callCount(spy, 5);
|
||||
['error', 'reconnect_error', 'reconnect_failed', 'connect', 'reconnect'].forEach(function(e) {
|
||||
sinon.assert.calledWith(spy, e);
|
||||
});
|
||||
}));
|
||||
|
||||
it('should set Address Event Handlers', inject(function(controllerUtils, $rootScope, Socket) {
|
||||
var spy = sinon.spy(Socket, 'on');
|
||||
$rootScope.wallet = new FakeWallet();
|
||||
var Waddr = Object.keys($rootScope.wallet.balanceByAddr)[0];
|
||||
controllerUtils.updateGlobalAddresses();
|
||||
sinon.assert.calledWith(spy, Waddr);
|
||||
}));
|
||||
});
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue