Files
Ydisks-Xianyu-Helper/frontend/components/sidebarState.test.ts
T
Christ 67d7214930 feat: add account automation and isolated chat
- add account-level auto rating and daily polish tasks\n- add cached historical chat, media, emoji, and per-account realtime sync\n- add SQLite, MySQL, and PostgreSQL migrations and regression coverage\n- align account, sidebar, and chat interfaces with the new workflows
2026-08-08 22:16:35 +08:00

29 lines
1.0 KiB
TypeScript

import { afterEach, describe, expect, test, vi } from 'vitest';
import { readSidebarCollapsed, writeSidebarCollapsed } from './sidebarState';
afterEach(() => vi.unstubAllGlobals());
describe('sidebar persistence', () => {
test('defaults to expanded and persists both states', () => {
const values = new Map<string, string>();
vi.stubGlobal('window', { localStorage: {
getItem: (key: string) => values.get(key) ?? null,
setItem: (key: string, value: string) => values.set(key, value),
}});
expect(readSidebarCollapsed()).toBe(false);
writeSidebarCollapsed(true);
expect(readSidebarCollapsed()).toBe(true);
writeSidebarCollapsed(false);
expect(readSidebarCollapsed()).toBe(false);
});
test('storage failures safely fall back to expanded', () => {
vi.stubGlobal('window', { localStorage: {
getItem: () => { throw new Error('blocked'); },
setItem: () => { throw new Error('blocked'); },
}});
expect(readSidebarCollapsed()).toBe(false);
expect(() => writeSidebarCollapsed(true)).not.toThrow();
});
});