organize tests into units

This commit is contained in:
2025-09-30 11:43:54 +02:00
parent e1e76612d6
commit 2863eae3fb
13 changed files with 22 additions and 22 deletions

View File

@@ -0,0 +1,29 @@
import { describe, test, expect } from 'vitest';
import { load } from '$root/routes/(angemeldet)/+layout.server';
import { ROUTE_NAMES } from '../../src/routes';
import { baseData, mockEvent } from '../fixtures';
describe('+layout.server load(): Teste korrekte URL', () => {
test('Werfe redirect zu /anmeldung wenn User nicht eingeloggt', async () => {
const mockEvent = {
locals: {
user: null
},
url: new URL(`https://example.com/not-anmeldung`)
};
try {
load(mockEvent);
throw new Error('Expected load() to throw');
} catch (err) {
expect(err.status).toBe(303);
expect(err.location).toBe(ROUTE_NAMES.ANMELDUNG);
}
});
});
describe('+layout.server load(): Teste erfolgreichen Pfad', () => {
test('Werfe kein Fehler', async () => {
const result = load(mockEvent);
expect(result).toEqual({ user: baseData.user });
});
});