1
0
mirror of https://github.com/lana-k/sqliteviz.git synced 2025-12-06 10:08:52 +08:00

add tests for Pager

This commit is contained in:
lana-k
2021-02-26 21:19:13 +01:00
parent 8e5e2787c7
commit 6cb0d2d95d

View 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])
})
})