From 3a5a56b42cda6527b209b93553735fb27726e290 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Weso=C5=82owski?= Date: Sat, 8 Jun 2024 22:02:58 +0200 Subject: [PATCH] test --- .../integration/pages/api/auth/login.test.ts | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/integration/pages/api/auth/login.test.ts b/tests/integration/pages/api/auth/login.test.ts index cdbb027..b884b8c 100644 --- a/tests/integration/pages/api/auth/login.test.ts +++ b/tests/integration/pages/api/auth/login.test.ts @@ -41,4 +41,28 @@ describe('POST API Route', () => { expect(jsonResponse.error).toBeDefined(); expect(jsonResponse.error).toBe('Ungültiges Passwort'); }); + + it('returns error when email is not registered', async () => { + const mockContext = { + request: { + formData: vi.fn().mockResolvedValue({ + get: vi.fn((key) => { + const data = { + email: 'test@test.com', + password: '1234' + }; + return data[key]; + }), + }) + } + }; + + const response = await POST(mockContext); + + expect(response.status).toBe(400); + + const jsonResponse = await response.json(); + expect(jsonResponse.error).toBeDefined(); + expect(jsonResponse.error).toBe('E-Mail ist bei uns nicht registriert.'); + }); });