Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated game service tests #83

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions gameservice/game-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ app.post('/addgame', async (req, res) => {
// Guarda el nuevo juego en la base de datos
const savedGame = await newGame.save();

res.status(201).json(savedGame);
res.status(200).json(savedGame);
} catch (error) {
res.status(500).json({ error: 'Internal Server Error' });
res.status(500).json({ error: error.message });
}
});

Expand Down
15 changes: 3 additions & 12 deletions gameservice/game-service.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
{
Expand All @@ -42,7 +33,7 @@ describe('Game Service', () => {
};

const response = await request(app).post('/addgame').send(newGame);
expect(response.status).toBe(201);
expect(response.status).toBe(200);
expect(response.body).toHaveProperty('user', newGame.user.toString());
});
});
4 changes: 2 additions & 2 deletions 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(201);
expect(response.body).toHaveProperty('question', 'What is the capital of France?');
expect(response.statusCode).toBe(200);
expect(response.body).toHaveProperty('question', 'Mocked Question');
});
});
4 changes: 2 additions & 2 deletions questionservice/question-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(200).json(savedQuestion);
} catch (error) {
res.status(500).json({ error: 'Internal Server Error' });
res.status(500).json({ error: error.message });
}
});

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(201);
expect(response.status).toBe(200);
expect(response.body).toHaveProperty('question', 'Mocked Question');
});

Expand Down