From c5b591ca5d0ef0aad735a75c36596639d4b9f1e3 Mon Sep 17 00:00:00 2001 From: elweyn Date: Wed, 5 Apr 2023 13:18:44 +0200 Subject: [PATCH] Test that currentPage is reset when switching tab. --- admin/src/pages/CreationConfirm.spec.js | 43 ++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/admin/src/pages/CreationConfirm.spec.js b/admin/src/pages/CreationConfirm.spec.js index c9d9661c2..74fe23428 100644 --- a/admin/src/pages/CreationConfirm.spec.js +++ b/admin/src/pages/CreationConfirm.spec.js @@ -39,7 +39,7 @@ const mocks = { const defaultData = () => { return { adminListContributions: { - contributionCount: 2, + contributionCount: 30, contributionList: [ { id: 1, @@ -152,6 +152,35 @@ describe('CreationConfirm', () => { }) describe('actions in overlay', () => { + describe('change pagination', () => { + it('has pagination buttons', () => { + expect(wrapper.findComponent({ name: 'BPagination' }).exists()).toBe(true) + }) + + describe('next page', () => { + beforeAll(async () => { + jest.clearAllMocks() + }) + + beforeEach(() => { + wrapper.vm.currentPage = 2 + }) + + it('has currentPage set to 2', () => { + expect(wrapper.vm.currentPage).toBe(2) + }) + + it('calls the API again', () => { + expect(adminListContributionsMock).toBeCalledWith({ + currentPage: 2, + order: 'DESC', + pageSize: 25, + statusFilter: ['IN_PROGRESS', 'PENDING'], + }) + }) + }) + }) + describe('delete creation', () => { beforeEach(async () => { await wrapper.findAll('tr').at(1).findAll('button').at(0).trigger('click') @@ -367,6 +396,10 @@ describe('CreationConfirm', () => { await wrapper.find('a[data-test="denied"]').trigger('click') }) + it('refresh the currentPage to 1', () => { + expect(wrapper.vm.currentPage).toBe(1) + }) + it('refetches contributions with proper filter', () => { expect(adminListContributionsMock).toBeCalledWith({ currentPage: 1, @@ -383,6 +416,10 @@ describe('CreationConfirm', () => { await wrapper.find('a[data-test="deleted"]').trigger('click') }) + it('refresh the currentPage to 1', () => { + expect(wrapper.vm.currentPage).toBe(1) + }) + it('refetches contributions with proper filter', () => { expect(adminListContributionsMock).toBeCalledWith({ currentPage: 1, @@ -399,6 +436,10 @@ describe('CreationConfirm', () => { await wrapper.find('a[data-test="all"]').trigger('click') }) + it('refresh the currentPage to 1', () => { + expect(wrapper.vm.currentPage).toBe(1) + }) + it('refetches contributions with proper filter', () => { expect(adminListContributionsMock).toBeCalledWith({ currentPage: 1,