refactor WalletFactory test to use sinon instead of mocks WIP

This commit is contained in:
Matias Alejo Garcia 2014-09-13 10:25:13 -03:00
commit c3574ae57f
9 changed files with 223 additions and 114 deletions

View file

@ -12,7 +12,7 @@ function Storage(opts) {
this.__uniqueid = ++id;
if (opts.password)
this._setPassphrase(opts.password);
this.setPassphrase(opts.password);
try {
this.storage = opts.storage || localStorage;
@ -33,7 +33,7 @@ Storage.prototype._getPassphrase = function() {
return pps[this.__uniqueid];
}
Storage.prototype._setPassphrase = function(password) {
Storage.prototype.setPassphrase = function(password) {
pps[this.__uniqueid] = password;
}
@ -231,6 +231,7 @@ Storage.prototype.getWallets = function(cb) {
Storage.prototype.deleteWallet = function(walletId, cb) {
preconditions.checkArgument(walletId);
preconditions.checkArgument(cb);
var err;
var toDelete = {};
toDelete['nameFor::' + walletId] = 1;
@ -245,11 +246,15 @@ Storage.prototype.deleteWallet = function(walletId, cb) {
});
var l = toDelete.length,
i = 0;
j = 0;
if (!l)
return cb(new Error('WNOTFOUND: Wallet not found'));
for (var i in toDelete) {
this.removeGlobal(i, function() {
if (++i == l)
return cb();
if (++j == l)
return cb(err);
});
}
};