阶段十:完成前端组件与 Hook 注释基线清零

This commit is contained in:
Christ committed 2026-08-15 04:44:06 +08:00
1 parent c90461226b
commit 6257fad453
43 files changed
+1094 -7356

No files matched your search

+10 -9
View File
@@ -1,14 +1,15 @@
import { afterEach, describe, expect, test, vi } from 'vitest';
import { readSidebarCollapsed, writeSidebarCollapsed } from './sidebarState';
afterEach(() => vi.unstubAllGlobals());
afterEach(/* 当前回调处理用户交互或异步状态变化。 */ () => vi.unstubAllGlobals());
describe('sidebar persistence', () => {
test('defaults to expanded and persists both states', () => {
describe('sidebar persistence', /* 当前回调处理用户交互或异步状态变化。 */ () => {
test('defaults to expanded and persists both states', /* 当前回调处理用户交互或异步状态变化。 */ () => {
// values 值列表。
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),
getItem: /* 当前回调处理用户交互或异步状态变化。 */ (key: string) => values.get(key) ?? null,
setItem: /* 当前回调处理用户交互或异步状态变化。 */ (key: string, value: string) => values.set(key, value),
}});
expect(readSidebarCollapsed()).toBe(false);
writeSidebarCollapsed(true);
@@ -17,12 +18,12 @@ describe('sidebar persistence', () => {
expect(readSidebarCollapsed()).toBe(false);
});
test('storage failures safely fall back to expanded', () => {
test('storage failures safely fall back to expanded', /* 当前回调处理用户交互或异步状态变化。 */ () => {
vi.stubGlobal('window', { localStorage: {
getItem: () => { throw new Error('blocked'); },
setItem: () => { throw new Error('blocked'); },
getItem: /* 当前回调处理用户交互或异步状态变化。 */ () => { throw new Error('blocked'); },
setItem: /* 当前回调处理用户交互或异步状态变化。 */ () => { throw new Error('blocked'); },
}});
expect(readSidebarCollapsed()).toBe(false);
expect(() => writeSidebarCollapsed(true)).not.toThrow();
expect(/* 当前回调处理用户交互或异步状态变化。 */ () => writeSidebarCollapsed(true)).not.toThrow();
});
});