fix(test): Refactor trash test to improve metadata and deletion validation
This commit is contained in:
@ -52,7 +52,21 @@ tap.test('should put a file into the trash', async () => {
|
||||
console.log(fileMetadata.toString());
|
||||
expect(await file.getMetaData().then((meta) => meta.metadataFile.getJsonData())).toEqual({});
|
||||
await file.delete({ mode: 'trash' });
|
||||
jestExpect(await file.getMetaData().then((meta) => meta.metadataFile.getJsonData())).toEqual({
|
||||
|
||||
const getTrashContents = async () => {
|
||||
const trash = await myBucket.getTrash();
|
||||
const trashDir = await trash.getTrashDir();
|
||||
return await trashDir.listFiles();
|
||||
}
|
||||
|
||||
const trashedFiles = await getTrashContents();
|
||||
expect(trashedFiles.length).toEqual(2);
|
||||
|
||||
const trashedMetaFile = trashedFiles.find(file => file.name.endsWith('.metadata'));
|
||||
expect(trashedMetaFile).toBeDefined();
|
||||
expect(trashedMetaFile).toBeInstanceOf(smartbucket.File);
|
||||
|
||||
jestExpect(await trashedMetaFile!.getJsonData()).toEqual({
|
||||
custom_recycle: {
|
||||
deletedAt: jestExpect.any(Number),
|
||||
originalPath: "trashtest/trashme.txt",
|
||||
|
Reference in New Issue
Block a user