20 lines
381 B
JavaScript
20 lines
381 B
JavaScript
const localStorageMock = (function() {
|
|
let store = {};
|
|
return {
|
|
getItem: function(key) {
|
|
return store[key] || null;
|
|
},
|
|
setItem: function(key, value) {
|
|
store[key] = value.toString();
|
|
},
|
|
removeItem: function(key) {
|
|
delete store[key];
|
|
},
|
|
clear: function() {
|
|
store = {};
|
|
}
|
|
};
|
|
})();
|
|
|
|
global.localStorage = localStorageMock;
|