remove unused pagination component

This commit is contained in:
Moriz Wahl 2022-04-05 13:30:06 +02:00
parent f8412acb5e
commit ddeb936634
2 changed files with 0 additions and 102 deletions

View File

@ -1,49 +0,0 @@
import { mount } from '@vue/test-utils'
import PaginationButtons from './PaginationButtons'
const localVue = global.localVue
const propsData = {
totalRows: 42,
perPage: 12,
value: 1,
}
describe('PaginationButtons', () => {
let wrapper
const mocks = {
$t: jest.fn((t) => t),
}
const Wrapper = () => {
return mount(PaginationButtons, { localVue, mocks, propsData })
}
describe('mount', () => {
beforeEach(() => {
wrapper = Wrapper()
})
it('renders the component', () => {
expect(wrapper.find('div.pagination-buttons').exists()).toBeTruthy()
})
describe('with active buttons', () => {
it('emits input next page button is clicked', async () => {
wrapper.find('button.next-page').trigger('click')
await wrapper.vm.$nextTick()
expect(wrapper.emitted().input[0]).toEqual([2])
})
it('emits input when previous page button is clicked', async () => {
wrapper.setProps({ value: 2 })
wrapper.setData({ currentValue: 2 })
await wrapper.vm.$nextTick()
wrapper.find('button.previous-page').trigger('click')
await wrapper.vm.$nextTick()
expect(wrapper.emitted().input[0]).toEqual([1])
})
})
})
})

View File

@ -1,53 +0,0 @@
<template>
<div class="pagination-buttons" v-if="totalRows > perPage">
<b-row class="m-4">
<b-col class="text-right">
<b-button class="previous-page" :disabled="!hasPrevious" @click="currentValue--">
<b-icon icon="chevron-left" variant="primary"></b-icon>
</b-button>
</b-col>
<b-col cols="3">
<p class="text-center pt-2">{{ value }} {{ $t('math.div') }} {{ totalPages }}</p>
</b-col>
<b-col>
<b-button class="next-page" :disabled="!hasNext" @click="currentValue++">
<b-icon icon="chevron-right" variant="primary"></b-icon>
</b-button>
</b-col>
</b-row>
</div>
</template>
<script>
export default {
name: 'PaginationButtons',
props: {
totalRows: { required: true },
perPage: { type: Number, required: true },
value: { type: Number, required: true },
},
data() {
return {
currentValue: { type: Number, default: 1 },
}
},
computed: {
hasNext() {
return this.value * this.perPage < this.totalRows
},
hasPrevious() {
return this.value > 1
},
totalPages() {
return Math.ceil(this.totalRows / this.perPage)
},
},
created() {
this.currentValue = this.value
},
watch: {
currentValue() {
if (this.currentValue !== this.value) this.$emit('input', this.currentValue)
},
},
}
</script>