From 14dbd374ec4b3cd12d685b69ccce096e6cb36491 Mon Sep 17 00:00:00 2001 From: Ilia Mashkov Date: Fri, 10 Apr 2026 08:06:51 +0300 Subject: [PATCH] refactor: replace unifiedFontStore with fontStore in comparisonStore tests --- .../model/stores/comparisonStore.test.ts | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/widgets/ComparisonView/model/stores/comparisonStore.test.ts b/src/widgets/ComparisonView/model/stores/comparisonStore.test.ts index 9d397b8..10d2316 100644 --- a/src/widgets/ComparisonView/model/stores/comparisonStore.test.ts +++ b/src/widgets/ComparisonView/model/stores/comparisonStore.test.ts @@ -4,7 +4,7 @@ * Tests the font comparison store functionality including: * - Font loading via CSS Font Loading API * - Storage synchronization when fonts change - * - Default values from unifiedFontStore + * - Default values from fontStore * - Reset functionality * - isReady computed state */ @@ -25,7 +25,6 @@ import { // Mock all dependencies vi.mock('$entities/Font', () => ({ fetchFontsByIds: vi.fn(), - unifiedFontStore: { fonts: [] }, fontStore: { fonts: [] }, })); @@ -120,7 +119,7 @@ vi.mock('$shared/lib/helpers/createPersistentStore/createPersistentStore.svelte' // Import after mocks import { fetchFontsByIds, - unifiedFontStore, + fontStore, } from '$entities/Font'; import { createTypographyControlManager } from '$features/SetupFont'; import { ComparisonStore } from './comparisonStore.svelte'; @@ -151,8 +150,8 @@ describe('ComparisonStore', () => { }; mockStorage._clear.mockClear(); - // Setup mock unifiedFontStore - (unifiedFontStore as any).fonts = []; + // Setup mock fontStore + (fontStore as any).fonts = []; // Setup mock fetchFontsByIds vi.mocked(fetchFontsByIds).mockResolvedValue([]); @@ -302,8 +301,8 @@ describe('ComparisonStore', () => { }); it('should handle partial restoration when only one font is found', async () => { - // Ensure unifiedFontStore is empty so $effect doesn't interfere - (unifiedFontStore as any).fonts = []; + // Ensure fontStore is empty so $effect doesn't interfere + (fontStore as any).fonts = []; mockStorage._value.fontAId = mockFontA.id; mockStorage._value.fontBId = mockFontB.id; @@ -331,7 +330,7 @@ describe('ComparisonStore', () => { describe('Font Loading with CSS Font Loading API', () => { it('should construct correct font strings for checking', async () => { mockFontFaceSet.check.mockReturnValue(false); - (unifiedFontStore as any).fonts = [mockFontA, mockFontB]; + (fontStore as any).fonts = [mockFontA, mockFontB]; vi.mocked(fetchFontsByIds).mockResolvedValue([mockFontA, mockFontB]); const store = new ComparisonStore(); @@ -368,7 +367,7 @@ describe('ComparisonStore', () => { // Mock load to fail mockFontFaceSet.load.mockRejectedValue(new Error('Font load failed')); - (unifiedFontStore as any).fonts = [mockFontA, mockFontB]; + (fontStore as any).fonts = [mockFontA, mockFontB]; vi.mocked(fetchFontsByIds).mockResolvedValue([mockFontA, mockFontB]); const consoleSpy = vi.spyOn(console, 'warn').mockImplementation(() => {}); @@ -385,11 +384,11 @@ describe('ComparisonStore', () => { }); }); - describe('Default Values from unifiedFontStore', () => { - it('should set default fonts from unifiedFontStore when available', () => { + describe('Default Values from fontStore', () => { + it('should set default fonts from fontStore when available', () => { // Note: This test relies on Svelte 5's $effect which may not work // reliably in the test environment. We test the logic path instead. - (unifiedFontStore as any).fonts = [mockFontA, mockFontB]; + (fontStore as any).fonts = [mockFontA, mockFontB]; const store = new ComparisonStore(); @@ -403,9 +402,9 @@ describe('ComparisonStore', () => { expect(store.fontB).toBeDefined(); }); - it('should use first and last font from unifiedFontStore as defaults', () => { + it('should use first and last font from fontStore as defaults', () => { const mockFontC = UNIFIED_FONTS.lato; - (unifiedFontStore as any).fonts = [mockFontA, mockFontC, mockFontB]; + (fontStore as any).fonts = [mockFontA, mockFontC, mockFontB]; const store = new ComparisonStore();