Skip to content

Commit

Permalink
Mocked existance of the question in unit tests for question generation
Browse files Browse the repository at this point in the history
  • Loading branch information
PabloGOP committed Apr 28, 2024
1 parent 69c410f commit 7f263b5
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions questions/__tests/services/question-generation-service.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const generalQuestions = require('../../utils/generalQuestions');
jest.mock('../../utils/generalQuestions');
jest.mock('../../services/wikidata-service');
jest.mock('../../services/question-data-service', () => ({
getQuestion: jest.fn(),
addQuestion: jest.fn(), // Mockear la función addQuestion para que no haga nada
}));

Expand All @@ -15,15 +16,10 @@ const entity = {
"properties": [
{
"property": "P1082",
"template":
[{
"lang": "es",
"question": "Cuál es la población de x"
},
{
"lang": "en",
"question": "What is the population of x"
}],
"template": {
"es": "Cuál es la población de x",
"en": "What is the population of x"
},
"filter": ">1000000",
"category": ["Geography"]
}
Expand All @@ -48,8 +44,9 @@ describe('Question generation', function() {
wikidataService.getProperties.mockResolvedValue(['Barcelona', 'Paris', 'London']);
wikidataService.convertUrlsToLabels.mockResolvedValue(['Barcelona', 'Paris', 'London','Madrid']);

generalQuestions.shuffleArray.mockResolvedValue(['Barcelona', 'Paris', 'London','Madrid'])
generalQuestions.shuffleArray.mockResolvedValue(['Barcelona', 'Paris', 'London','Madrid']);

dbService.getQuestion.mockResolvedValue("undefined");
dbService.addQuestion.mockResolvedValue();
// Llama a la función que deseas probar
await generator.generateQuestions(1,"en","Geography");
Expand Down

0 comments on commit 7f263b5

Please sign in to comment.