Skip to content

Commit

Permalink
ALCS-2345 Fix failed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fbarreta committed Oct 30, 2024
1 parent ff6926c commit cca19c9
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
import { Test, TestingModule } from '@nestjs/testing';
import { NoticeOfIntentTagController } from './notice-of-intent-tag.controller';
import { NoticeOfIntentTagService } from './notice-of-intent-tag.service';
import { DeepMocked } from '@golevelup/nestjs-testing';
import { ClsService } from 'nestjs-cls';
import { mockKeyCloakProviders } from '../../../../test/mocks/mockTypes';

describe('NoticeOfIntentTagController', () => {
let controller: NoticeOfIntentTagController;
let tagService: DeepMocked<NoticeOfIntentTagService>;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [NoticeOfIntentTagController],
providers: [
{ provide: NoticeOfIntentTagService, useValue: tagService },
{
provide: ClsService,
useValue: {},
},
...mockKeyCloakProviders,
],
}).compile();

controller = module.get<NoticeOfIntentTagController>(NoticeOfIntentTagController);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
import { Test, TestingModule } from '@nestjs/testing';
import { NoticeOfIntentTagService } from './notice-of-intent-tag.service';
import { getRepositoryToken } from '@nestjs/typeorm';
import { NoticeOfIntent } from '../notice-of-intent.entity';
import { createMock, DeepMocked } from '@golevelup/nestjs-testing';
import { Repository } from 'typeorm';
import { Tag } from '../../tag/tag.entity';

describe('NoticeOfIntentTagService', () => {
let service: NoticeOfIntentTagService;
let noiRepository: DeepMocked<Repository<NoticeOfIntent>>;
let tagRepository: DeepMocked<Repository<Tag>>;

beforeEach(async () => {
noiRepository = createMock();
const module: TestingModule = await Test.createTestingModule({
providers: [NoticeOfIntentTagService],
providers: [
NoticeOfIntentTagService,
{
provide: getRepositoryToken(NoticeOfIntent),
useValue: noiRepository,
},
{
provide: getRepositoryToken(Tag),
useValue: tagRepository,
},
],
}).compile();

service = module.get<NoticeOfIntentTagService>(NoticeOfIntentTagService);
Expand Down

0 comments on commit cca19c9

Please sign in to comment.