add aden's requested changes

This commit is contained in:
2026-06-10 11:00:09 +09:30
parent ec94376e1f
commit 57a1965a6d
13 changed files with 403 additions and 44 deletions
+35
View File
@@ -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();
}