From e68bdabd8a8528281afc8bb339e0a023850aa7e8 Mon Sep 17 00:00:00 2001 From: Justin Date: Fri, 12 Jul 2019 12:12:00 -0400 Subject: [PATCH] Add pagination object check --- test/integration/services/Labels.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/integration/services/Labels.ts b/test/integration/services/Labels.ts index 1ab69db8..0463b415 100644 --- a/test/integration/services/Labels.ts +++ b/test/integration/services/Labels.ts @@ -53,4 +53,26 @@ describe('Labels.all', () => { expect(labels).toBeInstanceOf(Array); expect(filtered).toHaveLength(50); }); + + it('should return a list of labels on a project restricted to page 5', async () => { + const labels = await service.all(project.id, { perPage: 5, page: 5}); + + expect(labels).toBeInstanceOf(Array); + expect(labels).toHaveLength(5); + }); + + it('should return a list of labels on a project restricted to page 5 and show the pagination object', async () => { + const { data, pagination } = await service.all(project.id, { perPage: 5, page: 5, showPagination: true}); + + expect(data).toBeInstanceOf(Array); + expect(data).toHaveLength(5); + expect(pagination).toMatchObject({ + total: 51, // TODO: change this to not depend on previous data + previous: 4, + current: 5, + next: 6, + perPage: 5, + totalPages: 11, + }); + }); }); \ No newline at end of file