Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
MBergCap committed Sep 29, 2024
1 parent 62fcf84 commit 888fa85
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,5 +149,6 @@ export const externalToolFactory = ExternalToolFactory.define(ExternalTool, ({ s
isDeactivated: false,
openNewTab: false,
createdAt: new Date(2020, 1, 1),
restrictToContexts: undefined,
};
});
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ export const schoolExternalToolFactory = SchoolExternalToolFactory.define(School
toolId: 'toolId',
isDeactivated: false,
status: schoolExternalToolConfigurationStatusFactory.build(),
restrictToContexts: undefined,
};
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import { SchoolExternalToolService, SchoolExternalToolValidationService } from '
import { schoolExternalToolFactory } from '../testing';
import { SchoolExternalToolQueryInput } from './dto/school-external-tool.types';
import { SchoolExternalToolUc } from './school-external-tool.uc';
import { ExternalToolService } from '@modules/tool';
import { ExternalTool } from '@modules/tool/external-tool/domain';
import { externalToolFactory } from '@modules/tool/external-tool/testing';

describe('SchoolExternalToolUc', () => {
let module: TestingModule;
Expand All @@ -23,6 +26,7 @@ describe('SchoolExternalToolUc', () => {
let commonToolMetadataService: DeepMocked<CommonToolMetadataService>;
let authorizationService: DeepMocked<AuthorizationService>;
let schoolService: DeepMocked<SchoolService>;
let externalToolService: DeepMocked<ExternalToolService>;

beforeAll(async () => {
await setupEntities();
Expand All @@ -49,6 +53,10 @@ describe('SchoolExternalToolUc', () => {
provide: SchoolService,
useValue: createMock<SchoolService>(),
},
{
provide: ExternalToolService,
useValue: createMock<ExternalToolService>(),
},
],
}).compile();

Expand All @@ -58,6 +66,7 @@ describe('SchoolExternalToolUc', () => {
commonToolMetadataService = module.get(CommonToolMetadataService);
authorizationService = module.get(AuthorizationService);
schoolService = module.get(SchoolService);
externalToolService = module.get(ExternalToolService);
});

afterAll(async () => {
Expand All @@ -74,10 +83,12 @@ describe('SchoolExternalToolUc', () => {
const tool: SchoolExternalTool = schoolExternalToolFactory.buildWithId();
const user: User = userFactory.buildWithId();
const school: School = schoolFactory.build({ id: tool.schoolId });
const externalTool: ExternalTool = externalToolFactory.build();

schoolExternalToolService.findSchoolExternalTools.mockResolvedValue([tool]);
authorizationService.getUserWithPermissions.mockResolvedValueOnce(user);
schoolService.getSchoolById.mockResolvedValueOnce(school);
externalToolService.findById.mockResolvedValueOnce(externalTool);

return {
user,
Expand Down Expand Up @@ -139,8 +150,10 @@ describe('SchoolExternalToolUc', () => {
const setup = () => {
const tool: SchoolExternalTool = schoolExternalToolFactory.buildWithId();
const user: User = userFactory.buildWithId();
const externalTool: ExternalTool = externalToolFactory.buildWithId({ id: tool.toolId });

schoolExternalToolService.findSchoolExternalTools.mockResolvedValue([tool, tool]);
externalToolService.findById.mockResolvedValue(externalTool);

return {
user,
Expand Down

0 comments on commit 888fa85

Please sign in to comment.