refactor: 优化 RouterProvider 组件的数据加载逻辑
- 使用批量获取方法 `getMany` 替代多个单独的 `get` 调用,简化数据加载过程。 - 更新 `loadInitialData` 函数,确保从存储中获取的默认值更为一致。 - 修改测试用例以验证批量获取的功能,确保组件在不同情况下的正确性。
This commit is contained in:
@@ -40,6 +40,7 @@ describe('useStorageState', () => {
|
||||
|
||||
// 初始值应从快照恢复,而非默认值
|
||||
expect(result.current[0]).toBe(false);
|
||||
expect(storageUtil.get).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('应该从 Chrome Storage 异步加载并覆盖初始值', async () => {
|
||||
@@ -179,5 +180,6 @@ describe('useStorageState', () => {
|
||||
await waitFor(() => {
|
||||
expect(storageUtil.set).not.toHaveBeenCalled();
|
||||
});
|
||||
expect(storageUtil.get).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user