From 87eb68dbb45b10325c32be69471832e6c3519399 Mon Sep 17 00:00:00 2001 From: MajedAlaitwniCap Date: Mon, 16 Oct 2023 16:40:36 +0200 Subject: [PATCH] fix file storage service test --- .../service/temporary-file-storage.service.spec.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/server/src/modules/h5p-editor/service/temporary-file-storage.service.spec.ts b/apps/server/src/modules/h5p-editor/service/temporary-file-storage.service.spec.ts index 2eef900f57b..2003e0c2d65 100644 --- a/apps/server/src/modules/h5p-editor/service/temporary-file-storage.service.spec.ts +++ b/apps/server/src/modules/h5p-editor/service/temporary-file-storage.service.spec.ts @@ -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'; @@ -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); 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', () => {