Feature/unit tests (#184)
This commit is contained in:
committed by
GitHub
parent
255e4d8883
commit
ec46a6f760
22
core/test/mockLocalStorage.ts
Normal file
22
core/test/mockLocalStorage.ts
Normal file
@ -0,0 +1,22 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
const mockLocalStorage = (function () {
|
||||
let store: Record<string, any> = {};
|
||||
return {
|
||||
getItem(key: string) {
|
||||
return store[key] ?? null;
|
||||
},
|
||||
setItem(key: string, value: any) {
|
||||
store[key] = value.toString();
|
||||
},
|
||||
clear() {
|
||||
store = {};
|
||||
},
|
||||
removeItem(key: string) {
|
||||
delete store[key];
|
||||
},
|
||||
};
|
||||
})();
|
||||
|
||||
Object.defineProperty(window, 'localStorage', { value: mockLocalStorage });
|
||||
|
||||
export {};
|
Reference in New Issue
Block a user