Skip to content

Commit

Permalink
fixing gateways tests all work
Browse files Browse the repository at this point in the history
  • Loading branch information
uo289029 committed Mar 11, 2024
1 parent a994f95 commit 2272e37
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions gatewayservice/gateway-service.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,6 @@ describe('Gateway Service', () => {
return Promise.resolve({ data: { token: 'mockedToken' } });
} else if (url.endsWith('/adduser')) {
return Promise.resolve({ data: { userId: 'mockedUserId' } });
} else if (url.endsWith('/getQuestion')) {
return Promise.resolve({
data: {
question: "¿Cuál es la capital de España?",
correctAnswerLabel: "Madrid",
answerLabelSet: ["Estocolmo", "Madrid", "Oslo", "Copenhague"]
}
});
} else if(url.endsWith('/saveHistorial')){
return Promise.resolve({ data: { message: 'Historial saved' } });
} else if(url.endsWith('/getHistorial')){
Expand All @@ -41,9 +33,18 @@ describe('Gateway Service', () => {
}
],
});
} else if (url.endsWith('/getQuestion')) {
return Promise.resolve({
data: {
question: "¿Cuál es la capital de España?",
correctAnswerLabel: "Madrid",
answerLabelSet: ["Estocolmo", "Madrid", "Oslo", "Copenhague"]
}
});
}
});


// Test /login endpoint
it('should forward login request to auth service', async () => {
const response = await request(app)
Expand All @@ -67,7 +68,7 @@ describe('Gateway Service', () => {
// Test /getQuestion endpoint
it('should forward get question reques to question service', async () => {
const response = await request(app)
.get('/getQuestion');
.post('/getQuestion');

expect(response.statusCode).toBe(200);
expect(response.body.question).toBe("¿Cuál es la capital de España?");
Expand All @@ -77,7 +78,7 @@ describe('Gateway Service', () => {
// Test /getQuestion endpoint
it('should forward save historial request to historial service', async () => {
const response = await request(app)
.get('/saveHistorial')
.post('/saveHistorial')
.send({ question: '¿Cuál es la capital de España?', answersArray: ['Madrid', 'Barcelona', 'Valencia', 'Sevilla'],correctAnswer: 'Madrid', selectedAnswer: 'Madrid', correct: true, username2: 'testuser'});

expect(response.statusCode).toBe(200);
Expand All @@ -86,7 +87,7 @@ describe('Gateway Service', () => {

it('should forward get historial request to historial service', async () => {
const response = await request(app)
.get('/getHistorial')
.post('/getHistorial')
.send({ username2: 'testuser'});

expect(response.statusCode).toBe(200);
Expand Down

0 comments on commit 2272e37

Please sign in to comment.