Skip to content

Commit

Permalink
Add node clam mock
Browse files Browse the repository at this point in the history
  • Loading branch information
bischofmax committed Oct 25, 2023
1 parent b6fcad0 commit 411481a
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
import { createMock } from '@golevelup/ts-jest';
import { EntityManager, ObjectId } from '@mikro-orm/mongodb';
import { ICurrentUser } from '@modules/authentication';
import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard';
import { FILES_STORAGE_S3_CONNECTION, FilesStorageTestModule } from '@modules/files-storage';
import {
CopyFileParams,
CopyFilesOfParentParams,
FileRecordListResponse,
FileRecordResponse,
} from '@modules/files-storage/controller/dto';
import { ExecutionContext, INestApplication } from '@nestjs/common';
import { Test, TestingModule } from '@nestjs/testing';
import { ApiValidationError } from '@shared/common';
Expand All @@ -15,15 +24,7 @@ import {
schoolFactory,
userFactory,
} from '@shared/testing';
import { ICurrentUser } from '@modules/authentication';
import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard';
import { FILES_STORAGE_S3_CONNECTION, FilesStorageTestModule } from '@modules/files-storage';
import {
CopyFileParams,
CopyFilesOfParentParams,
FileRecordListResponse,
FileRecordResponse,
} from '@modules/files-storage/controller/dto';
import NodeClam from 'clamscan';
import { Request } from 'express';
import FileType from 'file-type-cjs/file-type-cjs-index';
import request from 'supertest';
Expand Down Expand Up @@ -107,6 +108,8 @@ describe(`${baseRouteName} (api)`, () => {
return true;
},
})
.overrideProvider(NodeClam)
.useValue(createMock<NodeClam>())
.compile();

app = module.createNestApplication();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { createMock } from '@golevelup/ts-jest';
import { EntityManager, ObjectId } from '@mikro-orm/mongodb';
import { ICurrentUser } from '@modules/authentication';
import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard';
import { FILES_STORAGE_S3_CONNECTION, FilesStorageTestModule } from '@modules/files-storage';
import { FileRecordListResponse, FileRecordResponse } from '@modules/files-storage/controller/dto';
import { ExecutionContext, INestApplication } from '@nestjs/common';
import { Test, TestingModule } from '@nestjs/testing';
import { ApiValidationError } from '@shared/common';
Expand All @@ -14,10 +18,7 @@ import {
schoolFactory,
userFactory,
} from '@shared/testing';
import { ICurrentUser } from '@modules/authentication';
import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard';
import { FILES_STORAGE_S3_CONNECTION, FilesStorageTestModule } from '@modules/files-storage';
import { FileRecordListResponse, FileRecordResponse } from '@modules/files-storage/controller/dto';
import NodeClam from 'clamscan';
import { Request } from 'express';
import FileType from 'file-type-cjs/file-type-cjs-index';
import request from 'supertest';
Expand Down Expand Up @@ -101,6 +102,8 @@ describe(`${baseRouteName} (api)`, () => {
return true;
},
})
.overrideProvider(NodeClam)
.useValue(createMock<NodeClam>())
.compile();

app = module.createNestApplication();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { createMock, DeepMocked } from '@golevelup/ts-jest';
import { EntityManager } from '@mikro-orm/mongodb';
import { ICurrentUser } from '@modules/authentication';
import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard';
import { FILES_STORAGE_S3_CONNECTION, FilesStorageTestModule } from '@modules/files-storage';
import { FileRecordResponse } from '@modules/files-storage/controller/dto';
import { ExecutionContext, INestApplication } from '@nestjs/common';
import { Test, TestingModule } from '@nestjs/testing';
import { ApiValidationError } from '@shared/common';
import { EntityId, Permission } from '@shared/domain';
import { AntivirusService } from '@shared/infra/antivirus';
import { S3ClientAdapter } from '@shared/infra/s3-client';
import { cleanupCollections, mapUserToCurrentUser, roleFactory, schoolFactory, userFactory } from '@shared/testing';
import { ICurrentUser } from '@modules/authentication';
import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard';
import { FILES_STORAGE_S3_CONNECTION, FilesStorageTestModule } from '@modules/files-storage';
import { FileRecordResponse } from '@modules/files-storage/controller/dto';
import NodeClam from 'clamscan';
import { Request } from 'express';
import FileType from 'file-type-cjs/file-type-cjs-index';
import request from 'supertest';
Expand Down Expand Up @@ -114,6 +115,8 @@ describe('files-storage controller (API)', () => {
return true;
},
})
.overrideProvider(NodeClam)
.useValue(createMock<NodeClam>())
.compile();

