Skip to content

Commit

Permalink
response 201 for added game and question to the db
Browse files Browse the repository at this point in the history
  • Loading branch information
uo276976 committed Mar 4, 2024
1 parent 88c2bc9 commit ac25f92
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion gameservice/game-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ app.post('/addgame', async (req, res) => {
// Guarda el nuevo juego en la base de datos
const savedGame = await newGame.save();

res.status(200).json(savedGame);
res.status(201).json(savedGame);
} catch (error) {
res.status(500).json({ error: 'Internal Server Error' });
}
Expand Down
2 changes: 1 addition & 1 deletion gameservice/game-service.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('Game Service', () => {
};

const response = await request(app).post('/addgame').send(newGame);
expect(response.status).toBe(200);
expect(response.status).toBe(201);
expect(response.body).toHaveProperty('user', newGame.user.toString());
});
});
2 changes: 1 addition & 1 deletion gatewayservice/gateway-service.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ describe('Gateway Service', () => {
incorrects: ['Mocked Option 1', 'Mocked Option 2']
});

expect(response.statusCode).toBe(200);
expect(response.statusCode).toBe(201);
expect(response.body).toHaveProperty('question', 'What is the capital of France?');
});
});
2 changes: 1 addition & 1 deletion questionservice/question-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ app.post('/addquestion', async (req, res) => {
// Guarda la nueva pregunta en la base de datos
const savedQuestion = await newQuestion.save();

res.status(200).json(savedQuestion);
res.status(1).json(savedQuestion);
} catch (error) {
res.status(500).json({ error: 'Internal Server Error' });
}
Expand Down
2 changes: 1 addition & 1 deletion questionservice/question-service.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('Question Service', () => {
};

const response = await request(app).post('/addquestion').send(newQuestion);
expect(response.status).toBe(200);
expect(response.status).toBe(201);
expect(response.body).toHaveProperty('question', 'Mocked Question');
});

Expand Down

0 comments on commit ac25f92

Please sign in to comment.