fix tests and stringify for localstorage

This commit is contained in:
Matias Alejo Garcia 2014-08-15 12:43:43 -04:00
commit 18aadede29
9 changed files with 75 additions and 76 deletions

View file

@ -11,8 +11,8 @@ FakeStorage.prototype._setPassphrase = function(password) {
this.storage.passphrase = password;
};
FakeStorage.prototype.setGlobal = function(id, payload) {
this.storage[id] = payload;
FakeStorage.prototype.setGlobal = function(id, v) {
this.storage[id] = typeof v === 'object' ? JSON.stringify(v) : v;
};
FakeStorage.prototype.getGlobal = function(id) {

View file

@ -41,7 +41,7 @@ describe('WalletLock model', function() {
storage.sessionId = 'xxx';
(function() {
new WalletLock(storage, 'walletId')
}).should.throw('adquire lock');
}).should.throw('already open');
});
it('should not fail if locked by me', function() {
@ -60,7 +60,10 @@ describe('WalletLock model', function() {
it('should not fail if expired', function() {
var s = new Storage();
var w = new WalletLock(s, 'walletId');
s.storage[Object.keys(s.storage)[0]].expireTs = Date.now() - 60 * 6 * 1000;
var k = Object.keys(s.storage)[0];
var v = JSON.parse(s.storage[k]);
v.expireTs = Date.now() - 60 * 6 * 1000;
s.storage[k] = JSON.stringify(v);
s.sessionId = 'xxx';
var w2 = new WalletLock(s, 'walletId')