mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-14 09:20:51 +08:00
b01a6f4e81
* feat: Feature/datepicker && repeat-click directive (#288) * style: fix lint * test: fix local test * test: update test * fix: update api to disabledHours * chore: update * chore: fix lint
36 lines
784 B
TypeScript
36 lines
784 B
TypeScript
import { sleep } from '@element-plus/test-utils'
|
|
import { mount } from '@vue/test-utils'
|
|
import RepeatClick from '../repeat-click'
|
|
|
|
const handler = jest.fn()
|
|
const _mount = () => mount({
|
|
template: `
|
|
<div id="block" v-repeat-click="onClick">TEST</div>
|
|
`,
|
|
directives: {
|
|
repeatClick: RepeatClick,
|
|
},
|
|
methods: {
|
|
onClick() {
|
|
handler()
|
|
},
|
|
},
|
|
})
|
|
|
|
beforeEach(() => {
|
|
handler.mockClear()
|
|
})
|
|
|
|
describe('Directives.vue', () => {
|
|
test('Click test', async () => {
|
|
const wrapper = _mount()
|
|
const block = wrapper.find('#block')
|
|
block.trigger('mousedown')
|
|
const testTime = 330
|
|
await sleep(testTime)
|
|
block.trigger('mouseup')
|
|
const expectResult = Math.floor(testTime / 100)
|
|
expect(handler).toHaveBeenCalledTimes(expectResult)
|
|
})
|
|
})
|