mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-04 19:41:06 +08:00
21 lines
559 B
TypeScript
21 lines
559 B
TypeScript
/* eslint-disable no-return-assign */
|
|
/* eslint-disable no-undef */
|
|
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 = {}),
|
|
};
|
|
};
|
|
Object.defineProperty(window, 'localStorage', {
|
|
value: mock(),
|
|
});
|
|
Object.defineProperty(window, 'sessionStorage', {
|
|
value: mock(),
|
|
});
|
|
Object.defineProperty(window, 'getComputedStyle', {
|
|
value: () => ['-webkit-appearance'],
|
|
});
|