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

40
tests/api/User.test.ts Normal file
View File

@@ -0,0 +1,40 @@
import { describe, test, expect } from 'vitest';
import { GET } from '$root/routes/api/user/+server';
const id = 'admin';
describe('API-Endpoints: User ist Admin', () => {
test('User ist Admin', async () => {
const admin = true;
const event = {
locals: {
user: { id, admin }
}
};
const fakeResult = { admin };
const response = await GET(event);
expect(response.status).toBe(200);
const json = await response.json();
expect(json).toEqual(fakeResult);
});
test('User ist kein Admin', async () => {
const admin = false;
const event = {
locals: {
user: { id, admin }
}
};
const fakeResult = { admin };
const response = await GET(event);
expect(response.status).toBe(200);
const json = await response.json();
expect(json).toEqual(fakeResult);
});
});