From 5e303bbf0e1a727b4595d35cab9943df0f2118e1 Mon Sep 17 00:00:00 2001 From: uo289029 Date: Sat, 27 Apr 2024 11:30:01 +0200 Subject: [PATCH] another try to make it work --- questionsgenerator/questions-service.test.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/questionsgenerator/questions-service.test.js b/questionsgenerator/questions-service.test.js index 12bde39..f21d12a 100644 --- a/questionsgenerator/questions-service.test.js +++ b/questionsgenerator/questions-service.test.js @@ -6,6 +6,7 @@ const sinonMongoose = require('sinon-mongoose'); const Question = require('./question-model'); const Template = require('./templates/template-model'); const QuestionGenerator = require('./questionGenerator.js'); +const mongoose = require('mongoose'); let mongoServer; let app; @@ -29,23 +30,22 @@ beforeAll(async () => { //mock the deleteOne from the service const deleteOneStub = sinon.stub(Question, 'deleteOne'); deleteOneStub.resolves({ n: 1 }); - }); afterAll(async () => { - await mongoServer.stop(); - await app.close(); - sinon.restore(); + app.close(); + await mongoose.connection.close(); + await mongoServer.stop(); }); describe('Questions Service', () => { - it('should get a new question on POST /getQuestion', async () => { - /**const category = "todo"; + it('should get a new question on GET /getQuestion', async () => { + const category = "todo"; const response = await request(app).get('/getQuestion').query({ category });; expect(response.status).toBe(200); expect(response.body).toHaveProperty('question'); expect(response.body).toHaveProperty('correctAnswerLabel'); - expect(response.body).toHaveProperty('answerLabelSet');**/ + expect(response.body).toHaveProperty('answerLabelSet'); }); });