f100_backend_api-endpoints_tests #31

Merged
jared merged 17 commits from f100_backend_api-endpoints_tests into development 2025-09-04 15:16:50 +02:00
Showing only changes of commit c222d75ac5 - Show all commits

40
tests/APIUser.test.ts Normal file
View File

@@ -0,0 +1,40 @@
import { describe, test, expect, vi } from 'vitest';
import { GET } from '../src/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);
});
});