Skip to content

Commit

Permalink
Question generation service test updated
Browse files Browse the repository at this point in the history
  • Loading branch information
UO287687 committed Apr 4, 2024
1 parent 9b4a055 commit eba121c
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions question_generator/questionGenerationService.test.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
const request = require('supertest');
const axios = require('axios');
const app = require('./questionGenerationService');
let app;

beforeAll(() => {
beforeAll(async () => {
jest.useFakeTimers();
app = require('./questionGenerationService');
});

afterAll(async () => {
await app.close();
jest.useRealTimers();
app.close();
jest.useRealTimers();
});

describe('Question generation service', () => {
Expand All @@ -30,25 +31,25 @@ describe('Question generation service', () => {
expect(response.body).toHaveProperty('question');
expect(response.body).toHaveProperty('correct');
expect(response.body).toHaveProperty('incorrects');
});
}, 100000);

it('should forward create question request to question generation service with sports category', async () => {
it('should forward create question request to question generation service', async () => {
const response = await request(app)
.get('/api/questions/create?category=sports');

expect(response.statusCode).toBe(200);
expect(response.body).toHaveProperty('question');
expect(response.body).toHaveProperty('correct');
expect(response.body).toHaveProperty('incorrects');
});
},100000);

it('should forward create question request to question generation service with geography category', async () => {
it('should forward create question request to question generation service', async () => {
const response = await request(app)
.get('/api/questions/create?category=geography');

expect(response.statusCode).toBe(200);
expect(response.body).toHaveProperty('question');
expect(response.body).toHaveProperty('correct');
expect(response.body).toHaveProperty('incorrects');
});
},100000);
});

0 comments on commit eba121c

Please sign in to comment.