Save last opened wallet

This commit is contained in:
Yemel Jardi 2014-08-04 15:10:01 -03:00
commit 9b1708b88e
6 changed files with 62 additions and 1 deletions

View file

@ -317,6 +317,20 @@ describe('WalletFactory model', function() {
});
});
it('should clean lastOpened on delete wallet', function(done) {
var wf = new WalletFactory(config, '0.0.1');
var w = wf.create({
name: 'test wallet'
});
wf.storage.setLastOpened(w.id);
wf.delete(w.id, function() {
var last = wf.storage.getLastOpened();
should.equal(last, undefined);
done();
});
});
it('should return false if wallet does not exist', function() {
var opts = {
'requiredCopayers': 2,
@ -343,6 +357,23 @@ describe('WalletFactory model', function() {
wf.read.calledWith(walletId).should.be.true;
});
it('should save lastOpened on create/open a wallet', function() {
var opts = {
'requiredCopayers': 2,
'totalCopayers': 3
};
var wf = new WalletFactory(config, '0.0.1');
var w = wf.create(opts);
var last = wf.storage.getLastOpened();
should.equal(last, w.id);
wf.storage.setLastOpened('other_id');
var wo = wf.open(w.id, opts);
last = wf.storage.getLastOpened();
should.equal(last, w.id);
});
it('should return error if network are differents', function() {
var opts = {
'requiredCopayers': 2,