fix: stabilize catalog filter coverage imports

This commit is contained in:
plebeius
2026-03-08 19:40:19 +08:00
parent 5d77a33c38
commit fabdd0efe5
2 changed files with 5 additions and 6 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
import { Comment } from '@bitsocialhq/bitsocial-react-hooks'; import type { Comment } from '@bitsocialhq/bitsocial-react-hooks';
import useSubplebbitsStore from '@bitsocialhq/bitsocial-react-hooks/dist/stores/subplebbits'; import useSubplebbitsStore from '@bitsocialhq/bitsocial-react-hooks/dist/stores/subplebbits';
/** /**
@@ -7,6 +7,10 @@ const testState = vi.hoisted(() => ({
}), }),
})); }));
vi.mock('../../lib/utils/pattern-utils', () => ({
commentMatchesPattern: (comment: unknown, pattern: string) => testState.commentMatchesPatternMock(comment as never, pattern),
}));
type CatalogFiltersStoreModule = typeof import('../use-catalog-filters-store'); type CatalogFiltersStoreModule = typeof import('../use-catalog-filters-store');
type CatalogFiltersStore = Awaited<ReturnType<typeof loadStore>>; type CatalogFiltersStore = Awaited<ReturnType<typeof loadStore>>;
@@ -14,10 +18,6 @@ const STORAGE_KEY = 'catalog-filters-storage';
const loadStore = async () => { const loadStore = async () => {
vi.resetModules(); vi.resetModules();
vi.doMock('../../lib/utils/pattern-utils', () => ({
commentMatchesPattern: (comment: unknown, pattern: string) => testState.commentMatchesPatternMock(comment as never, pattern),
}));
const module = (await import('../use-catalog-filters-store')) as CatalogFiltersStoreModule; const module = (await import('../use-catalog-filters-store')) as CatalogFiltersStoreModule;
await Promise.resolve(); await Promise.resolve();
return module.default; return module.default;
@@ -48,7 +48,6 @@ describe('useCatalogFiltersStore', () => {
afterEach(() => { afterEach(() => {
vi.useRealTimers(); vi.useRealTimers();
vi.doUnmock('../../lib/utils/pattern-utils');
consoleWarnSpy.mockRestore(); consoleWarnSpy.mockRestore();
}); });