fleet/frontend/.test.setup.js

32 строки
635 B
JavaScript
Исходник Обычный вид История

2016-09-06 21:41:16 +03:00
import jsdom from 'jsdom';
const doc = jsdom.jsdom('<!doctype html><html><body></body></html>');
global.document = doc;
global.window = doc.defaultView;
global.navigator = global.window.navigator;
function mockStorage() {
const storage = {};
return {
setItem(key, value = '') {
storage[key] = value;
},
getItem(key) {
return storage[key];
},
removeItem(key) {
delete storage[key];
},
get length() {
return Object.keys(storage).length;
},
key(i) {
return Object.keys(storage)[i] || null;
},
};
}
global.localStorage = window.localStorage = mockStorage();