Skip to content

Commit

Permalink
fix file storage service test
Browse files Browse the repository at this point in the history
  • Loading branch information
MajedAlaitwniCap committed Oct 16, 2023
1 parent 61a4018 commit 87eb68d
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { S3ClientAdapter } from '@shared/infra/s3-client';
import { FileDto } from '@src/modules/files-storage/dto';
import { GetFileResponse } from '@src/modules/files-storage/interface';
import { ReadStream } from 'fs';
import { join } from 'node:path';
import { Readable } from 'node:stream';
import { TemporaryFile } from '../entity/temporary-file.entity';
import { H5P_CONTENT_S3_CONNECTION } from '../h5p-editor.config';
Expand Down Expand Up @@ -101,12 +100,15 @@ describe('TemporaryFileStorage', () => {
describe('WHEN file exists', () => {
it('should delete file', async () => {
const { user1, file1 } = setup();
const res = [`h5p-tempfiles/${user1.id}/${file1.filename}`];
console.log(res);

Check warning on line 104 in apps/server/src/modules/h5p-editor/service/temporary-file-storage.service.spec.ts

View workflow job for this annotation

GitHub Actions / nest_lint

Unexpected console statement
repo.findByUserAndFilename.mockResolvedValueOnce(file1);

await storage.deleteFile(file1.filename, user1.id);

expect(repo.delete).toHaveBeenCalled();
expect(s3clientAdapter.delete).toHaveBeenCalledWith([join('h5p-tempfiles', user1.id, file1.filename)]);
expect(s3clientAdapter.delete).toHaveBeenCalledTimes(1);
expect(s3clientAdapter.delete).toHaveBeenCalledWith(res);
});
});
describe('WHEN file does not exist', () => {
Expand Down

0 comments on commit 87eb68d

Please sign in to comment.