From 327782998e5bed090732f8ab5b1e38dc47452f4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Fern=C3=A1ndez?= Date: Sat, 6 Apr 2024 17:00:18 +0200 Subject: [PATCH] Aumentados tests user-service --- users/userservice/user-service.test.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/users/userservice/user-service.test.js b/users/userservice/user-service.test.js index 8dd8ea16..1ed02977 100644 --- a/users/userservice/user-service.test.js +++ b/users/userservice/user-service.test.js @@ -1,5 +1,6 @@ const request = require('supertest'); const { MongoMemoryServer } = require('mongodb-memory-server'); +const User = require('./user-model'); let mongoServer; let app; @@ -27,4 +28,19 @@ describe('User Service', () => { expect(response.status).toBe(200); expect(response.body).toHaveProperty('username', 'testuser'); }); + + it('should get all users on GET /users', async () => { + const response = await request(app).get('/users'); + expect(response.status).toBe(200); + expect(Array.isArray(response.body)).toBe(true); + }); + + it('should return 400 when required fields are missing on POST /adduser', async () => { + const newUser = { + username: 'testuser', + }; + + const response = await request(app).post('/adduser').send(newUser); + expect(response.status).toBe(400); + }); });