fix fake URL in test fixtures pointing to 404-page and refactoring magic strings URLs
This commit is contained in:
@@ -4,6 +4,7 @@ import * as nav from '$app/navigation';
|
||||
import TatortListPage from '../src/routes/(token-based)/list/[vorgang]/+page.svelte';
|
||||
import { baseData } from './fixtures';
|
||||
import { tick } from 'svelte';
|
||||
import { API_ROUTES } from '../src/routes';
|
||||
|
||||
vi.spyOn(nav, 'invalidateAll').mockResolvedValue();
|
||||
global.fetch = vi.fn().mockResolvedValue({ ok: true });
|
||||
@@ -50,6 +51,7 @@ describe('Seite: Vorgangsansicht', () => {
|
||||
it('führt DELETE-Request aus und entfernt Element aus UI', async () => {
|
||||
const testData = structuredClone(baseData);
|
||||
const oldName = testData.crimesList[0].name;
|
||||
const vorgang = testData.vorgang;
|
||||
|
||||
render(TatortListPage, { props: { data: testData } });
|
||||
const initialItems = screen.getAllByTestId('test-list-item');
|
||||
@@ -62,10 +64,9 @@ describe('Seite: Vorgangsansicht', () => {
|
||||
await fireEvent.click(within(listItem).getByTestId('delete-button'));
|
||||
await tick();
|
||||
|
||||
let expectedPath = new URL(testData.url).pathname;
|
||||
expectedPath += `/${oldName}`
|
||||
let expectedPath = API_ROUTES.CRIME(vorgang.vorgangToken, oldName)
|
||||
expect(global.fetch).toHaveBeenCalledWith(
|
||||
`/api${expectedPath}`,
|
||||
expectedPath,
|
||||
expect.objectContaining({
|
||||
method: 'DELETE',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
|
||||
@@ -41,7 +41,7 @@ export const baseData = {
|
||||
vorgang: testVorgangsList[0],
|
||||
vorgangList: testVorgangsList,
|
||||
crimesList: testCrimesList,
|
||||
url: `https://example.com/${testVorgangsList[0].vorgangToken}`,
|
||||
url: `https://example.com/list/${testVorgangsList[0].vorgangToken}`,
|
||||
crimeNames: ['modell-A', 'Fall-A']
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user