Skip to content

Commit

Permalink
Fixed Backend broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
maikofelix47 committed Jul 25, 2023
1 parent 3ce6437 commit e9fd211
Show file tree
Hide file tree
Showing 13 changed files with 272 additions and 66 deletions.
22 changes: 18 additions & 4 deletions apps/back-end/src/answer-type/answer-type.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,32 @@
import { Test, TestingModule } from '@nestjs/testing';
import { AnswerTypeController } from './answer-type.controller';
import { AnswerTypeService } from './answer-type.service';

const mockAnswerTypeService = {};
describe('AnswerTypeController', () => {
let controller: AnswerTypeController;
let answerTypeController: AnswerTypeController;
let answerTypeService: AnswerTypeService;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [AnswerTypeController],
providers: [
{
provide: AnswerTypeService,
useValue: mockAnswerTypeService,
},
],
}).compile();

controller = module.get<AnswerTypeController>(AnswerTypeController);
answerTypeController =
module.get<AnswerTypeController>(AnswerTypeController);
answerTypeService = module.get<AnswerTypeService>(AnswerTypeService);
});

it('should be defined', () => {
expect(controller).toBeDefined();
it('answer-type controller should be defined', () => {
expect(answerTypeController).toBeDefined();
});
it('answer-type service should be defined', () => {
expect(answerTypeService).toBeDefined();
});
});
15 changes: 11 additions & 4 deletions apps/back-end/src/answer-type/answer-type.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
import { Test, TestingModule } from '@nestjs/testing';
import { AnswerTypeService } from './answer-type.service';

const mockAnswerTypeService = {};

describe('AnswerTypeService', () => {
let service: AnswerTypeService;
let answerTpeservice: AnswerTypeService;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [AnswerTypeService],
providers: [
{
provide: AnswerTypeService,
useValue: mockAnswerTypeService,
},
],
}).compile();

service = module.get<AnswerTypeService>(AnswerTypeService);
answerTpeservice = module.get<AnswerTypeService>(AnswerTypeService);
});

it('should be defined', () => {
expect(service).toBeDefined();
expect(answerTpeservice).toBeDefined();
});
});
44 changes: 40 additions & 4 deletions apps/back-end/src/answer/answer.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,54 @@
import { Test, TestingModule } from '@nestjs/testing';
import { EncountersService } from '../encounters/encounters.service';
import { QuestionService } from '../question/question.service';
import { AnswerController } from './answer.controller';
import { AnswerService } from './answer.service';

const mockAnswerService = {};
const mockQuestionService = {};
const mockEncounterService = {};

describe('AnswerController', () => {
let controller: AnswerController;
let answerController: AnswerController;
let answerService: AnswerService;
let qstnService: QuestionService;
let encounterService: EncountersService;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [AnswerController],
providers: [
{
provide: AnswerService,
useValue: mockAnswerService,
},
{
provide: QuestionService,
useValue: mockQuestionService,
},
{
provide: EncountersService,
useValue: mockEncounterService,
},
],
}).compile();

controller = module.get<AnswerController>(AnswerController);
answerController = module.get<AnswerController>(AnswerController);
answerService = module.get<AnswerService>(AnswerService);
qstnService = module.get<QuestionService>(QuestionService);
encounterService = module.get<EncountersService>(EncountersService);
});

it('should be defined', () => {
expect(controller).toBeDefined();
it('answer controller should be defined', () => {
expect(answerController).toBeDefined();
});
it('question service should be defined', () => {
expect(qstnService).toBeDefined();
});
it('answer service should be defined', () => {
expect(answerService).toBeDefined();
});
it('encounters service should be defined', () => {
expect(encounterService).toBeDefined();
});
});
2 changes: 0 additions & 2 deletions apps/back-end/src/answer/answer.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ import { Answer } from '@prisma/client';
import { AnswerService } from './answer.service';
import { AnsDto, AnswerDto, CreateAnswerDto } from './dtos/create-answer.dto';
import { QuestionService } from '../question/question.service';
import { AnswerTypeService } from '../answer-type/answer-type.service';
import { EncountersService } from '../encounters/encounters.service';

@Controller('answer')
export class AnswerController {
constructor(
private answerService: AnswerService,
private qstnService: QuestionService,
private ansTypeService: AnswerTypeService,
private encounterService: EncountersService
) {}
@Get()
Expand Down
9 changes: 1 addition & 8 deletions apps/back-end/src/answer/answer.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,10 @@ import { AnswerService } from './answer.service';
import { AnswerController } from './answer.controller';
import { PrismaService } from '../app/prisma/prisma.service';
import { QuestionService } from '../question/question.service';
import { AnswerTypeService } from '../answer-type/answer-type.service';
import { EncountersService } from '../encounters/encounters.service';

@Module({
providers: [
AnswerService,
PrismaService,
QuestionService,
AnswerTypeService,
EncountersService,
],
providers: [AnswerService, PrismaService, QuestionService, EncountersService],
controllers: [AnswerController],
})
export class AnswerModule {}
17 changes: 12 additions & 5 deletions apps/back-end/src/answer/answer.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
import { Test, TestingModule } from '@nestjs/testing';
import { AnswerService } from './answer.service';

const mockAnswerService = {};

describe('AnswerService', () => {
let service: AnswerService;
let answerService: AnswerService;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [AnswerService],
providers: [
{
provide: AnswerService,
useValue: mockAnswerService,
},
],
}).compile();

service = module.get<AnswerService>(AnswerService);
answerService = module.get<AnswerService>(AnswerService);
});

