rm storage.storage to storage.db
This commit is contained in:
parent
c4c7dc8eb1
commit
028a300012
7 changed files with 39 additions and 34 deletions
|
|
@ -7,11 +7,10 @@ var timeStamp = Date.now();
|
|||
describe('Storage model', function() {
|
||||
|
||||
var s;
|
||||
beforeEach(function() {
|
||||
beforeEach(function(done) {
|
||||
s = new Storage(requireMock('FakeLocalStorage').storageParams);
|
||||
s.setPassphrase('mysupercoolpassword');
|
||||
s.storage.clear();
|
||||
s.sessionStorage.clear();
|
||||
s.clearAll(done);
|
||||
});
|
||||
|
||||
|
||||
|
|
@ -22,7 +21,7 @@ describe('Storage model', function() {
|
|||
it('should fail when encrypting without a password', function() {
|
||||
var s2 = new Storage(requireMock('FakeLocalStorage').storageParams);
|
||||
(function() {
|
||||
var params = _.clone(require('./mocks/FakeLocalStorage').storageParams);
|
||||
var params = _.clone(requireMock('FakeLocalStorage').storageParams);
|
||||
params.password = undefined;
|
||||
new Storage(params);
|
||||
}).should.throw('Illegal Argument');
|
||||
|
|
@ -325,7 +324,7 @@ describe('Storage model', function() {
|
|||
'id1::b': 'y',
|
||||
'id2::c': 'z',
|
||||
};
|
||||
s.storage.allKeys = sinon.stub().yields(_.keys(data));
|
||||
s.db.allKeys = sinon.stub().yields(_.keys(data));
|
||||
sinon.stub(s, '_read', function(k, cb) {
|
||||
return cb(data[k]);
|
||||
});
|
||||
|
|
@ -354,7 +353,7 @@ describe('Storage model', function() {
|
|||
c: 'z'
|
||||
},
|
||||
};
|
||||
s.storage.allKeys = sinon.stub().yields(_.keys(data));
|
||||
s.db.allKeys = sinon.stub().yields(_.keys(data));
|
||||
sinon.stub(s, '_read', function(k, cb) {
|
||||
return cb(data[k]);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -11,8 +11,7 @@ describe('WalletLock model', function() {
|
|||
beforeEach(function() {
|
||||
storage = new Storage(requireMock('FakeLocalStorage').storageParams);
|
||||
storage.setPassphrase('mysupercoolpassword');
|
||||
storage.storage.clear();
|
||||
storage.sessionStorage.clear();
|
||||
storage.clearAll();
|
||||
});
|
||||
|
||||
it('should fail with missing args', function() {
|
||||
|
|
@ -85,9 +84,9 @@ describe('WalletLock model', function() {
|
|||
w.keepAlive(function() {
|
||||
storage.setSessionId('session2', function() {
|
||||
|
||||
var json = JSON.parse(storage.storage.ls['lock::walletId']);
|
||||
var json = JSON.parse(storage.db.ls['lock::walletId']);
|
||||
json.expireTs -= 3600 * 1000;
|
||||
storage.storage.ls['lock::walletId'] = JSON.stringify(json);
|
||||
storage.db.ls['lock::walletId'] = JSON.stringify(json);
|
||||
var w2 = new WalletLock(storage, 'walletId');
|
||||
w2.keepAlive(function(locked) {
|
||||
w2.sessionId.should.equal('session2');
|
||||
|
|
|
|||
|
|
@ -21,14 +21,15 @@ FakeLocalStorage.prototype.setItem = function(k, v, cb) {
|
|||
this.ls[k] = v;
|
||||
return cb();
|
||||
};
|
||||
FakeLocalStorage.prototype.clear = function() {
|
||||
FakeLocalStorage.prototype.clear = function(cb) {
|
||||
this.ls = {};
|
||||
if (cb) return cb();
|
||||
}
|
||||
|
||||
module.exports = FakeLocalStorage;
|
||||
|
||||
module.exports.storageParams = {
|
||||
password: '123',
|
||||
storage: new FakeLocalStorage(),
|
||||
db: new FakeLocalStorage(),
|
||||
sessionStorage: new FakeLocalStorage(),
|
||||
};
|
||||
|
|
|
|||
|
|
@ -14,11 +14,12 @@ describe('Profile model', function() {
|
|||
var storage = new FakeStorage();
|
||||
var opts = {
|
||||
email: email,
|
||||
password: password,
|
||||
};
|
||||
|
||||
beforeEach(function() {
|
||||
storage.getItem = sinon.stub();
|
||||
storage.setFromObj = sinon.stub();
|
||||
storage.setFromObj.yields(null);
|
||||
});
|
||||
|
||||
it('should fail create an instance', function() {
|
||||
|
|
@ -32,21 +33,20 @@ describe('Profile model', function() {
|
|||
it('should create an instance', function() {
|
||||
var p = new Profile({
|
||||
email: email,
|
||||
password: password
|
||||
}, storage);
|
||||
}, password, storage);
|
||||
should.exist(p);
|
||||
});
|
||||
|
||||
it('#fromObj #toObj round trip', function() {
|
||||
|
||||
var p = new Profile(opts, storage);
|
||||
var p2 = Profile.fromObj(p.toObj(), storage);
|
||||
var p = new Profile(opts, password, storage);
|
||||
var p2 = Profile.fromObj(p.toObj(), password, storage);
|
||||
p2.should.deep.equal(p);
|
||||
});
|
||||
|
||||
it('#store', function(done) {
|
||||
var p = new Profile(opts, storage);
|
||||
var p = new Profile(opts, password, storage);
|
||||
p.store(function(err) {
|
||||
storage.setFromObj.getCall(0).args[1].should.deep.equal(p.toObj());
|
||||
should.not.exist(err);
|
||||
done();
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue