mirror of
https://github.com/lana-k/sqliteviz.git
synced 2025-12-06 18:18:53 +08:00
add tests for Pager
This commit is contained in:
33
tests/unit/components/Pager.spec.js
Normal file
33
tests/unit/components/Pager.spec.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import { expect } from 'chai'
|
||||
import sinon from 'sinon'
|
||||
import { mount, shallowMount } from '@vue/test-utils'
|
||||
import Pager from '@/components/Pager.vue'
|
||||
|
||||
describe('Pager.vue', () => {
|
||||
afterEach(() => {
|
||||
sinon.restore()
|
||||
})
|
||||
|
||||
it('emits input event with a page', async () => {
|
||||
const wrapper = mount(Pager, { propsData: {
|
||||
pageCount: 5
|
||||
}})
|
||||
|
||||
// click on 'next page' link
|
||||
await wrapper.find('.paginator-next').trigger('click')
|
||||
expect(wrapper.emitted('input')[0]).to.eql([2])
|
||||
|
||||
// click on the link to page 3 (it has index 2)
|
||||
await wrapper.findAll('.paginator-page-link').at(2).trigger('click')
|
||||
expect(wrapper.emitted('input')[1]).to.eql([3])
|
||||
})
|
||||
|
||||
it('changes the page when value is changed', async () => {
|
||||
const wrapper = mount(Pager, { propsData: {
|
||||
pageCount: 5
|
||||
}})
|
||||
|
||||
await wrapper.setProps({ value: 5 })
|
||||
expect(wrapper.emitted('input')[0]).to.eql([5])
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user