refactor/code-splitting #31

Merged
ilia merged 32 commits from refactor/code-splitting into main 2026-04-08 06:34:20 +00:00
Showing only changes of commit 9c538069e4 - Show all commits

View File

@@ -433,3 +433,58 @@ describe('category getters', () => {
expect(store.monospaceFonts.every(f => f.category === 'monospace')).toBe(true);
});
});
describe('isEmpty', () => {
let store: UnifiedFontStore;
beforeEach(() => {
store = new UnifiedFontStore({ limit: 10 });
});
afterEach(() => {
store.destroy();
queryClient.clear();
vi.resetAllMocks();
});
it('is true when fetch returns no fonts', async () => {
mockedFetch.mockResolvedValue(makeResponse([]));
await store.refetch();
expect(store.isEmpty).toBe(true);
});
it('is false when fonts are present', async () => {
mockedFetch.mockResolvedValue(makeResponse(generateMockFonts(3)));
await store.refetch();
expect(store.isEmpty).toBe(false);
});
it('is true after an error (no fonts loaded)', async () => {
mockedFetch.mockRejectedValue(new Error('network down'));
await store.refetch().catch((e: unknown) => e);
expect(store.isEmpty).toBe(true);
});
});
describe('destroy', () => {
it('can be called without throwing', () => {
const store = new UnifiedFontStore({ limit: 10 });
expect(() => {
store.destroy();
}).not.toThrow();
});
it('sets filterCleanup to null so it is not called again', () => {
const store = new UnifiedFontStore({ limit: 10 });
store.destroy();
// Second destroy should not throw even though filterCleanup is now null
expect(() => {
store.destroy();
}).not.toThrow();
});
});