copay/test/test.storage.LocalPlain.js

40 lines
1.1 KiB
JavaScript
Raw Normal View History

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
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);
});
describe('#setFromObj', function() {
it('should set keys from an object', function() {
var fakeWallet = 'fake-wallet-id';
var timeStamp = Date.now();
2014-06-13 07:30:48 -07:00
var obj = {
test: 'testval',
opts: {
name: 'testname'
}
};
var storage = new LocalPlain();
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-14 13:17:56 -07:00
});
}