mirror of
https://github.com/open-reception/appointment-booking-software.git
synced 2026-09-06 17:37:37 +02:00
37 Fixed mock in page.svelte test (api route did not exist in unit test)
This commit is contained in:
@@ -1,9 +1,18 @@
|
||||
import { describe, test, expect } from 'vitest';
|
||||
import { describe, test, expect, vi, beforeEach } from 'vitest';
|
||||
import '@testing-library/jest-dom/vitest';
|
||||
import { render, screen } from '@testing-library/svelte';
|
||||
import Page from './+page.svelte';
|
||||
|
||||
describe('/+page.svelte', () => {
|
||||
beforeEach(() => {
|
||||
// Mock fetch to avoid the "Invalid URL" error
|
||||
global.fetch = vi.fn(() =>
|
||||
Promise.resolve({
|
||||
json: () => Promise.resolve({ envOkay: true })
|
||||
} as Response)
|
||||
);
|
||||
});
|
||||
|
||||
test('should render h1', () => {
|
||||
render(Page);
|
||||
expect(screen.getByRole('heading', { level: 1 })).toBeInTheDocument();
|
||||
|
||||
Reference in New Issue
Block a user