Fixes: tests. Added karma and mocha tests.

This commit is contained in:
Gustavo Maximiliano Cortez 2014-08-07 20:07:41 -03:00
commit 8ad1fa7b02
7 changed files with 40 additions and 9 deletions

View file

@ -75,14 +75,16 @@ angular.module('copayApp.controllers').controller('SidebarController',
}
$scope.checkIfWarning = function() {
if (!$rootScope.wallet.isLocked) {
if ($rootScope.wallet && !$rootScope.wallet.isLocked) {
controllerUtils.redirIfLogged();
}
};
$scope.ignoreLocked = function() {
$rootScope.wallet.isLocked = false;
controllerUtils.redirIfLogged();
if ($rootScope.wallet) {
$rootScope.wallet.isLocked = false;
controllerUtils.redirIfLogged();
}
};
});

View file

@ -43,6 +43,7 @@ function Wallet(opts) {
this.id = opts.id || Wallet.getRandomId();
this.name = opts.name;
this.isLocked = false;
this.verbose = opts.verbose;
this.publicKeyRing.walletId = this.id;
@ -431,7 +432,6 @@ Wallet.prototype.netStart = function(callback) {
var self = this;
var net = this.network;
this._checkLocked();
net.removeAllListeners();
net.on('connect', self._handleConnect.bind(self));
@ -464,6 +464,7 @@ Wallet.prototype.netStart = function(callback) {
self.scheduleConnect();
self.emit('txProposalsUpdated');
}, 10);
self._checkLocked();
});
};
@ -1017,6 +1018,9 @@ Wallet.prototype.indexDiscovery = function(start, change, cosigner, gap, cb) {
Wallet.prototype.disconnect = function() {
this.log('## DISCONNECTING');
if (!this.isLocked) {
this.closeIfOpen();
}
this.network.disconnect();
};

View file

@ -21,10 +21,7 @@ angular.module('copayApp.services')
}
};
root.logout = function() {
if (!$rootScope.wallet.isLocked) {
$rootScope.wallet.closeIfOpen();
}
root.logout = function() {
Socket.removeAllListeners();
$rootScope.wallet = null;