forked from Arquisoft/wiq_0
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #95 from Arquisoft/deployTest
Corrección de fallos para poder desplegar
- Loading branch information
Showing
15 changed files
with
317 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
const request = require('supertest'); | ||
const { MongoMemoryServer } = require('mongodb-memory-server'); | ||
const bcrypt = require('bcrypt'); | ||
const Question = require('./create-model'); | ||
|
||
let mongoServer; | ||
let app; | ||
|
||
//test question | ||
const questionTest = { | ||
questionBody: '¿Cuál es la capital de ', | ||
typeQuestion: 'pais', | ||
typeAnswer: 'capital' | ||
}; | ||
|
||
async function addQuestion(questionTest){ | ||
const newQuestion = new Question({ | ||
questionBody: questionTest.questionBody, | ||
typeQuestion: questionTest.typeQuestion, | ||
typeAnswer: questionTest.typeAnswer | ||
}); | ||
|
||
await newQuestion.save(); | ||
} | ||
|
||
beforeAll(async () => { | ||
mongoServer = await MongoMemoryServer.create(); | ||
const mongoUri = mongoServer.getUri(); | ||
process.env.MONGODB_URI = mongoUri; | ||
app = require('./create-service'); | ||
//Load database with initial conditions | ||
await addQuestion(questionTest); | ||
}); | ||
|
||
afterAll(async () => { | ||
app.close(); | ||
await mongoServer.stop(); | ||
}); | ||
|
||
describe('Create Service', () => { | ||
it('Should perform an addRecord operation /addQuestion', async () => { | ||
const response = await request(app).post('/addQuestion').send(questionTest); | ||
expect(response.status).toBe(200); | ||
expect(response.body).toHaveProperty('questionBody', '¿Cuál es la capital de '); | ||
expect(response.body).toHaveProperty('typeQuestion', 'pais'); | ||
expect(response.body).toHaveProperty('typeAnswer', 'capital'); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
questions/generatedquestservice/generatedquest-service.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
const request = require('supertest'); | ||
const { MongoMemoryServer } = require('mongodb-memory-server'); | ||
const bcrypt = require('bcrypt'); | ||
const GeneratedQuestion = require('./generatedquest-model'); | ||
|
||
let mongoServer; | ||
let app; | ||
|
||
//test generated question | ||
const generatedQuestionTest = { | ||
generatedQuestionBody: '¿Cuál es la capital de España?', | ||
correctAnswer: 'Madrid', | ||
}; | ||
|
||
async function addGeneratedQuestion(generatedQuestionTest){ | ||
const newGeneratedQuestion = new GeneratedQuestion({ | ||
generatedQuestionBody: generatedQuestionTest.generatedQuestionBody, | ||
correctAnswer: generatedQuestionTest.correctAnswer | ||
}); | ||
|
||
await newGeneratedQuestion.save(); | ||
} | ||
|
||
beforeAll(async () => { | ||
mongoServer = await MongoMemoryServer.create(); | ||
const mongoUri = mongoServer.getUri(); | ||
process.env.MONGODB_URI = mongoUri; | ||
app = require('./generatedquest-service'); | ||
//Load database with initial conditions | ||
await addGeneratedQuestion(generatedQuestionTest); | ||
}); | ||
|
||
afterAll(async () => { | ||
app.close(); | ||
await mongoServer.stop(); | ||
}); | ||
|
||
describe('Generatedquest Service', () => { | ||
it('Should perform an addRecord operation /addGeneratedQuestion', async () => { | ||
const response = await request(app).post('/addGeneratedQuestion').send(generatedQuestionTest); | ||
expect(response.status).toBe(200); | ||
expect(response.body).toHaveProperty('generatedQuestionBody', '¿Cuál es la capital de España?'); | ||
expect(response.body).toHaveProperty('correctAnswer', 'Madrid'); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.