From 945bf18fe125fd9857e594b91b8cf1428c1373c1 Mon Sep 17 00:00:00 2001 From: Alfonso Date: Mon, 4 Mar 2024 14:42:41 +0100 Subject: [PATCH] updated game service tests --- gameservice/game-service.js | 2 +- gameservice/game-service.test.js | 13 ++----------- questionservice/question-service.js | 4 ++-- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/gameservice/game-service.js b/gameservice/game-service.js index 3d1fbc29..74f7d8de 100644 --- a/gameservice/game-service.js +++ b/gameservice/game-service.js @@ -40,7 +40,7 @@ app.post('/addgame', async (req, res) => { res.status(201).json(savedGame); } catch (error) { - res.status(500).json({ error: 'Internal Server Error' }); + res.status(500).json({ error: error.message }); } }); diff --git a/gameservice/game-service.test.js b/gameservice/game-service.test.js index 88b5ba78..12c0b811 100644 --- a/gameservice/game-service.test.js +++ b/gameservice/game-service.test.js @@ -19,18 +19,9 @@ afterAll(async () => { describe('Game Service', () => { it('should add a new game on POST /addgame', async () => { const newGame = { - user: 'testUser', + user: '609c6e365308ce1a1c2658d1', questions: [ - { - question: 'Mocked Question', - correct: 'Mocked Correct Answer', - incorrects: ['Mocked Option 1', 'Mocked Option 2'] - }, - { - question: 'Mocked Question2', - correct: 'Mocked Correct Answer2', - incorrects: ['Mocked Option 1', 'Mocked Option 2'] - } + "609c6e365308ce1a1c2658d2", "609c6e365308ce1a1c2658d3" ], answers: [ { diff --git a/questionservice/question-service.js b/questionservice/question-service.js index 6dcfccca..2e764beb 100644 --- a/questionservice/question-service.js +++ b/questionservice/question-service.js @@ -37,9 +37,9 @@ app.post('/addquestion', async (req, res) => { // Guarda la nueva pregunta en la base de datos const savedQuestion = await newQuestion.save(); - res.status(1).json(savedQuestion); + res.status(201).json(savedQuestion); } catch (error) { - res.status(500).json({ error: 'Internal Server Error' }); + res.status(500).json({ error: error.message }); } });