Test that currentPage is reset when switching tab.

This commit is contained in:
elweyn 2023-04-05 13:18:44 +02:00
parent 25b0aeb3bf
commit c5b591ca5d

View File

@ -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,