From 7e1c8c9a8e3788866859ef174f17aa59d923389c Mon Sep 17 00:00:00 2001 From: getlarge Date: Thu, 1 Aug 2024 18:14:42 +0200 Subject: [PATCH] test(nestjs-tools-file-storage): add integration tests for moveFile --- packages/file-storage/test/file-storage.spec.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/file-storage/test/file-storage.spec.ts b/packages/file-storage/test/file-storage.spec.ts index 9d3c5ef..4b691ad 100644 --- a/packages/file-storage/test/file-storage.spec.ts +++ b/packages/file-storage/test/file-storage.spec.ts @@ -134,6 +134,20 @@ testMap.forEach((testSuite) => { await fileStorage.deleteFile({ filePath }); }); + it('moveFile moves a file to a new location and remove the previous one', async () => { + const oldFileName = 'oldFileName.txt'; + const newFileName = 'newFileName.txt'; + await fileStorage.uploadFile({ filePath: oldFileName, content: 'this is a test' }); + // + await fileStorage.moveFile({ filePath: oldFileName, newFilePath: newFileName }); + // + const oldFileExists = await fileStorage.fileExists({ filePath: oldFileName }); + expect(oldFileExists).toBe(false); + const newFileExists = await fileStorage.fileExists({ filePath: newFileName }); + expect(newFileExists).toBe(true); + await fileStorage.deleteFile({ filePath: newFileName }); + }); + it('deleteFile deletes a file', async () => { const filePath = randomUUID(); await fileStorage.uploadFile({ filePath, content: 'this is a test' });