Skip to content

Commit

Permalink
Add test checking response format
Browse files Browse the repository at this point in the history
  • Loading branch information
juanenrisley committed Sep 1, 2023
1 parent efce5ae commit 316e902
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/news-find.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,24 @@ afterAll(async () => {
});

describe('GET /news/?afterDate=... - Search via date', () => {
it('should return the correct response format', () =>
request(app)
.get('/api/news')
.set('Accept', 'application/json')
.expect(httpStatus.OK)
.expect(({ body: { data } }) =>
data.forEach((obj) => {
expect(obj).toHaveProperty('id');
expect(obj).toHaveProperty('date');
expect(obj).toHaveProperty('iconId');
expect(obj).toHaveProperty('isActive');
expect(obj).toHaveProperty('createdAt');
expect(obj).toHaveProperty('updatedAt');
expect(obj).toHaveProperty('title.en');
expect(obj).toHaveProperty('message.en');
}),
));

it('should return active news by default', async () => {
await request(app)
.get('/api/news')
Expand Down

0 comments on commit 316e902

Please sign in to comment.