2014-04-14 13:17:56 -07:00
|
|
|
'use strict';
|
|
|
|
|
2014-06-13 07:30:48 -07:00
|
|
|
if (typeof process === 'undefined' || !process.version) {
|
2014-04-14 14:08:18 -07:00
|
|
|
// browser
|
2014-06-13 07:30:48 -07:00
|
|
|
var chai = chai || require('chai');
|
|
|
|
var should = chai.should();
|
|
|
|
var copay = copay || require('../copay');
|
|
|
|
var LocalPlain = copay.StorageLocalPlain;
|
2014-04-14 13:17:56 -07:00
|
|
|
|
2014-06-16 13:50:02 -07:00
|
|
|
describe('Storage/LocalPlain model', function() {
|
2014-04-14 13:17:56 -07:00
|
|
|
|
2014-06-13 07:30:48 -07:00
|
|
|
it('should create an instance', function() {
|
2014-04-16 07:55:18 -07:00
|
|
|
var s = new LocalPlain();
|
2014-04-14 13:17:56 -07:00
|
|
|
should.exist(s);
|
|
|
|
});
|
2014-04-17 14:04:56 -07:00
|
|
|
|
|
|
|
describe('#setFromObj', function() {
|
|
|
|
it('should set keys from an object', function() {
|
2014-06-16 13:50:02 -07:00
|
|
|
var fakeWallet = 'fake-wallet-id';
|
|
|
|
var timeStamp = Date.now();
|
|
|
|
|
2014-06-13 07:30:48 -07:00
|
|
|
var obj = {
|
|
|
|
test: 'testval',
|
|
|
|
opts: {
|
|
|
|
name: 'testname'
|
|
|
|
}
|
|
|
|
};
|
2014-04-17 14:04:56 -07:00
|
|
|
var storage = new LocalPlain();
|
2014-06-16 13:50:02 -07:00
|
|
|
storage.setFromObj(fakeWallet+timeStamp, obj);
|
|
|
|
storage.get(fakeWallet+timeStamp, 'test').should.equal('testval');
|
|
|
|
|
|
|
|
// Clean data used in localstorage
|
|
|
|
localStorage.removeItem(fakeWallet+timeStamp+'::test');
|
|
|
|
localStorage.removeItem(fakeWallet+timeStamp+'::opts');
|
|
|
|
localStorage.removeItem('nameFor::'+fakeWallet+timeStamp);
|
2014-04-17 14:04:56 -07:00
|
|
|
});
|
|
|
|
});
|
2014-04-14 13:17:56 -07:00
|
|
|
});
|
|
|
|
}
|