From a98c4fbb1bd96ec9f6be149eec960b696b318f22 Mon Sep 17 00:00:00 2001 From: David Mehren Date: Tue, 22 Sep 2020 21:10:09 +0200 Subject: [PATCH] Note E2E tests: Await all note-creations and fix test for note-deletion. Signed-off-by: David Mehren --- test/public-api/notes.e2e-spec.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/test/public-api/notes.e2e-spec.ts b/test/public-api/notes.e2e-spec.ts index ba978d2ba..b349d56f9 100644 --- a/test/public-api/notes.e2e-spec.ts +++ b/test/public-api/notes.e2e-spec.ts @@ -51,7 +51,7 @@ describe('Notes', () => { }); it(`GET /notes/{note}`, async () => { - notesService.createNote('This is a test note.', 'test1'); + await notesService.createNote('This is a test note.', 'test1'); const response = await request(app.getHttpServer()) .get('/notes/test1') .expect('Content-Type', /json/) @@ -75,15 +75,17 @@ describe('Notes', () => { }); it(`DELETE /notes/{note}`, async () => { - notesService.createNote('This is a test note.', 'test3'); + await notesService.createNote('This is a test note.', 'test3'); await request(app.getHttpServer()) .delete('/notes/test3') .expect(200); - return expect(notesService.getNoteByIdOrAlias('test3')).toBeNull(); + return expect(notesService.getNoteByIdOrAlias('test3')).rejects.toEqual( + Error('Note not found'), + ); }); it(`PUT /notes/{note}`, async () => { - notesService.createNote('This is a test note.', 'test4'); + await notesService.createNote('This is a test note.', 'test4'); await request(app.getHttpServer()) .put('/notes/test4') .set('Content-Type', 'text/markdown') @@ -111,7 +113,7 @@ describe('Notes', () => { }); it(`GET /notes/{note}/revisions`, async () => { - notesService.createNote('This is a test note.', 'test7'); + await notesService.createNote('This is a test note.', 'test7'); const response = await request(app.getHttpServer()) .get('/notes/test7/revisions') .expect('Content-Type', /json/) @@ -120,7 +122,7 @@ describe('Notes', () => { }); it(`GET /notes/{note}/revisions/{revision-id}`, async () => { - notesService.createNote('This is a test note.', 'test8'); + await notesService.createNote('This is a test note.', 'test8'); const response = await request(app.getHttpServer()) .get('/notes/test8/revisions/1') .expect('Content-Type', /json/) @@ -129,7 +131,7 @@ describe('Notes', () => { }); it(`GET /notes/{note}/content`, async () => { - notesService.createNote('This is a test note.', 'test9'); + await notesService.createNote('This is a test note.', 'test9'); const response = await request(app.getHttpServer()) .get('/notes/test9/content') .expect(200);