f090_magic_strings_refactoring #35

Merged
jared merged 29 commits from f090_magic_strings_refactoring into development 2025-09-30 13:33:27 +02:00
2 changed files with 5 additions and 4 deletions
Showing only changes of commit 8fbc59499b - Show all commits

View File

@@ -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' },

View File

@@ -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']
};