mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-08-29 01:31:04 +00:00
add aden's requested changes
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
const storage = new Map<string, unknown>();
|
||||
|
||||
const local = {
|
||||
get: jest.fn(async (keys?: string | string[] | null) => {
|
||||
if (keys == null) {
|
||||
return Object.fromEntries(storage);
|
||||
}
|
||||
if (typeof keys === "string") {
|
||||
return keys in storage ? { [keys]: storage.get(keys) } : {};
|
||||
}
|
||||
const out: Record<string, unknown> = {};
|
||||
for (const key of keys) {
|
||||
if (storage.has(key)) out[key] = storage.get(key);
|
||||
}
|
||||
return out;
|
||||
}),
|
||||
set: jest.fn(async (items: Record<string, unknown>) => {
|
||||
for (const [k, v] of Object.entries(items)) storage.set(k, v);
|
||||
}),
|
||||
remove: jest.fn(async (keys: string | string[]) => {
|
||||
const list = Array.isArray(keys) ? keys : [keys];
|
||||
for (const key of list) storage.delete(key);
|
||||
}),
|
||||
};
|
||||
|
||||
export default {
|
||||
storage: { local },
|
||||
};
|
||||
|
||||
export function __resetBrowserStorageMock() {
|
||||
storage.clear();
|
||||
local.get.mockClear();
|
||||
local.set.mockClear();
|
||||
local.remove.mockClear();
|
||||
}
|
||||
Reference in New Issue
Block a user