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', () => {
|
describe.only('pagination buttons', () => {
|
||||||
const transactions = Array.from({ length: 42 }, (_, idx) => {
|
it('shows the pagination buttons if transactionCount > 25', () => {
|
||||||
return {
|
beforeEach(async () => {
|
||||||
amount: '3.14',
|
await wrapper.setProps({
|
||||||
balanceDate: '2021-04-29T17:26:40+00:00',
|
transactionCount: 42,
|
||||||
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(),
|
|
||||||
})
|
})
|
||||||
paginationButtons = wrapper.find('div.pagination-buttons')
|
expect(wrapper.find('div.pagination')).toBeTruthy()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('shows the pagination buttons', () => {
|
it('shows no the pagination buttons if transactionCount < 25', () => {
|
||||||
expect(paginationButtons.exists()).toBeTruthy()
|
beforeEach(async () => {
|
||||||
})
|
await wrapper.setProps({
|
||||||
|
transactionCount: 2,
|
||||||
it('has the previous button disabled', () => {
|
})
|
||||||
expect(paginationButtons.find('button.previous-page').attributes('disabled')).toBe(
|
})
|
||||||
'disabled',
|
expect(wrapper.find('div.pagination').exists()).toBe(false)
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
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()
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@ -56,12 +56,17 @@
|
|||||||
</transaction-list-item>
|
</transaction-list-item>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<pagination-buttons
|
<b-pagination
|
||||||
v-if="showPagination"
|
v-if="showPagination"
|
||||||
|
class="mt-3"
|
||||||
|
pills
|
||||||
|
size="lg"
|
||||||
v-model="currentPage"
|
v-model="currentPage"
|
||||||
:per-page="pageSize"
|
:per-page="pageSize"
|
||||||
:total-rows="transactionCount"
|
:total-rows="transactionCount"
|
||||||
></pagination-buttons>
|
align="center"
|
||||||
|
></b-pagination>
|
||||||
|
|
||||||
<div v-if="transactionCount <= 0" class="mt-4 text-center">
|
<div v-if="transactionCount <= 0" class="mt-4 text-center">
|
||||||
<span>{{ $t('transaction.nullTransactions') }}</span>
|
<span>{{ $t('transaction.nullTransactions') }}</span>
|
||||||
</div>
|
</div>
|
||||||
@ -70,7 +75,6 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import TransactionListItem from '@/components/TransactionListItem'
|
import TransactionListItem from '@/components/TransactionListItem'
|
||||||
import PaginationButtons from '@/components/PaginationButtons'
|
|
||||||
import TransactionDecay from '@/components/Transactions/TransactionDecay'
|
import TransactionDecay from '@/components/Transactions/TransactionDecay'
|
||||||
import TransactionSend from '@/components/Transactions/TransactionSend'
|
import TransactionSend from '@/components/Transactions/TransactionSend'
|
||||||
import TransactionReceive from '@/components/Transactions/TransactionReceive'
|
import TransactionReceive from '@/components/Transactions/TransactionReceive'
|
||||||
@ -81,7 +85,6 @@ export default {
|
|||||||
name: 'gdd-transaction-list',
|
name: 'gdd-transaction-list',
|
||||||
components: {
|
components: {
|
||||||
TransactionListItem,
|
TransactionListItem,
|
||||||
PaginationButtons,
|
|
||||||
TransactionDecay,
|
TransactionDecay,
|
||||||
TransactionSend,
|
TransactionSend,
|
||||||
TransactionReceive,
|
TransactionReceive,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user