it('should be defined', () => {
expect(service).toBeDefined();
it('answer service should be defined', () => {
expect(answerService).toBeDefined();
});
});
46 changes: 42 additions & 4 deletions apps/back-end/src/form-question/form-question.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,56 @@
import { Test, TestingModule } from '@nestjs/testing';
import { FormService } from '../form/form.service';
import { QuestionService } from '../question/question.service';
import { FormQuestionController } from './form-question.controller';
import { FormQuestionService } from './form-question.service';

const mockFormQuestionService = {};
const mockFormService = {};
const mockQuestionService = {};

describe('FormQuestionController', () => {
let controller: FormQuestionController;
let formQuestionController: FormQuestionController;
let formQuestionService: FormQuestionService;
let formService: FormService;
let questionService: QuestionService;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [FormQuestionController],
providers: [
{
provide: FormQuestionService,
useValue: mockFormQuestionService,
},
{
provide: FormService,
useValue: mockFormService,
},
{
provide: QuestionService,
useValue: mockQuestionService,
},
],
}).compile();

controller = module.get<FormQuestionController>(FormQuestionController);
formQuestionController = module.get<FormQuestionController>(
FormQuestionController
);
formQuestionService = module.get<FormQuestionService>(FormQuestionService);
formService = module.get<FormService>(FormService);
questionService = module.get<QuestionService>(QuestionService);
});

it('should be defined', () => {
expect(controller).toBeDefined();
it('form question controller should be defined', () => {
expect(formQuestionController).toBeDefined();
});
it('form question service should be defined', () => {
expect(formQuestionService).toBeDefined();
});
it('form service should be defined', () => {
expect(formService).toBeDefined();
});
it('question service should be defined', () => {
expect(questionService).toBeDefined();
});
});
17 changes: 12 additions & 5 deletions apps/back-end/src/form-question/form-question.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
import { Test, TestingModule } from '@nestjs/testing';
import { FormQuestionService } from './form-question.service';

const mockFormQuestionService = {};

describe('FormQuestionService', () => {
let service: FormQuestionService;
let formQuestionService: FormQuestionService;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [FormQuestionService],
providers: [
{
provide: FormQuestionService,
useValue: mockFormQuestionService,
},
],
}).compile();

service = module.get<FormQuestionService>(FormQuestionService);
formQuestionService = module.get<FormQuestionService>(FormQuestionService);
});

it('should be defined', () => {
expect(service).toBeDefined();
it('form question service should be defined', () => {
expect(formQuestionService).toBeDefined();
});
});
35 changes: 31 additions & 4 deletions apps/back-end/src/form/form.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,45 @@
import { Test, TestingModule } from '@nestjs/testing';
import { EncounterTypesService } from '../encounter-types/encounter-types.service';
import { FormController } from './form.controller';
import { FormService } from './form.service';

const mockFormService = {};
const mockEncounterTypeService = {};

describe('FormController', () => {
let controller: FormController;
let formController: FormController;
let formService: FormService;
let encounterTypeService: EncounterTypesService;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [FormController],
providers: [
{
provide: FormService,
useValue: mockFormService,
},
{
provide: EncounterTypesService,
useValue: mockEncounterTypeService,
},
],
}).compile();

controller = module.get<FormController>(FormController);
formController = module.get<FormController>(FormController);
formService = module.get<FormService>(FormService);
encounterTypeService = module.get<EncounterTypesService>(
EncounterTypesService
);
});

it('should be defined', () => {
expect(controller).toBeDefined();
it('form controller should be defined', () => {
expect(formController).toBeDefined();
});
it('form service should be defined', () => {
expect(formService).toBeDefined();
});
it('encounter-type service should be defined', () => {
expect(encounterTypeService).toBeDefined();
});
});
15 changes: 11 additions & 4 deletions apps/back-end/src/form/form.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
import { Test, TestingModule } from '@nestjs/testing';
import { FormService } from './form.service';

class mockFormService {}

describe('FormService', () => {
let service: FormService;
let formService: FormService;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [FormService],
providers: [
{
provide: FormService,
useClass: mockFormService,
},
],
}).compile();

service = module.get<FormService>(FormService);
formService = module.get<FormService>(FormService);
});

it('should be defined', () => {
expect(service).toBeDefined();
expect(formService).toBeDefined();
});
});
Loading

0 comments on commit e9fd211

Please sign in to comment.