Archived
1
0

feat/tests #5

Merged
mrqiz merged 7 commits from feat/tests into lord 2025-11-26 00:06:35 +03:00
2 changed files with 55 additions and 0 deletions
Showing only changes of commit 35fd995d2d - Show all commits

View File

@ -0,0 +1,36 @@
import { describe, expect, test, } from 'bun:test';
describe('E2E: Authentication', () => {
const testUser = {
name: 'Test User',
email: `test-${Date.now()}@example.com`,
password: 'TestPassword123!',
};
let authCookie: string;
let userId: string;
test('should register new user', async () => {
const response = await fetch('http://localhost:3000/auth/api/sign-up/email', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(testUser),
});
expect(response.status).toBe(200);
const data = await response.json() as unknown as any;
expect(data.user).toBeDefined();
expect(data.user.email).toBe(testUser.email);
expect(data.user.name).toBe(testUser.name);
userId = data.user.id;
// Получаем cookies из ответа
const setCookieHeader = response.headers.get('set-cookie');
expect(setCookieHeader).toBeDefined();
authCookie = setCookieHeader!;
});
});