From 94f09633133510ac2000ee8e1f923f61cdb7c78f Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 11 Apr 2023 12:35:20 +0200 Subject: [PATCH] test reset current page on tab change properly --- admin/src/pages/CreationConfirm.spec.js | 79 ++++++++++++------------- 1 file changed, 38 insertions(+), 41 deletions(-) diff --git a/admin/src/pages/CreationConfirm.spec.js b/admin/src/pages/CreationConfirm.spec.js index 74fe23428..8c51d9475 100644 --- a/admin/src/pages/CreationConfirm.spec.js +++ b/admin/src/pages/CreationConfirm.spec.js @@ -152,35 +152,6 @@ 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') @@ -396,10 +367,6 @@ 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, @@ -416,10 +383,6 @@ 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, @@ -436,10 +399,6 @@ 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, @@ -448,6 +407,44 @@ describe('CreationConfirm', () => { statusFilter: ['IN_PROGRESS', 'PENDING', 'CONFIRMED', 'DENIED', 'DELETED'], }) }) + + describe('change pagination', () => { + it('has pagination buttons', () => { + expect(wrapper.findComponent({ name: 'BPagination' }).exists()).toBe(true) + }) + + describe('next page', () => { + beforeEach(() => { + jest.clearAllMocks() + wrapper.findComponent({ name: 'BPagination' }).vm.$emit('input', 2) + }) + + it('calls the API again', () => { + expect(adminListContributionsMock).toBeCalledWith({ + currentPage: 2, + order: 'DESC', + pageSize: 25, + statusFilter: ['IN_PROGRESS', 'PENDING', 'CONFIRMED', 'DENIED', 'DELETED'], + }) + }) + }) + }) + + describe('click tab "open" again', () => { + beforeEach(async () => { + jest.clearAllMocks() + await wrapper.find('a[data-test="open"]').trigger('click') + }) + + it('refetches contributions with proper filter and current page = 1', () => { + expect(adminListContributionsMock).toBeCalledWith({ + currentPage: 1, + order: 'DESC', + pageSize: 25, + statusFilter: ['IN_PROGRESS', 'PENDING'], + }) + }) + }) }) }) })