This commit is contained in:
klimentru1986 2018-05-06 02:17:16 +03:00
parent 2c99646fef
commit 4ca019ac02
2 changed files with 17 additions and 19 deletions

View File

@ -1,20 +1,18 @@
const mock = () => {
let storage = {};
return {
getItem: key => (key in storage ? storage[key] : null),
setItem: (key, value) => (storage[key] = value || ''),
removeItem: key => delete storage[key],
clear: () => (storage = {})
};
let storage = {};
return {
getItem: key => (key in storage ? storage[key] : null),
setItem: (key, value) => (storage[key] = value || ''),
removeItem: key => delete storage[key],
clear: () => (storage = {}),
};
Object.defineProperty(window, 'localStorage', {
value: mock()
});
Object.defineProperty(window, 'sessionStorage', {
value: mock()
});
Object.defineProperty(window, 'getComputedStyle', {
value: () => ['-webkit-appearance']
});
};
Object.defineProperty(window, 'localStorage', {
value: mock(),
});
Object.defineProperty(window, 'sessionStorage', {
value: mock(),
});
Object.defineProperty(window, 'getComputedStyle', {
value: () => ['-webkit-appearance'],
});

View File

@ -1,2 +1,2 @@
import 'jest-preset-angular';
import './globalMocks';
import './globalMocks';