Files
doona/src/shell/widgets/samples.test.ts
T
Zakk 2725f76a50 test(widgets): cover the dashboard, editor and panel
Unit tests cover layout parsing and migration, size presets, packing,
instance limits, shared mode drafts and previews that never save. The
dashboard spec checks the default layout against main's geometry, drags in
four directions, reorders by keyboard, resizes one card without moving the
others, and checks level columns and edit-mode boxes in Chromium, Firefox
and WebKit. The panel spec covers keyboard resizing, collapse and pinning.
2026-10-02 16:11:18 +10:00

25 lines
1020 B
TypeScript

import {expect, it, vi} from 'vitest';
import {loadSamples} from './samples';
import {hasPreviewData} from './preview';
it('derives reusable preview snapshots without browser storage, network calls or timers', async () => {
const storage = {getItem: vi.fn(() => '100000'), setItem: vi.fn(), removeItem: vi.fn()};
vi.stubGlobal('localStorage', storage);
const fetch = vi.spyOn(globalThis, 'fetch');
const interval = vi.spyOn(globalThis, 'setInterval');
try {
const pending = loadSamples();
expect(loadSamples()).toBe(pending);
const samples = await pending;
for (const [name, value] of Object.entries(samples)) expect(hasPreviewData(value), name).toBe(true);
expect(samples.nodes).toHaveLength(8);
expect(storage.getItem).not.toHaveBeenCalled();
expect(storage.setItem).not.toHaveBeenCalled();
expect(fetch).not.toHaveBeenCalled();
expect(interval).not.toHaveBeenCalled();
} finally {
fetch.mockRestore();
interval.mockRestore();
vi.unstubAllGlobals();
}
});