f102_test_KeineListeVorhanden #33
@@ -2,7 +2,12 @@ import { render } from '@testing-library/svelte';
|
|||||||
import { describe, expect, it } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
import TatortListPage from "../src/routes/(token-based)/list/[vorgang]/+page.svelte";
|
import TatortListPage from "../src/routes/(token-based)/list/[vorgang]/+page.svelte";
|
||||||
|
|
||||||
|
const testUser = {
|
||||||
|
admin: true,
|
||||||
|
exp: 1757067123,
|
||||||
|
iat: 1757063523,
|
||||||
|
id: "admin",
|
||||||
|
}
|
||||||
const testCrimesList = [
|
const testCrimesList = [
|
||||||
{
|
{
|
||||||
name: 'model-A',
|
name: 'model-A',
|
||||||
@@ -21,21 +26,34 @@ const testCrimesList = [
|
|||||||
show_button: true
|
show_button: true
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
const baseData = {
|
|
||||||
user: {admin: true, id: 'admin'},
|
|
||||||
vorgang: {
|
|
||||||
|
|
||||||
},
|
const testVorgangsList = [
|
||||||
vorgangList: [],
|
{
|
||||||
|
vorgangName: "vorgang-1",
|
||||||
|
vorgangPIN: "pin-123",
|
||||||
|
vorgangToken: "c322f26f-8c5e-4cb9-94b3-b5433bf5109e"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
vorgangName: "vorgang-2",
|
||||||
|
vorgangPIN: "pin-2",
|
||||||
|
vorgangToken: "cb0051bc-5f38-47b8-943c-9352d4d9c984"
|
||||||
|
}
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
|
const baseData = {
|
||||||
|
user: testUser,
|
||||||
|
vorgang: testVorgangsList[0],
|
||||||
|
vorgangList: testVorgangsList,
|
||||||
crimesList: testCrimesList,
|
crimesList: testCrimesList,
|
||||||
url: URL,
|
url: URL,
|
||||||
|
mina marked this conversation as resolved
Outdated
|
|||||||
crimeNames: [],
|
crimeNames: [ "modell-A" ],
|
||||||
|
mina marked this conversation as resolved
Outdated
trachi93
commented
Bitte von Bitte von `testCrimesList` nehmen, sonst magic string.
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('Tatort Liste Page', ()=>{
|
describe('Tatort Liste Page EmptyList-Komponente View', ()=>{
|
||||||
//Hier steht die funktion die getestet wird
|
|
||||||
it('zeigt EmptyList-Komponente, wenn Liste leer ist', () => {
|
it('zeigt EmptyList-Komponente an, wenn Liste leer ist', () => {
|
||||||
const testData = { ...baseData, crimesList: [] };
|
const testData = { ...baseData, crimesList: [] };
|
||||||
const { getByTestId } = render(TatortListPage, {props:{data: testData}});
|
const { getByTestId } = render(TatortListPage, {props:{data: testData}});
|
||||||
|
|
||||||
@@ -43,11 +61,11 @@ describe('Tatort Liste Page', ()=>{
|
|||||||
expect(getByTestId('empty-list')).toBeInTheDocument();
|
expect(getByTestId('empty-list')).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('zeigt EmptyList-Komponente, wenn Liste vorhanden ist', () => {
|
it('zeigt Liste(min. 1 li-Element) an, wenn Liste vorhanden ist', () => {
|
||||||
const testData = { ...baseData };
|
const testData = { ...baseData };
|
||||||
const { getAllByTestId } = render(TatortListPage, {props:{data: testData}});
|
const { getAllByTestId } = render(TatortListPage, {props:{data: testData}});
|
||||||
const items = getAllByTestId('test-list-item');
|
const items = getAllByTestId('test-list-item');
|
||||||
|
|
||||||
expect(items).toHaveLength(2); // z. B. bei 2 Einträgen, da fake 2 Einträge hat
|
expect(items).toHaveLength(2);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -50,20 +50,19 @@ const baseData = {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('Vorgänge Liste Page', ()=>{
|
describe('Vorgänge Liste Page EmptyList-Komponente View', ()=>{
|
||||||
//Hier steht die funktion die getestet wird
|
it('zeigt EmptyList-Komponente an, wenn Liste leer ist', () => {
|
||||||
it('zeigt EmptyList-Komponente, wenn Liste leer ist', () => {
|
|
||||||
const testData = { ...baseData, vorgangList: [] };
|
const testData = { ...baseData, vorgangList: [] };
|
||||||
const { getByTestId } = render(VorgangListPage, {props:{data: testData}});
|
const { getByTestId } = render(VorgangListPage, {props:{data: testData}});
|
||||||
|
|
||||||
expect(getByTestId('empty-list')).toBeInTheDocument();
|
expect(getByTestId('empty-list')).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('zeigt EmptyList-Komponente, wenn Liste vorhanden ist', () => {
|
it('zeigt Liste(min. 1 li-Element) an, wenn Liste vorhanden ist', () => {
|
||||||
const testData = { ...baseData };
|
const testData = { ...baseData };
|
||||||
const { getAllByTestId } = render(VorgangListPage, {props:{data: testData}});
|
const { getAllByTestId } = render(VorgangListPage, {props:{data: testData}});
|
||||||
const items = getAllByTestId('test-list-item');
|
const items = getAllByTestId('test-list-item');
|
||||||
|
|
||||||
expect(items).toHaveLength(2); // z. B. bei 2 Einträgen, da fake 2 Einträge hat
|
expect(items).toHaveLength(2);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user
URL ist nicht definiert.
in f086 PR ist URL definiert.