mirror of
https://github.com/Zakkaus/doona.git
synced 2026-12-06 08:02:04 +00:00
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.
25 lines
1020 B
TypeScript
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();
|
|
}
|
|
});
|