chore: add unit tests for the createdAfter filter of notifications

Signed-off-by: Marek Libra <marek.libra@gmail.com>
This commit is contained in:
Marek Libra
2024-02-22 13:01:29 +01:00
parent 5d9c5ba0a6
commit cacae47b1c
2 changed files with 43 additions and 1 deletions
@@ -60,7 +60,7 @@ describe('NotificationsClient', () => {
server.use(
rest.get(`${mockBaseUrl}/`, (req, res, ctx) => {
expect(req.url.search).toBe(
'?limit=10&offset=0&search=find+me&read=true',
'?limit=10&offset=0&search=find+me&read=true&created_after=1970-01-01T00%3A00%3A00.005Z',
);
return res(ctx.json(expectedResp));
}),
@@ -70,6 +70,21 @@ describe('NotificationsClient', () => {
offset: 0,
search: 'find me',
read: true,
createdAfter: new Date(5),
});
expect(response).toEqual(expectedResp);
});
it('should omit unselected fetch options', async () => {
server.use(
rest.get(`${mockBaseUrl}/`, (req, res, ctx) => {
expect(req.url.search).toBe('?limit=10');
return res(ctx.json(expectedResp));
}),
);
const response = await client.getNotifications({
limit: 10,
// do not put more options here
});
expect(response).toEqual(expectedResp);
});