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

@ -41,6 +41,10 @@ describe('Alias', () => {
.expect(201);
});
afterAll(async () => {
await testSetup.cleanup();
});
describe('POST /alias', () => {
const testAlias = 'aliasTest';
const newAliasDto: AliasCreateDto = {

View file

@ -38,6 +38,10 @@ describe('Auth', () => {
password = 'test_password';
});
afterAll(async () => {
await testSetup.cleanup();
});
describe('POST /auth/local', () => {
it('works', async () => {
const registrationDto: RegisterDto = {

View file

@ -34,6 +34,7 @@ describe('Groups', () => {
afterEach(async () => {
await testSetup.app.close();
await testSetup.cleanup();
});
test('details for existing groups can be retrieved', async () => {

View file

@ -58,6 +58,11 @@ describe('History', () => {
.expect(201);
});
afterAll(async () => {
await testSetup.app.close();
await testSetup.cleanup();
});
it('GET /me/history', async () => {
const emptyResponse = await agent
.get('/api/private/me/history')
@ -219,8 +224,4 @@ describe('History', () => {
expect(userEntryDto.pinStatus).toEqual(entryDto.pinStatus);
expect(userEntryDto.lastVisitedAt).toEqual(entryDto.lastVisitedAt);
});
afterAll(async () => {
await testSetup.app.close();
});
});

View file

@ -49,6 +49,10 @@ describe('Me', () => {
.expect(201);
});
afterAll(async () => {
await testSetup.cleanup();
});
it('GET /me', async () => {
const userInfo = testSetup.userService.toFullUserDto(user);
const response = await agent

View file

@ -53,6 +53,13 @@ describe('Media', () => {
.expect(201);
});
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 agent
@ -122,10 +129,4 @@ describe('Media', () => {
const filename = url.split('/').pop() || '';
await agent.delete('/api/private/media/' + filename).expect(204);
});
afterAll(async () => {
// Delete the upload folder
await ensureDeleted(uploadPath);
await testSetup.app.close();
});
});

View file

@ -54,6 +54,11 @@ describe('Notes', () => {
.expect(201);
});
afterAll(async () => {
await testSetup.app.close();
await testSetup.cleanup();
});
it('POST /notes', async () => {
const response = await agent
.post('/api/private/notes')
@ -352,8 +357,4 @@ describe('Notes', () => {
.expect(403);
});
});
afterAll(async () => {
await testSetup.app.close();
});
});

View file

@ -23,6 +23,7 @@ describe('Register and Login', () => {
afterEach(async () => {
await testSetup.app.close();
await testSetup.cleanup();
});
test('a user can successfully create a local account and log in', async () => {

View file

@ -35,6 +35,10 @@ describe('Tokens', () => {
.expect(201);
});
afterAll(async () => {
await testSetup.cleanup();
});
it(`POST /tokens`, async () => {
const tokenName = 'testToken';
const response = await agent

View file

@ -17,6 +17,7 @@ describe('Users', () => {
afterEach(async () => {
await testSetup.app.close();
await testSetup.cleanup();
});
test('details for existing users can be retrieved', async () => {

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();
});
});