.
This commit is contained in:
parent
248c18596c
commit
7a072e83d9
1 changed files with 27 additions and 0 deletions
27
test/mocks/FakeLocalStorage.js
Normal file
27
test/mocks/FakeLocalStorage.js
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
//localstorage Mock
|
||||
ls = {};
|
||||
function LocalStorage(opts) {}
|
||||
|
||||
FakeLocalStorage = {};
|
||||
FakeLocalStorage.length = 0;
|
||||
FakeLocalStorage.removeItem = function(key) {
|
||||
delete ls[key];
|
||||
this.length = Object.keys(ls).length;
|
||||
};
|
||||
|
||||
FakeLocalStorage.getItem = function(k) {
|
||||
return ls[k];
|
||||
};
|
||||
|
||||
|
||||
FakeLocalStorage.key = function(i) {
|
||||
return Object.keys(ls)[i];
|
||||
};
|
||||
|
||||
FakeLocalStorage.setItem = function(k, v) {
|
||||
ls[k] = v;
|
||||
this.key[this.length] = k;
|
||||
this.length = Object.keys(ls).length;
|
||||
};
|
||||
|
||||
module.exports = require('soop')(FakeLocalStorage);
|
||||
Loading…
Add table
Add a link
Reference in a new issue