mirror of
https://github.com/lana-k/sqliteviz.git
synced 2025-12-07 02:28:54 +08:00
add tests for splitter and touch events
This commit is contained in:
@@ -136,4 +136,85 @@ describe('Splitpanes.vue', () => {
|
||||
wrapper.destroy()
|
||||
root.remove()
|
||||
})
|
||||
|
||||
it('drag - horizontal - touch', async () => {
|
||||
const root = document.createElement('div')
|
||||
const place = document.createElement('div')
|
||||
root.style.width = '600px'
|
||||
root.style.height = '500px'
|
||||
root.appendChild(place)
|
||||
document.body.appendChild(root)
|
||||
|
||||
// mount the component
|
||||
const wrapper = shallowMount(Splitpanes, {
|
||||
attachTo: place,
|
||||
slots: {
|
||||
leftPane: '<div />',
|
||||
rightPane: '<div />'
|
||||
},
|
||||
propsData: {
|
||||
before: { size: 10, max: 100 },
|
||||
after: { size: 90, max: 100 },
|
||||
horizontal: true
|
||||
}
|
||||
})
|
||||
|
||||
window.ontouchstart = null
|
||||
await wrapper.find('.splitpanes-splitter').trigger('touchstart')
|
||||
const event = new TouchEvent('touchmove')
|
||||
Object.defineProperty(event, 'touches', {
|
||||
value: [{
|
||||
clientX: 10,
|
||||
clientY: 250
|
||||
}],
|
||||
writable: true
|
||||
})
|
||||
document.dispatchEvent(event)
|
||||
document.dispatchEvent(new MouseEvent('touchend'))
|
||||
await wrapper.vm.$nextTick()
|
||||
expect(wrapper.findAll('.splitpanes-pane').at(0).element.style.height).to.equal('50%')
|
||||
wrapper.destroy()
|
||||
root.remove()
|
||||
delete window.ontouchstart
|
||||
})
|
||||
|
||||
it('drag - vertical - touch', async () => {
|
||||
const root = document.createElement('div')
|
||||
const place = document.createElement('div')
|
||||
root.style.width = '600px'
|
||||
root.style.height = '500px'
|
||||
root.appendChild(place)
|
||||
document.body.appendChild(root)
|
||||
|
||||
// mount the component
|
||||
const wrapper = shallowMount(Splitpanes, {
|
||||
attachTo: place,
|
||||
slots: {
|
||||
leftPane: '<div />',
|
||||
rightPane: '<div />'
|
||||
},
|
||||
propsData: {
|
||||
before: { size: 60, max: 100 },
|
||||
after: { size: 40, max: 100 }
|
||||
}
|
||||
})
|
||||
window.ontouchstart = null
|
||||
|
||||
await wrapper.find('.splitpanes-splitter').trigger('touchstart')
|
||||
const event = new TouchEvent('touchmove')
|
||||
Object.defineProperty(event, 'touches', {
|
||||
value: [{
|
||||
clientX: 300,
|
||||
clientY: 80
|
||||
}],
|
||||
writable: true
|
||||
})
|
||||
document.dispatchEvent(event)
|
||||
document.dispatchEvent(new MouseEvent('touchend'))
|
||||
await wrapper.vm.$nextTick()
|
||||
expect(wrapper.findAll('.splitpanes-pane').at(0).element.style.width).to.equal('50%')
|
||||
wrapper.destroy()
|
||||
root.remove()
|
||||
delete window.ontouchstart
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user