diff --git a/users/userservice/user-service.js b/users/userservice/user-service.js index 7cdf1c3..2e0e67e 100644 --- a/users/userservice/user-service.js +++ b/users/userservice/user-service.js @@ -122,8 +122,9 @@ app.post('/adduser', async (req, res) => { }); await newUser.save(); - res.json(newUser); + res.status(200).json(newUser); } catch (error) { + console.log(error) res.status(400).json({ error: error.message }); }}); diff --git a/users/userservice/user-service.test.js b/users/userservice/user-service.test.js index 8dd8ea1..89fc9d9 100644 --- a/users/userservice/user-service.test.js +++ b/users/userservice/user-service.test.js @@ -20,11 +20,16 @@ describe('User Service', () => { it('should add a new user on POST /adduser', async () => { const newUser = { username: 'testuser', + email: 'testemail', password: 'testpassword', }; - const response = await request(app).post('/adduser').send(newUser); + const response = await request(app) + .post('/adduser') + .send(newUser); expect(response.status).toBe(200); - expect(response.body).toHaveProperty('username', 'testuser'); + expect(response.body).toHaveProperty('username', newUser.username); + expect(response.body).toHaveProperty('email', newUser.email); + expect(response.body.password).not.toBe(newUser.password); }); });