Skip to content

Commit

Permalink
test(nestjs-tools-file-storage): add integration tests for moveFile
Browse files Browse the repository at this point in the history
  • Loading branch information
getlarge committed Aug 1, 2024
1 parent 62629d9 commit 7e1c8c9
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/file-storage/test/file-storage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' });
Expand Down

0 comments on commit 7e1c8c9

Please sign in to comment.