Files
tatort/tests/TatortList.view.test.ts

54 lines
1.5 KiB
TypeScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { render } from '@testing-library/svelte';
import { describe, expect, it } from "vitest";
import TatortListPage from "../src/routes/(token-based)/list/[vorgang]/+page.svelte";
const testCrimesList = [
{
name: 'model-A',
lastModified: '2025-08-28T09:44:12.453Z',
etag: '558f35716f6af953f9bb5d75f6d77e6a',
size: 8947140,
prefix: '7596e4d5-c51f-482d-a4aa-ff76434305fc',
show_button: true
},
{
name: 'model-z',
lastModified: '2025-08-28T10:37:20.142Z',
etag: '43e3989c32c4682bee407baaf83b6fa0',
size: 35788560,
prefix: '7596e4d5-c51f-482d-a4aa-ff76434305fc',
show_button: true
}
];
const baseData = {
user: {admin: true, id: 'admin'},
vorgang: {
},
vorgangList: [],
crimesList: testCrimesList,
url: URL,
crimeNames: [],
}
describe('Tatort Liste Page', ()=>{
//Hier steht die funktion die getestet wird
it('zeigt EmptyList-Komponente, wenn Liste leer ist', () => {
const testData = { ...baseData, crimesList: [] };
const { getByTestId } = render(TatortListPage, {props:{data: testData}});
expect(getByTestId('empty-list')).toBeInTheDocument();
});
it('zeigt EmptyList-Komponente, wenn Liste vorhanden ist', () => {
const testData = { ...baseData };
const { getAllByTestId } = render(TatortListPage, {props:{data: testData}});
const items = getAllByTestId('test-list-item');
expect(items).toHaveLength(2); // z.B. bei 2 Einträgen, da fake 2 Einträge hat
});
})