better tests for GDD Transaction List

This commit is contained in:
Moriz Wahl 2021-09-14 17:57:46 +02:00
parent 8af43bd788
commit 39fad42571
2 changed files with 24 additions and 1 deletions

View File

@ -46,6 +46,9 @@ const apolloMock = jest.fn().mockResolvedValue({
})
const toastErrorMock = jest.fn()
const windowScrollToMock = jest.fn()
window.scrollTo = windowScrollToMock
describe('GdtTransactionList', () => {
let wrapper
@ -90,6 +93,10 @@ describe('GdtTransactionList', () => {
}),
)
})
it('scrolls to (0, 0) after API call', () => {
expect(windowScrollToMock).toBeCalledWith(0, 0)
})
})
describe('server returns error', () => {
@ -105,5 +112,21 @@ describe('GdtTransactionList', () => {
expect(toastErrorMock).toBeCalledWith('Ouch!')
})
})
describe('change of currentPage', () => {
it('calls the API after currentPage changes', async () => {
jest.clearAllMocks()
wrapper.setData({ currentPage: 2 })
await wrapper.vm.$nextTick()
expect(apolloMock).toBeCalledWith(
expect.objectContaining({
variables: {
currentPage: 2,
pageSize: 25,
},
}),
)
})
})
})
})

View File

@ -48,7 +48,7 @@ export default {
},
data() {
return {
transactionsGdt: { default: () => [] },
transactionsGdt: [],
transactionGdtCount: { type: Number, default: 0 },
currentPage: 1,
pageSize: 25,