Skip to content

Commit

Permalink
Merge pull request #4 from yldrmzffr/feature/error-handling
Browse files Browse the repository at this point in the history
test: new Exceptions Tests
  • Loading branch information
yldrmzffr authored Jul 17, 2023
2 parents a4b28f7 + c6f617e commit ad2eaea
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions test/methods.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,27 @@ describe('MuzuServer', () => {
it('should return 404 on GET /api/hello/world', async () => {
const res = await request(muzuServer.server).get('/api/hello/world');
expect(res.status).toEqual(404);
expect(res.body).toEqual({message: '404 Not Found'});
expect(res.body).toEqual({
kind: 'MuzuException',
message: 'Route GET /api/hello/world not found',
status: 404,
details: {
method: 'GET',
path: '/api/hello/world',
},
});
});

it('should return 400 on POST /api/hello', async () => {
const res = await request(muzuServer.server)
.post('/api/hello')
.send('Not a JSON');
expect(res.status).toEqual(400);
expect(res.body).toEqual({message: '400 Bad Request'});
expect(res.body).toEqual({
kind: 'MuzuException',
message: 'Error parsing body',
status: 400,
});
});
});

Expand Down

0 comments on commit ad2eaea

Please sign in to comment.