diff --git a/apps/server/src/modules/tool/external-tool/service/external-tool-metadata.service.spec.ts b/apps/server/src/modules/tool/external-tool/service/external-tool-metadata.service.spec.ts index c2caf123815..4753cc805f4 100644 --- a/apps/server/src/modules/tool/external-tool/service/external-tool-metadata.service.spec.ts +++ b/apps/server/src/modules/tool/external-tool/service/external-tool-metadata.service.spec.ts @@ -1,7 +1,7 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { ObjectId } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; -import { ContextExternalToolRepo, ExternalToolRepo, SchoolExternalToolRepo } from '@shared/repo'; +import { ContextExternalToolRepo, SchoolExternalToolRepo } from '@shared/repo'; import { externalToolFactory, legacySchoolDoFactory, schoolExternalToolFactory } from '@shared/testing'; import { ContextExternalToolType } from '../../context-external-tool/entity'; import { SchoolExternalTool } from '../../school-external-tool/domain'; @@ -12,7 +12,6 @@ describe('ExternalToolMetadataService', () => { let module: TestingModule; let service: ExternalToolMetadataService; - let externalToolRepo: DeepMocked; let schoolExternalToolRepo: DeepMocked; let contextExternalToolRepo: DeepMocked; @@ -20,10 +19,6 @@ describe('ExternalToolMetadataService', () => { module = await Test.createTestingModule({ providers: [ ExternalToolMetadataService, - { - provide: ExternalToolRepo, - useValue: createMock(), - }, { provide: SchoolExternalToolRepo, useValue: createMock(), @@ -36,7 +31,6 @@ describe('ExternalToolMetadataService', () => { }).compile(); service = module.get(ExternalToolMetadataService); - externalToolRepo = module.get(ExternalToolRepo); schoolExternalToolRepo = module.get(SchoolExternalToolRepo); contextExternalToolRepo = module.get(ContextExternalToolRepo); }); @@ -53,7 +47,6 @@ describe('ExternalToolMetadataService', () => { describe('when externalToolId is given', () => { const setup = () => { const toolId: string = new ObjectId().toHexString(); - const externalTool: ExternalTool = externalToolFactory.buildWithId(undefined, toolId); const school = legacySchoolDoFactory.buildWithId(); const school1 = legacySchoolDoFactory.buildWithId(); @@ -76,7 +69,6 @@ describe('ExternalToolMetadataService', () => { contextExternalToolCountPerContext: { course: 3, boardElement: 3 }, }); - externalToolRepo.findById.mockResolvedValue(externalTool); schoolExternalToolRepo.findByExternalToolId.mockResolvedValue([schoolExternalTool, schoolExternalTool1]); contextExternalToolRepo.countBySchoolToolIdsAndContextType.mockResolvedValue(3); @@ -131,7 +123,6 @@ describe('ExternalToolMetadataService', () => { contextExternalToolCountPerContext: { course: 0, boardElement: 0 }, }); - externalToolRepo.findById.mockResolvedValue(externalToolEntity); schoolExternalToolRepo.findByExternalToolId.mockResolvedValue([]); contextExternalToolRepo.countBySchoolToolIdsAndContextType.mockResolvedValue(0); diff --git a/apps/server/src/modules/tool/external-tool/service/external-tool-metadata.service.ts b/apps/server/src/modules/tool/external-tool/service/external-tool-metadata.service.ts index c2b15cec1a7..9476e738a87 100644 --- a/apps/server/src/modules/tool/external-tool/service/external-tool-metadata.service.ts +++ b/apps/server/src/modules/tool/external-tool/service/external-tool-metadata.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@nestjs/common'; import { EntityId } from '@shared/domain'; -import { ContextExternalToolRepo, ExternalToolRepo, SchoolExternalToolRepo } from '@shared/repo'; +import { ContextExternalToolRepo, SchoolExternalToolRepo } from '@shared/repo'; import { ToolContextType } from '../../common/enum'; import { ContextExternalToolType } from '../../context-external-tool/entity'; import { SchoolExternalTool } from '../../school-external-tool/domain'; @@ -10,7 +10,6 @@ import { ToolContextMapper } from '../../common/mapper/tool-context.mapper'; @Injectable() export class ExternalToolMetadataService { constructor( - private readonly externalToolRepo: ExternalToolRepo, private readonly schoolToolRepo: SchoolExternalToolRepo, private readonly contextToolRepo: ContextExternalToolRepo ) {} diff --git a/apps/server/src/modules/tool/school-external-tool/service/school-external-tool-metadata.service.ts b/apps/server/src/modules/tool/school-external-tool/service/school-external-tool-metadata.service.ts index a2e8480bae6..fa8fd4fc926 100644 --- a/apps/server/src/modules/tool/school-external-tool/service/school-external-tool-metadata.service.ts +++ b/apps/server/src/modules/tool/school-external-tool/service/school-external-tool-metadata.service.ts @@ -16,18 +16,17 @@ export class SchoolExternalToolMetadataService { [ContextExternalToolType.COURSE]: 0, }; - if (schoolExternalToolId) { - await Promise.all( - Object.values(ToolContextType).map(async (contextType: ToolContextType): Promise => { - const type: ContextExternalToolType = ToolContextMapper.contextMapping[contextType]; + await Promise.all( + Object.values(ToolContextType).map(async (contextType: ToolContextType): Promise => { + const type: ContextExternalToolType = ToolContextMapper.contextMapping[contextType]; - const countPerContext: number = await this.contextToolRepo.countBySchoolToolIdsAndContextType(type, [ - schoolExternalToolId, - ]); - contextExternalToolCount[type] = countPerContext; - }) - ); - } + const countPerContext: number = await this.contextToolRepo.countBySchoolToolIdsAndContextType(type, [ + schoolExternalToolId, + ]); + + contextExternalToolCount[type] = countPerContext; + }) + ); const schoolExternaltoolMetadata: SchoolExternalToolMetadata = new SchoolExternalToolMetadata({ contextExternalToolCountPerContext: contextExternalToolCount,