refactor(font): move test fixtures into a dedicated testing segment

Mock data lived in lib/ and was re-exported through the slice's
production index.ts, advertising fixtures as part of the public API.
Move it to a testing/ segment and drop it from index.ts; consumers now
import explicitly via the $entities/Font/testing subpath.

Repoints the four mock consumers (FontApplicator story, sizeResolver
and fontCatalogStore specs, comparisonStore test) to the new subpath.
This commit is contained in:
Ilia Mashkov
2026-05-31 14:08:25 +03:00
parent 7d66b0bc92
commit b8edeff86f
10 changed files with 14 additions and 55 deletions
+3
View File
@@ -3,3 +3,6 @@ export * from './domain';
export * from './lib';
export * from './model';
export * from './ui';
// `./testing` is intentionally not re-exported: fixtures must not leak into the
// production public API. Import them via `$entities/Font/testing`.
-44
View File
@@ -1,49 +1,5 @@
export { getFontUrl } from './getFontUrl/getFontUrl';
// Mock data helpers for Storybook and testing
export {
createCategoriesFilter,
createErrorState,
createGenericFilter,
createLoadingState,
createMockComparisonStore,
// Filter mocks
createMockFilter,
createMockFontApiResponse,
createMockFontStoreState,
// Store mocks
createMockQueryState,
createMockReactiveState,
createMockStore,
createProvidersFilter,
createSubsetsFilter,
createSuccessState,
generateMixedCategoryFonts,
generateMockFonts,
generatePaginatedFonts,
generateSequentialFilter,
GENERIC_FILTERS,
getAllMockFonts,
getFontsByCategory,
getFontsByProvider,
MOCK_FILTERS,
MOCK_FILTERS_ALL_SELECTED,
MOCK_FILTERS_EMPTY,
MOCK_FILTERS_SELECTED,
MOCK_FONT_STORE_STATES,
MOCK_STORES,
type MockFilterOptions,
type MockFilters,
type MockFontStoreState,
// Font mocks
// Types
type MockQueryObserverResult,
type MockQueryState,
mockUnifiedFont,
type MockUnifiedFontOptions,
UNIFIED_FONTS,
} from './mocks';
export {
FontNetworkError,
FontResponseError,
@@ -14,6 +14,7 @@ vi.mock('@chenglou/pretext', async () => {
layout: vi.fn(actual.layout),
};
});
import { mockUnifiedFont } from '$entities/Font/testing';
import {
beforeEach,
describe,
@@ -22,7 +23,6 @@ import {
vi,
} from 'vitest';
import type { FontLoadStatus } from '../../model/types';
import { mockUnifiedFont } from '../mocks';
import { createFontRowSizeResolver } from './createFontRowSizeResolver';
// Fixed-width canvas mock: every character is 10px wide regardless of font.
@@ -1,3 +1,7 @@
import {
generateMixedCategoryFonts,
generateMockFonts,
} from '$entities/Font/testing';
import { QueryClient } from '@tanstack/query-core';
import { flushSync } from 'svelte';
import {
@@ -12,10 +16,6 @@ import {
FontNetworkError,
FontResponseError,
} from '../../../lib/errors/errors';
import {
generateMixedCategoryFonts,
generateMockFonts,
} from '../../../lib/mocks/fonts.mock';
import type { UnifiedFont } from '../../types';
import { FontCatalogStore } from './fontCatalogStore.svelte';
@@ -16,7 +16,7 @@
* GOOGLE_FONTS,
* FONTHARE_FONTS,
* UNIFIED_FONTS,
* } from '$entities/Font/lib/mocks';
* } from '$entities/Font/testing';
*
* // Create a mock Google Font
* const roboto = mockGoogleFont({ family: 'Roboto', category: 'sans-serif' });
@@ -28,7 +28,7 @@
* const font = mockUnifiedFont({ id: 'roboto', name: 'Roboto' });
*
* // Use preset fonts
* import { UNIFIED_FONTS } from '$entities/Font/lib/mocks';
* import { UNIFIED_FONTS } from '$entities/Font/testing';
* ```
*/
@@ -13,7 +13,7 @@
* UNIFIED_FONTS,
* MOCK_FILTERS,
* createMockFontStoreState,
* } from '$entities/Font/lib/mocks';
* } from '$entities/Font/testing';
*
* // Use in stories
* const font = mockUnifiedFont({ name: 'My Font', category: 'serif' });
@@ -8,7 +8,7 @@
* import {
* createMockQueryState,
* MOCK_STORES,
* } from '$entities/Font/lib/mocks';
* } from '$entities/Font/testing';
*
* // Create a mock query state
* const loadingState = createMockQueryState({ status: 'pending' });
@@ -23,7 +23,7 @@ const { Story } = defineMeta({
</script>
<script lang="ts">
import { mockUnifiedFont } from '$entities/Font/lib/mocks';
import { mockUnifiedFont } from '$entities/Font/testing';
import type { ComponentProps } from 'svelte';
const fontUnknown = mockUnifiedFont({ id: 'nonexistent-font-xk92z', name: 'Nonexistent Font Xk92z' });