test: ensure testSetup.cleanup is called

Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
David Mehren 2022-03-04 13:13:46 +01:00
parent f0e6f6150d
commit a6734cc58f
14 changed files with 55 additions and 28 deletions

View file

@ -28,6 +28,7 @@ describe('Alias', () => {
afterEach(async () => {
await testSetup.app.close();
await testSetup.cleanup();
});
describe('POST /alias', () => {

View file

@ -31,6 +31,11 @@ describe('Me', () => {
await testSetup.app.init();
});
afterAll(async () => {
await testSetup.app.close();
await testSetup.cleanup();
});
it(`GET /me`, async () => {
const userInfo = testSetup.userService.toFullUserDto(user);
const response = await request(testSetup.app.getHttpServer())
@ -218,8 +223,4 @@ describe('Me', () => {
}
await fs.rm(uploadPath, { recursive: true });
});
afterAll(async () => {
await testSetup.app.close();
});
});

View file

@ -43,6 +43,13 @@ describe('Media', () => {
);
});
afterAll(async () => {
// Delete the upload folder
await ensureDeleted(uploadPath);
await testSetup.app.close();
await testSetup.cleanup();
});
describe('POST /media', () => {
it('works', async () => {
const uploadResponse = await request(testSetup.app.getHttpServer())
@ -111,10 +118,4 @@ describe('Media', () => {
.delete('/api/v2/media/' + filename)
.expect(204);
});
afterAll(async () => {
// Delete the upload folder
await ensureDeleted(uploadPath);
await testSetup.app.close();
});
});

View file

@ -41,6 +41,11 @@ describe('Notes', () => {
testImage = await fs.readFile('test/public-api/fixtures/test.png');
});
afterAll(async () => {
await testSetup.app.close();
await testSetup.cleanup();
});
it('POST /notes', async () => {
const response = await request(testSetup.app.getHttpServer())
.post('/api/v2/notes')
@ -212,6 +217,7 @@ describe('Notes', () => {
expect(await updatedNote.groupPermissions).toHaveLength(0);
await request(testSetup.app.getHttpServer())
.delete('/api/v2/notes/test3')
.send({ keepMedia: false })
.expect(204);
await expect(
testSetup.notesService.getNoteByIdOrAlias('test3'),
@ -463,8 +469,4 @@ describe('Notes', () => {
.expect(403);
});
});
afterAll(async () => {
await testSetup.app.close();
});
});