app = module.createNestApplication();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { createMock, DeepMocked } from '@golevelup/ts-jest';
import { EntityManager, ObjectId } from '@mikro-orm/mongodb';
import { ICurrentUser } from '@modules/authentication';
import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard';
import { FILES_STORAGE_S3_CONNECTION, FilesStorageTestModule } from '@modules/files-storage';
import { FileRecordResponse } from '@modules/files-storage/controller/dto';
import { ExecutionContext, INestApplication, NotFoundException, StreamableFile } from '@nestjs/common';
import { Test, TestingModule } from '@nestjs/testing';
import { ApiValidationError } from '@shared/common';
import { EntityId, Permission } from '@shared/domain';
import { AntivirusService } from '@shared/infra/antivirus';
import { S3ClientAdapter } from '@shared/infra/s3-client';
import { cleanupCollections, mapUserToCurrentUser, roleFactory, schoolFactory, userFactory } from '@shared/testing';
import { ICurrentUser } from '@modules/authentication';
import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard';
import { FILES_STORAGE_S3_CONNECTION, FilesStorageTestModule } from '@modules/files-storage';
import { FileRecordResponse } from '@modules/files-storage/controller/dto';
import NodeClam from 'clamscan';
import { Request } from 'express';
import FileType from 'file-type-cjs/file-type-cjs-index';
import request from 'supertest';
Expand Down Expand Up @@ -111,6 +112,8 @@ describe('File Controller (API) - preview', () => {
return true;
},
})
.overrideProvider(NodeClam)
.useValue(createMock<NodeClam>())
.compile();

app = module.createNestApplication();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { createMock } from '@golevelup/ts-jest';
import { EntityManager } from '@mikro-orm/mongodb';
import { ICurrentUser } from '@modules/authentication';
import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard';
import { FilesStorageTestModule } from '@modules/files-storage';
import { FileRecordResponse, RenameFileParams } from '@modules/files-storage/controller/dto';
import { ExecutionContext, INestApplication } from '@nestjs/common';
import { Test, TestingModule } from '@nestjs/testing';
import { ApiValidationError } from '@shared/common';
import { Permission } from '@shared/domain';
import { ICurrentUser } from '@modules/authentication';
import {
cleanupCollections,
fileRecordFactory,
Expand All @@ -12,9 +16,7 @@ import {
schoolFactory,
userFactory,
} from '@shared/testing';
import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard';
import { FilesStorageTestModule } from '@modules/files-storage';
import { FileRecordResponse, RenameFileParams } from '@modules/files-storage/controller/dto';
import NodeClam from 'clamscan';
import { Request } from 'express';
import request from 'supertest';
import { FileRecord, FileRecordParentType } from '../../entity';
Expand Down Expand Up @@ -62,6 +64,8 @@ describe(`${baseRouteName} (api)`, () => {
return true;
},
})
.overrideProvider(NodeClam)
.useValue(createMock<NodeClam>())
.compile();

app = module.createNestApplication();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { createMock } from '@golevelup/ts-jest';
import { EntityManager, ObjectId } from '@mikro-orm/mongodb';
import { ICurrentUser } from '@modules/authentication';
import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard';
import { FILES_STORAGE_S3_CONNECTION, FilesStorageTestModule } from '@modules/files-storage';
import { FileRecordListResponse, FileRecordResponse } from '@modules/files-storage/controller/dto';
import { ExecutionContext, INestApplication } from '@nestjs/common';
import { Test, TestingModule } from '@nestjs/testing';
import { ApiValidationError } from '@shared/common';
Expand All @@ -14,10 +18,7 @@ import {
schoolFactory,
userFactory,
} from '@shared/testing';
import { ICurrentUser } from '@modules/authentication';
import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard';
import { FILES_STORAGE_S3_CONNECTION, FilesStorageTestModule } from '@modules/files-storage';
import { FileRecordListResponse, FileRecordResponse } from '@modules/files-storage/controller/dto';
import NodeClam from 'clamscan';
import { Request } from 'express';
import FileType from 'file-type-cjs/file-type-cjs-index';
import request from 'supertest';
Expand Down Expand Up @@ -126,6 +127,8 @@ describe(`${baseRouteName} (api)`, () => {
return true;
},
})
.overrideProvider(NodeClam)
.useValue(createMock<NodeClam>())
.compile();

app = module.createNestApplication();
Expand Down

0 comments on commit 411481a

Please sign in to comment.