diff --git a/frontend/src/components/GddTransactionList.spec.js b/frontend/src/components/GddTransactionList.spec.js
index aeecf43cc..fbcb10bdd 100644
--- a/frontend/src/components/GddTransactionList.spec.js
+++ b/frontend/src/components/GddTransactionList.spec.js
@@ -23,6 +23,8 @@ describe('GddTransactionList', () => {
return mount(GddTransactionList, { localVue, mocks })
}
+ const decayStartBlock = new Date(2001, 8, 9)
+
describe('mount', () => {
beforeEach(() => {
wrapper = Wrapper()
@@ -84,7 +86,6 @@ describe('GddTransactionList', () => {
describe('with transactions', () => {
beforeEach(async () => {
- const decayStartBlock = new Date(2001, 8, 9)
await wrapper.setProps({
transactions: [
{
@@ -406,78 +407,58 @@ describe('GddTransactionList', () => {
})
describe('pagination buttons', () => {
- const transactions = Array.from({ length: 42 }, (_, idx) => {
- return {
- amount: '3.14',
- balanceDate: '2021-04-29T17:26:40+00:00',
- decay: {},
- memo: 'Kreiszahl PI',
- linkedUser: {
- firstName: 'Bibi',
- lastName: 'Bloxberg',
- __typename: 'User',
- },
- id: idx + 1,
- typeId: 'RECEIVE',
- balance: '33.33',
- }
- })
-
- let paginationButtons
-
beforeEach(async () => {
await wrapper.setProps({
- transactions,
+ transactions: Array.from({ length: 42 }, (_, idx) => {
+ return {
+ amount: '3.14',
+ balanceDate: '2021-04-29T17:26:40+00:00',
+ decay: {},
+ memo: 'Kreiszahl PI',
+ linkedUser: {
+ firstName: 'Bibi',
+ lastName: 'Bloxberg',
+ __typename: 'User',
+ },
+ id: idx + 1,
+ typeId: 'RECEIVE',
+ balance: '33.33',
+ }
+ }),
transactionCount: 42,
+ decayStartBlock,
+ pageSize: 25,
showPagination: true,
- decayStartBlock: new Date(),
})
- paginationButtons = wrapper.find('div.pagination-buttons')
})
- it('shows the pagination buttons', () => {
- expect(paginationButtons.exists()).toBeTruthy()
+ describe('next page button clicked', () => {
+ beforeEach(async () => {
+ jest.clearAllMocks()
+ await wrapper.findComponent({ name: 'BPagination' }).vm.$emit('input', 2)
+ })
+
+ it('emits update transactions', () => {
+ expect(wrapper.emitted('update-transactions')).toEqual(
+ expect.arrayContaining([[{ currentPage: 2, pageSize: 25 }]]),
+ )
+ })
+ })
+ })
+
+ describe('show no pagination', () => {
+ beforeEach(async () => {
+ await wrapper.setProps({
+ transactions: [],
+ transactionCount: 2,
+ decayStartBlock,
+ pageSize: 25,
+ showPagination: false,
+ })
})
- it('has the previous button disabled', () => {
- expect(paginationButtons.find('button.previous-page').attributes('disabled')).toBe(
- 'disabled',
- )
- })
-
- it('shows the text "1 / 2"', () => {
- expect(paginationButtons.find('p.text-center').text()).toBe('1 math.div 2')
- })
-
- 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([
- { currentPage: 2, pageSize: 25 },
- ])
- })
-
- it('shows text "2 / 2" when next button is clicked', async () => {
- await paginationButtons.find('button.next-page').trigger('click')
- expect(paginationButtons.find('p.text-center').text()).toBe('2 math.div 2')
- })
-
- it('has next-button disabled when next button is clicked', async () => {
- await paginationButtons.find('button.next-page').trigger('click')
- expect(paginationButtons.find('button.next-page').attributes('disabled')).toBe('disabled')
- })
-
- it('scrolls to top after loading next page', async () => {
- await paginationButtons.find('button.next-page').trigger('click')
- expect(scrollToMock).toBeCalled()
- })
-
- 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([
- { currentPage: 1, pageSize: 25 },
- ])
- expect(scrollToMock).toBeCalled()
+ it('shows no pagination buttons', () => {
+ expect(wrapper.find('ul.pagination').exists()).toBe(false)
})
})
})
diff --git a/frontend/src/components/GddTransactionList.vue b/frontend/src/components/GddTransactionList.vue
index 55a11063c..4498034e9 100644
--- a/frontend/src/components/GddTransactionList.vue
+++ b/frontend/src/components/GddTransactionList.vue
@@ -63,12 +63,17 @@
-