From 39fad42571ae2c3adcdcabcc70e1c77c30da49a3 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 14 Sep 2021 17:57:46 +0200 Subject: [PATCH] better tests for GDD Transaction List --- .../GdtTransactionList.spec.js | 23 +++++++++++++++++++ .../AccountOverview/GdtTransactionList.vue | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/frontend/src/views/Pages/AccountOverview/GdtTransactionList.spec.js b/frontend/src/views/Pages/AccountOverview/GdtTransactionList.spec.js index a3c737d10..8d06de5c6 100644 --- a/frontend/src/views/Pages/AccountOverview/GdtTransactionList.spec.js +++ b/frontend/src/views/Pages/AccountOverview/GdtTransactionList.spec.js @@ -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, + }, + }), + ) + }) + }) }) }) diff --git a/frontend/src/views/Pages/AccountOverview/GdtTransactionList.vue b/frontend/src/views/Pages/AccountOverview/GdtTransactionList.vue index 7d1bcfd7e..dde5e31e8 100644 --- a/frontend/src/views/Pages/AccountOverview/GdtTransactionList.vue +++ b/frontend/src/views/Pages/AccountOverview/GdtTransactionList.vue @@ -48,7 +48,7 @@ export default { }, data() { return { - transactionsGdt: { default: () => [] }, + transactionsGdt: [], transactionGdtCount: { type: Number, default: 0 }, currentPage: 1, pageSize: 25,