- CompletedToggle: 5 tests for checkbox rendering, state, and interaction - SearchBar: 7 tests for input, placeholder, recent searches dropdown - TagInput: 6 tests for rendering with various tag configurations - Update vitest-setup-client.ts with $app/state, preferences, recentSearches mocks - All component tests run in real Chromium browser via Playwright
61 lines
1.3 KiB
TypeScript
61 lines
1.3 KiB
TypeScript
/// <reference types="@vitest/browser/matchers" />
|
|
/// <reference types="@vitest/browser/providers/playwright" />
|
|
|
|
import { vi } from 'vitest';
|
|
import { writable } from 'svelte/store';
|
|
|
|
// Mock $app/navigation
|
|
vi.mock('$app/navigation', () => ({
|
|
goto: vi.fn(() => Promise.resolve()),
|
|
invalidate: vi.fn(() => Promise.resolve()),
|
|
invalidateAll: vi.fn(() => Promise.resolve()),
|
|
beforeNavigate: vi.fn(),
|
|
afterNavigate: vi.fn()
|
|
}));
|
|
|
|
// Mock $app/stores
|
|
vi.mock('$app/stores', () => ({
|
|
page: writable({
|
|
url: new URL('http://localhost'),
|
|
params: {},
|
|
route: { id: null },
|
|
status: 200,
|
|
error: null,
|
|
data: {},
|
|
form: null
|
|
}),
|
|
navigating: writable(null),
|
|
updated: { check: vi.fn(), subscribe: writable(false).subscribe }
|
|
}));
|
|
|
|
// Mock $app/environment
|
|
vi.mock('$app/environment', () => ({
|
|
browser: true,
|
|
dev: true,
|
|
building: false
|
|
}));
|
|
|
|
// Mock $app/state (Svelte 5 runes-based state)
|
|
vi.mock('$app/state', () => ({
|
|
page: {
|
|
url: new URL('http://localhost'),
|
|
params: {},
|
|
route: { id: null },
|
|
status: 200,
|
|
error: null,
|
|
data: {},
|
|
form: null
|
|
}
|
|
}));
|
|
|
|
// Mock preferences store
|
|
vi.mock('$lib/stores/preferences.svelte', () => ({
|
|
preferences: writable({ showCompleted: false, lastEntryType: 'thought' })
|
|
}));
|
|
|
|
// Mock recent searches store
|
|
vi.mock('$lib/stores/recentSearches', () => ({
|
|
addRecentSearch: vi.fn(),
|
|
recentSearches: writable([])
|
|
}));
|