unify pagination to use currentPage, pageSize and order as values

This commit is contained in:
Ulf Gebhardt 2021-10-01 22:00:37 +02:00
parent 175bffcc05
commit 69bb8b7ea7
No known key found for this signature in database
GPG Key ID: 81308EFE29ABFEBD
6 changed files with 19 additions and 15 deletions

View File

@ -32,8 +32,8 @@ export const loginViaEmailVerificationCode = gql`
`
export const transactionsQuery = gql`
query($firstPage: Int = 1, $items: Int = 25, $order: String = "DESC") {
transactionList(firstPage: $firstPage, items: $items, order: $order) {
query($currentPage: Int = 1, $pageSize: Int = 25, $order: String = "DESC") {
transactionList(currentPage: $currentPage, pageSize: $pageSize, order: $order) {
gdtSum
count
balance

View File

@ -189,7 +189,7 @@ describe('DashboardLayoutGdd', () => {
})
await wrapper
.findComponent({ ref: 'router-view' })
.vm.$emit('update-transactions', { firstPage: 2, items: 5 })
.vm.$emit('update-transactions', { currentPage: 2, pageSize: 5 })
await flushPromises()
})
@ -197,8 +197,8 @@ describe('DashboardLayoutGdd', () => {
expect(apolloMock).toBeCalledWith(
expect.objectContaining({
variables: {
firstPage: 2,
items: 5,
currentPage: 2,
pageSize: 5,
},
}),
)
@ -233,7 +233,7 @@ describe('DashboardLayoutGdd', () => {
})
await wrapper
.findComponent({ ref: 'router-view' })
.vm.$emit('update-transactions', { firstPage: 2, items: 5 })
.vm.$emit('update-transactions', { currentPage: 2, pageSize: 5 })
await flushPromises()
})

View File

@ -110,8 +110,8 @@ export default {
.query({
query: transactionsQuery,
variables: {
firstPage: pagination.firstPage,
items: pagination.items,
currentPage: pagination.currentPage,
pageSize: pagination.pageSize,
},
fetchPolicy: 'network-only',
})

View File

@ -327,7 +327,9 @@ describe('GddTransactionList', () => {
it('emits update-transactions when next button is clicked', async () => {
await paginationButtons.find('button.next-page').trigger('click')
expect(wrapper.emitted('update-transactions')[1]).toEqual([{ firstPage: 2, items: 25 }])
expect(wrapper.emitted('update-transactions')[1]).toEqual([
{ currentPage: 2, pageSize: 25 },
])
})
it('shows text "2 / 2" when next button is clicked', async () => {
@ -348,7 +350,9 @@ describe('GddTransactionList', () => {
it('emits update-transactions when preivous button is clicked after next buton', async () => {
await paginationButtons.find('button.next-page').trigger('click')
await paginationButtons.find('button.previous-page').trigger('click')
expect(wrapper.emitted('update-transactions')[2]).toEqual([{ firstPage: 1, items: 25 }])
expect(wrapper.emitted('update-transactions')[2]).toEqual([
{ currentPage: 1, pageSize: 25 },
])
expect(scrollToMock).toBeCalled()
})
})

View File

@ -134,8 +134,8 @@ export default {
methods: {
updateTransactions() {
this.$emit('update-transactions', {
firstPage: this.currentPage,
items: this.pageSize,
currentPage: this.currentPage,
pageSize: this.pageSize,
})
window.scrollTo(0, 0)
},

View File

@ -36,16 +36,16 @@ describe('UserProfileTransactionList', () => {
it('emits update-transactions after creation', () => {
expect(wrapper.emitted('update-transactions')).toEqual(
expect.arrayContaining([expect.arrayContaining([{ firstPage: 1, items: 25 }])]),
expect.arrayContaining([expect.arrayContaining([{ currentPage: 1, pageSize: 25 }])]),
)
})
it('emist update-transactions when update-transactions is called', () => {
wrapper
.findComponent({ name: 'GddTransactionList' })
.vm.$emit('update-transactions', { firstPage: 2, items: 25 })
.vm.$emit('update-transactions', { currentPage: 2, pageSize: 25 })
expect(wrapper.emitted('update-transactions')).toEqual(
expect.arrayContaining([expect.arrayContaining([{ firstPage: 2, items: 25 }])]),
expect.arrayContaining([expect.arrayContaining([{ currentPage: 2, pageSize: 25 }])]),
)
})