Note E2E tests: Await all note-creations and fix test for note-deletion.

Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
David Mehren 2020-09-22 21:10:09 +02:00
parent 51aec1ea54
commit a98c4fbb1b
No known key found for this signature in database
GPG key ID: 185982BA4C42B7C3

View file

@ -51,7 +51,7 @@ describe('Notes', () => {
}); });
it(`GET /notes/{note}`, async () => { 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()) const response = await request(app.getHttpServer())
.get('/notes/test1') .get('/notes/test1')
.expect('Content-Type', /json/) .expect('Content-Type', /json/)
@ -75,15 +75,17 @@ describe('Notes', () => {
}); });
it(`DELETE /notes/{note}`, async () => { 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()) await request(app.getHttpServer())
.delete('/notes/test3') .delete('/notes/test3')
.expect(200); .expect(200);
return expect(notesService.getNoteByIdOrAlias('test3')).toBeNull(); return expect(notesService.getNoteByIdOrAlias('test3')).rejects.toEqual(
Error('Note not found'),
);
}); });
it(`PUT /notes/{note}`, async () => { 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()) await request(app.getHttpServer())
.put('/notes/test4') .put('/notes/test4')
.set('Content-Type', 'text/markdown') .set('Content-Type', 'text/markdown')
@ -111,7 +113,7 @@ describe('Notes', () => {
}); });
it(`GET /notes/{note}/revisions`, async () => { 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()) const response = await request(app.getHttpServer())
.get('/notes/test7/revisions') .get('/notes/test7/revisions')
.expect('Content-Type', /json/) .expect('Content-Type', /json/)
@ -120,7 +122,7 @@ describe('Notes', () => {
}); });
it(`GET /notes/{note}/revisions/{revision-id}`, async () => { 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()) const response = await request(app.getHttpServer())
.get('/notes/test8/revisions/1') .get('/notes/test8/revisions/1')
.expect('Content-Type', /json/) .expect('Content-Type', /json/)
@ -129,7 +131,7 @@ describe('Notes', () => {
}); });
it(`GET /notes/{note}/content`, async () => { 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()) const response = await request(app.getHttpServer())
.get('/notes/test9/content') .get('/notes/test9/content')
.expect(200); .expect(200);