refactoring: magic strings and tests for Vorgang overview page
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
import Trash from '$lib/icons/Trash.svelte';
|
import Trash from '$lib/icons/Trash.svelte';
|
||||||
import Folder from '$lib/icons/Folder.svelte';
|
import Folder from '$lib/icons/Folder.svelte';
|
||||||
import EmptyList from '$lib/components/EmptyList.svelte';
|
import EmptyList from '$lib/components/EmptyList.svelte';
|
||||||
|
import { ROUTE_NAMES } from '../../index.js';
|
||||||
|
|
||||||
let { data } = $props();
|
let { data } = $props();
|
||||||
|
|
||||||
@@ -49,7 +50,7 @@
|
|||||||
{#each vorgangList as vorgangItem}
|
{#each vorgangList as vorgangItem}
|
||||||
<li data-testid="test-list-item">
|
<li data-testid="test-list-item">
|
||||||
<a
|
<a
|
||||||
href="/list/{vorgangItem.vorgangToken}?pin={vorgangItem.vorgangPIN}"
|
href="{ROUTE_NAMES.VORGANG(vorgangItem.vorgangToken, vorgangItem.vorgangPIN)}"
|
||||||
class="flex justify-between gap-x-6 py-5"
|
class="flex justify-between gap-x-6 py-5"
|
||||||
>
|
>
|
||||||
<div class="flex gap-x-4">
|
<div class="flex gap-x-4">
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import { render } from '@testing-library/svelte';
|
import { render, screen, within } from '@testing-library/svelte';
|
||||||
import { describe, expect, it } from 'vitest';
|
import { describe, expect, it } from 'vitest';
|
||||||
import VorgangListPage from '../src/routes/(angemeldet)/list/+page.svelte';
|
import VorgangListPage from '../src/routes/(angemeldet)/list/+page.svelte';
|
||||||
import { baseData } from './fixtures';
|
import { baseData } from './fixtures';
|
||||||
|
import { ROUTE_NAMES } from '../src/routes';
|
||||||
|
|
||||||
describe('Vorgänge Liste Page EmptyList-Komponente View', () => {
|
describe('Vorgänge Liste Page EmptyList-Komponente View', () => {
|
||||||
it('zeigt EmptyList-Komponente an, wenn Liste leer ist', () => {
|
it('zeigt EmptyList-Komponente an, wenn Liste leer ist', () => {
|
||||||
@@ -19,3 +20,17 @@ describe('Vorgänge Liste Page EmptyList-Komponente View', () => {
|
|||||||
expect(items.length).toBeGreaterThan(0);
|
expect(items.length).toBeGreaterThan(0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('Teste Links auf Korrektheit', () => {
|
||||||
|
it('Überprüfe Links', () => {
|
||||||
|
const vorgListOneItem = baseData.vorgangList.slice(0, 1);
|
||||||
|
const vorgObj = vorgListOneItem[0];
|
||||||
|
const expectedURL = ROUTE_NAMES.VORGANG(vorgObj.vorgangToken, vorgObj.vorgangPIN)
|
||||||
|
|
||||||
|
render(VorgangListPage, { props: { data: { ...baseData, vorgangList: vorgListOneItem } } });
|
||||||
|
const listItem = screen.getByTestId("test-list-item");
|
||||||
|
const linkElement = within(listItem).getByRole('link');
|
||||||
|
expect(linkElement).toBeInTheDocument();
|
||||||
|
expect(linkElement).toHaveAttribute('href', expectedURL);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user