mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
fixed pagination button specs
This commit is contained in:
parent
da801d6410
commit
a9b1958161
@ -5,60 +5,61 @@ import PaginationButtons from './PaginationButtons'
|
||||
const localVue = global.localVue
|
||||
|
||||
describe('PaginationButtons.vue', () => {
|
||||
let propsData = {}
|
||||
const propsData = {}
|
||||
let wrapper
|
||||
let nextButton
|
||||
let backButton
|
||||
const mocks = {
|
||||
$t: jest.fn(),
|
||||
}
|
||||
|
||||
const Wrapper = () => {
|
||||
return mount(PaginationButtons, { propsData, localVue })
|
||||
return mount(PaginationButtons, { mocks, propsData, localVue })
|
||||
}
|
||||
|
||||
describe('mount', () => {
|
||||
describe('next button', () => {
|
||||
beforeEach(() => {
|
||||
propsData.hasNext = true
|
||||
wrapper = Wrapper()
|
||||
nextButton = wrapper.find('[data-test="next-button"]')
|
||||
})
|
||||
|
||||
it('is disabled by default', () => {
|
||||
propsData = {}
|
||||
wrapper = Wrapper()
|
||||
nextButton = wrapper.find('[data-test="next-button"]')
|
||||
expect(nextButton.attributes().disabled).toEqual('disabled')
|
||||
expect(wrapper.find('.next-button').exists()).toEqual(false)
|
||||
})
|
||||
|
||||
it('is enabled if hasNext is true', () => {
|
||||
expect(nextButton.attributes().disabled).toBeUndefined()
|
||||
it('is enabled if hasNext is true', async () => {
|
||||
wrapper.setProps({ hasMoreResults: true })
|
||||
await wrapper.vm.$nextTick()
|
||||
expect(wrapper.find('.next-button').exists()).toEqual(true)
|
||||
})
|
||||
|
||||
it('emits next when clicked', async () => {
|
||||
await nextButton.trigger('click')
|
||||
wrapper.setProps({ hasMoreResults: true })
|
||||
await wrapper.vm.$nextTick()
|
||||
wrapper.find('.next-button').trigger('click')
|
||||
await wrapper.vm.$nextTick()
|
||||
expect(wrapper.emitted().next).toHaveLength(1)
|
||||
})
|
||||
})
|
||||
|
||||
describe('back button', () => {
|
||||
beforeEach(() => {
|
||||
propsData.hasPrevious = true
|
||||
wrapper = Wrapper()
|
||||
backButton = wrapper.find('[data-test="previous-button"]')
|
||||
})
|
||||
|
||||
it('is disabled by default', () => {
|
||||
propsData = {}
|
||||
wrapper = Wrapper()
|
||||
backButton = wrapper.find('[data-test="previous-button"]')
|
||||
expect(backButton.attributes().disabled).toEqual('disabled')
|
||||
expect(wrapper.find('.previous-button').exists()).toEqual(false)
|
||||
})
|
||||
|
||||
it('is enabled if hasPrevious is true', () => {
|
||||
expect(backButton.attributes().disabled).toBeUndefined()
|
||||
it('is enabled if hasPrevious is true', async () => {
|
||||
wrapper.setProps({ hasPreviousResult: true })
|
||||
await wrapper.vm.$nextTick()
|
||||
expect(wrapper.find('.previous-button').exists()).toEqual(true)
|
||||
})
|
||||
|
||||
it('emits back when clicked', async () => {
|
||||
await backButton.trigger('click')
|
||||
wrapper.setProps({ hasPreviousResult: true })
|
||||
await wrapper.vm.$nextTick()
|
||||
wrapper.find('.previous-button').trigger('click')
|
||||
await wrapper.vm.$nextTick()
|
||||
expect(wrapper.emitted().back).toHaveLength(1)
|
||||
})
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user