mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
add bootstrap pagination on GDD Transaction List, tests adapted
This commit is contained in:
parent
f74912cf4c
commit
bae1b85482
@ -405,78 +405,23 @@ 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',
|
||||
}
|
||||
})
|
||||
|
||||
let paginationButtons
|
||||
|
||||
beforeEach(async () => {
|
||||
await wrapper.setProps({
|
||||
transactions,
|
||||
transactionCount: 42,
|
||||
showPagination: true,
|
||||
decayStartBlock: new Date(),
|
||||
describe.only('pagination buttons', () => {
|
||||
it('shows the pagination buttons if transactionCount > 25', () => {
|
||||
beforeEach(async () => {
|
||||
await wrapper.setProps({
|
||||
transactionCount: 42,
|
||||
})
|
||||
})
|
||||
paginationButtons = wrapper.find('div.pagination-buttons')
|
||||
expect(wrapper.find('div.pagination')).toBeTruthy()
|
||||
})
|
||||
|
||||
it('shows the pagination buttons', () => {
|
||||
expect(paginationButtons.exists()).toBeTruthy()
|
||||
})
|
||||
|
||||
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 the pagination buttons if transactionCount < 25', () => {
|
||||
beforeEach(async () => {
|
||||
await wrapper.setProps({
|
||||
transactionCount: 2,
|
||||
})
|
||||
})
|
||||
expect(wrapper.find('div.pagination').exists()).toBe(false)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -56,12 +56,17 @@
|
||||
</transaction-list-item>
|
||||
</div>
|
||||
</div>
|
||||
<pagination-buttons
|
||||
<b-pagination
|
||||
v-if="showPagination"
|
||||
class="mt-3"
|
||||
pills
|
||||
size="lg"
|
||||
v-model="currentPage"
|
||||
:per-page="pageSize"
|
||||
:total-rows="transactionCount"
|
||||
></pagination-buttons>
|
||||
align="center"
|
||||
></b-pagination>
|
||||
|
||||
<div v-if="transactionCount <= 0" class="mt-4 text-center">
|
||||
<span>{{ $t('transaction.nullTransactions') }}</span>
|
||||
</div>
|
||||
@ -70,7 +75,6 @@
|
||||
|
||||
<script>
|
||||
import TransactionListItem from '@/components/TransactionListItem'
|
||||
import PaginationButtons from '@/components/PaginationButtons'
|
||||
import TransactionDecay from '@/components/Transactions/TransactionDecay'
|
||||
import TransactionSend from '@/components/Transactions/TransactionSend'
|
||||
import TransactionReceive from '@/components/Transactions/TransactionReceive'
|
||||
@ -81,7 +85,6 @@ export default {
|
||||
name: 'gdd-transaction-list',
|
||||
components: {
|
||||
TransactionListItem,
|
||||
PaginationButtons,
|
||||
TransactionDecay,
|
||||
TransactionSend,
|
||||
TransactionReceive,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user