2020-08-18 00:25:10 +08:00
|
|
|
import { mount } from '@vue/test-utils'
|
|
|
|
import * as Vue from 'vue'
|
|
|
|
import * as popperExports from '@popperjs/core'
|
|
|
|
import ElPopper from '../src/index.vue'
|
|
|
|
|
|
|
|
import type { VueWrapper } from '@vue/test-utils'
|
2020-11-20 10:04:20 +08:00
|
|
|
import PopupManager from '@element-plus/utils/popup-manager'
|
2020-08-18 00:25:10 +08:00
|
|
|
|
2020-09-14 10:03:33 +08:00
|
|
|
type UnknownProps = Record<string, unknown>
|
2020-08-18 00:25:10 +08:00
|
|
|
|
2020-08-18 18:02:28 +08:00
|
|
|
jest.useFakeTimers()
|
|
|
|
|
2020-08-18 20:23:39 +08:00
|
|
|
const { h, nextTick } = Vue
|
2020-08-18 11:58:34 +08:00
|
|
|
const AXIOM = 'Rem is the best girl'
|
2020-08-18 18:02:28 +08:00
|
|
|
const selector = '[role="tooltip"]'
|
|
|
|
const TEST_TRIGGER = 'test-trigger'
|
|
|
|
const MOUSE_ENTER_EVENT = 'mouseenter'
|
|
|
|
const MOUSE_LEAVE_EVENT = 'mouseleave'
|
2020-08-28 10:47:02 +08:00
|
|
|
const CLICK_EVENT = 'click'
|
|
|
|
const FOCUS_EVENT = 'focus'
|
|
|
|
const BLUR_EVENT = 'blur'
|
2020-08-18 18:02:28 +08:00
|
|
|
const DISPLAY_NONE = 'display: none'
|
2020-08-18 00:25:10 +08:00
|
|
|
|
2020-09-14 10:03:33 +08:00
|
|
|
const Wrapped = (props: UnknownProps, { slots }) => {
|
|
|
|
return h('div', h(ElPopper, props, slots))
|
|
|
|
}
|
|
|
|
const Transition = (_: UnknownProps, { attrs, slots }) => h('div', attrs, slots)
|
2020-08-18 00:25:10 +08:00
|
|
|
Transition.displayName = 'Transition'
|
|
|
|
// eslint-disable-next-line
|
2020-09-14 10:03:33 +08:00
|
|
|
const _mount = (props: UnknownProps = {}, slots = {}): VueWrapper<any> =>
|
2020-08-18 00:25:10 +08:00
|
|
|
mount(Wrapped, {
|
|
|
|
props,
|
2020-08-18 18:02:28 +08:00
|
|
|
slots: {
|
2020-09-22 13:02:05 +08:00
|
|
|
trigger: () =>
|
|
|
|
h('div', {
|
|
|
|
class: TEST_TRIGGER,
|
|
|
|
}),
|
2020-08-18 18:02:28 +08:00
|
|
|
...slots,
|
|
|
|
},
|
2020-11-10 14:55:03 +08:00
|
|
|
attachTo: 'body',
|
2020-08-18 00:25:10 +08:00
|
|
|
})
|
|
|
|
|
2020-09-22 13:02:05 +08:00
|
|
|
const popperMock = jest
|
|
|
|
.spyOn(popperExports, 'createPopper')
|
|
|
|
.mockImplementation(() => ({
|
|
|
|
update: jest.fn(),
|
|
|
|
forceUpdate: jest.fn(),
|
|
|
|
setOptions: jest.fn(),
|
|
|
|
destroy: jest.fn(),
|
|
|
|
state: null,
|
|
|
|
}))
|
2020-08-18 11:58:34 +08:00
|
|
|
|
2020-08-18 00:25:10 +08:00
|
|
|
describe('Popper.vue', () => {
|
|
|
|
const oldTransition = Vue.Transition
|
|
|
|
beforeAll(() => {
|
2020-09-14 10:03:33 +08:00
|
|
|
(Vue as any).Transition = Transition
|
2020-08-18 00:25:10 +08:00
|
|
|
})
|
2020-08-18 11:58:34 +08:00
|
|
|
|
2020-08-18 00:25:10 +08:00
|
|
|
afterAll(() => {
|
|
|
|
popperMock.mockReset()
|
|
|
|
;(Vue as any).Transition = oldTransition
|
|
|
|
})
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
popperMock.mockClear()
|
|
|
|
})
|
|
|
|
|
|
|
|
test('render test', () => {
|
2020-09-22 13:02:05 +08:00
|
|
|
let wrapper = _mount(
|
|
|
|
{
|
|
|
|
appendToBody: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
default: () => AXIOM,
|
|
|
|
},
|
|
|
|
)
|
2020-08-18 00:25:10 +08:00
|
|
|
|
|
|
|
expect(wrapper.text()).toEqual(AXIOM)
|
|
|
|
|
|
|
|
wrapper = _mount({
|
|
|
|
content: AXIOM,
|
2020-10-19 13:44:50 +08:00
|
|
|
appendToBody: false,
|
2020-08-18 00:25:10 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
expect(wrapper.text()).toEqual(AXIOM)
|
|
|
|
})
|
|
|
|
|
|
|
|
test('append to body', () => {
|
|
|
|
let wrapper = _mount()
|
2020-11-10 14:55:03 +08:00
|
|
|
expect(wrapper.find(selector).exists()).toBe(true)
|
2020-09-14 10:03:33 +08:00
|
|
|
|
2020-08-25 22:25:46 +08:00
|
|
|
/**
|
|
|
|
* Current layout of `ElPopper`
|
|
|
|
* --> Teleport
|
|
|
|
* --> mask
|
|
|
|
* --> transition
|
|
|
|
* --> popper
|
|
|
|
*/
|
|
|
|
|
2020-08-18 00:25:10 +08:00
|
|
|
wrapper = _mount({
|
2020-11-10 14:55:03 +08:00
|
|
|
appendToBody: true,
|
2020-08-18 00:25:10 +08:00
|
|
|
})
|
|
|
|
|
2020-11-10 14:55:03 +08:00
|
|
|
expect(wrapper.find(selector).exists()).toBe(false)
|
2020-08-18 00:25:10 +08:00
|
|
|
})
|
|
|
|
|
2020-11-20 10:04:20 +08:00
|
|
|
test('popper z-index should be dynamical', () => {
|
|
|
|
const wrapper = _mount()
|
|
|
|
|
|
|
|
expect(
|
|
|
|
Number.parseInt(
|
|
|
|
window.getComputedStyle(wrapper.find('.el-popper').element).zIndex,
|
|
|
|
),
|
|
|
|
).toBeLessThanOrEqual(PopupManager.zIndex)
|
|
|
|
})
|
|
|
|
|
2020-08-18 00:25:10 +08:00
|
|
|
test('should show popper when mouse entered and hide when popper left', async () => {
|
|
|
|
const wrapper = _mount({
|
|
|
|
appendToBody: false,
|
|
|
|
})
|
|
|
|
|
2020-09-14 10:03:33 +08:00
|
|
|
const popper = wrapper.find(selector)
|
|
|
|
expect(popper.attributes('style')).toContain(DISPLAY_NONE)
|
2020-08-18 00:25:10 +08:00
|
|
|
|
2020-09-14 10:03:33 +08:00
|
|
|
const $trigger = wrapper.find(`.${TEST_TRIGGER}`)
|
|
|
|
await $trigger.trigger(MOUSE_ENTER_EVENT)
|
2020-08-18 00:25:10 +08:00
|
|
|
|
2020-09-14 10:03:33 +08:00
|
|
|
expect(popper.attributes('style')).not.toContain(DISPLAY_NONE)
|
|
|
|
|
|
|
|
await $trigger.trigger(MOUSE_LEAVE_EVENT)
|
2020-08-18 00:25:10 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
test('should be able to manual open', async () => {
|
|
|
|
const wrapper = _mount({
|
|
|
|
manualMode: true,
|
|
|
|
appendToBody: false,
|
2020-09-14 10:03:33 +08:00
|
|
|
visible: false,
|
2020-08-18 00:25:10 +08:00
|
|
|
})
|
2020-08-18 18:02:28 +08:00
|
|
|
expect(wrapper.find(selector).attributes('style')).toContain(DISPLAY_NONE)
|
|
|
|
await wrapper.find(selector).trigger(MOUSE_ENTER_EVENT)
|
2020-08-18 11:58:34 +08:00
|
|
|
|
2020-08-18 18:02:28 +08:00
|
|
|
expect(wrapper.find(selector).attributes('style')).toContain(DISPLAY_NONE)
|
2020-08-18 00:25:10 +08:00
|
|
|
await wrapper.setProps({
|
2020-09-14 10:03:33 +08:00
|
|
|
visible: true,
|
2020-08-18 00:25:10 +08:00
|
|
|
})
|
|
|
|
|
2020-09-22 13:02:05 +08:00
|
|
|
expect(wrapper.find(selector).attributes('style')).not.toContain(
|
|
|
|
DISPLAY_NONE,
|
|
|
|
)
|
2020-08-18 00:25:10 +08:00
|
|
|
})
|
|
|
|
|
2020-11-22 15:46:49 +08:00
|
|
|
test('should not stop propagation when stop mode is disabled', async () => {
|
2020-11-16 10:35:30 +08:00
|
|
|
const onMouseUp = jest.fn()
|
|
|
|
const onMouseDown = jest.fn()
|
|
|
|
document.addEventListener('mouseup', onMouseUp)
|
|
|
|
document.addEventListener('mousedown', onMouseDown)
|
|
|
|
|
|
|
|
const wrapper = _mount({
|
2020-11-22 15:46:49 +08:00
|
|
|
stopPopperMouseEvent: false,
|
2020-11-16 10:35:30 +08:00
|
|
|
visible: true,
|
|
|
|
})
|
|
|
|
await nextTick()
|
|
|
|
|
|
|
|
await wrapper.find('.el-popper').trigger('mousedown')
|
|
|
|
expect(onMouseDown).toHaveBeenCalled()
|
|
|
|
await wrapper.find('.el-popper').trigger('mouseup')
|
|
|
|
expect(onMouseUp).toHaveBeenCalled()
|
|
|
|
|
|
|
|
await wrapper.setProps({
|
2020-11-22 15:46:49 +08:00
|
|
|
stopPopperMouseEvent: true,
|
2020-11-16 10:35:30 +08:00
|
|
|
})
|
|
|
|
await nextTick()
|
|
|
|
|
|
|
|
await wrapper.find('.el-popper').trigger('mousedown')
|
|
|
|
expect(onMouseDown).toHaveBeenCalledTimes(1)
|
|
|
|
await wrapper.find('.el-popper').trigger('mouseup')
|
|
|
|
expect(onMouseUp).toHaveBeenCalledTimes(1)
|
|
|
|
document.removeEventListener('mouseup', onMouseUp)
|
|
|
|
document.removeEventListener('mousedown', onMouseDown)
|
|
|
|
})
|
|
|
|
|
2020-08-18 00:25:10 +08:00
|
|
|
test('should disable popper to popup', async () => {
|
|
|
|
const wrapper = _mount({
|
|
|
|
disabled: true,
|
|
|
|
appendToBody: false,
|
|
|
|
})
|
|
|
|
|
2020-09-14 10:03:33 +08:00
|
|
|
const $trigger = wrapper.find(`.${TEST_TRIGGER}`)
|
2020-08-18 18:02:28 +08:00
|
|
|
expect(wrapper.find(selector).attributes('style')).toContain(DISPLAY_NONE)
|
2020-09-14 10:03:33 +08:00
|
|
|
await $trigger.trigger(MOUSE_ENTER_EVENT)
|
2020-08-18 00:25:10 +08:00
|
|
|
|
2020-08-18 18:02:28 +08:00
|
|
|
expect(wrapper.find(selector).attributes('style')).toContain(DISPLAY_NONE)
|
2020-08-18 00:25:10 +08:00
|
|
|
|
|
|
|
await wrapper.setProps({
|
|
|
|
disabled: false,
|
|
|
|
})
|
2020-09-14 10:03:33 +08:00
|
|
|
|
|
|
|
await $trigger.trigger(MOUSE_ENTER_EVENT)
|
2020-08-18 11:58:34 +08:00
|
|
|
|
2020-09-22 13:02:05 +08:00
|
|
|
expect(wrapper.find(selector).attributes('style')).not.toContain(
|
|
|
|
DISPLAY_NONE,
|
|
|
|
)
|
2020-08-18 00:25:10 +08:00
|
|
|
})
|
|
|
|
|
2020-08-18 18:02:28 +08:00
|
|
|
test('should initialize a new popper when component mounted', async () => {
|
|
|
|
_mount({
|
|
|
|
appendToBody: false,
|
2020-09-14 10:03:33 +08:00
|
|
|
visible: true,
|
2020-08-18 00:25:10 +08:00
|
|
|
})
|
|
|
|
|
2020-09-15 21:58:36 +08:00
|
|
|
// expect(popperExports.createPopper).toHaveBeenCalledTimes(1)
|
2020-08-18 00:25:10 +08:00
|
|
|
})
|
|
|
|
|
2020-08-18 18:02:28 +08:00
|
|
|
test('should hide after hide after is given', async () => {
|
2020-08-18 00:25:10 +08:00
|
|
|
const wrapper = _mount({
|
2020-08-18 18:02:28 +08:00
|
|
|
hideAfter: 200,
|
2020-08-18 00:25:10 +08:00
|
|
|
appendToBody: false,
|
|
|
|
})
|
2020-09-14 10:03:33 +08:00
|
|
|
const $trigger = wrapper.find(`.${TEST_TRIGGER}`)
|
|
|
|
await $trigger.trigger(MOUSE_ENTER_EVENT)
|
2020-09-22 13:02:05 +08:00
|
|
|
expect(wrapper.find(selector).attributes('style')).not.toContain(
|
|
|
|
DISPLAY_NONE,
|
|
|
|
)
|
2020-08-18 20:23:39 +08:00
|
|
|
jest.runOnlyPendingTimers()
|
|
|
|
await nextTick()
|
|
|
|
expect(wrapper.find(selector).attributes('style')).toContain(DISPLAY_NONE)
|
2020-08-18 18:02:28 +08:00
|
|
|
})
|
2020-08-18 00:25:10 +08:00
|
|
|
|
2020-09-15 21:58:36 +08:00
|
|
|
test('should throw error when there is no trigger', async () => {
|
2020-08-18 20:23:39 +08:00
|
|
|
const errorHandler = jest.fn()
|
|
|
|
mount(Wrapped, {
|
|
|
|
slots: {
|
|
|
|
trigger: undefined,
|
|
|
|
},
|
|
|
|
global: {
|
|
|
|
config: {
|
|
|
|
errorHandler(err: Error) {
|
|
|
|
errorHandler(err)
|
|
|
|
},
|
|
|
|
warnHandler() {
|
|
|
|
// suppress warning
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-08-18 00:25:10 +08:00
|
|
|
})
|
2020-08-18 20:23:39 +08:00
|
|
|
// due to vue catches the error during rendering, and throws it asynchronously
|
|
|
|
// the only way to test this is by providing an error handler to catch it
|
2020-09-14 10:03:33 +08:00
|
|
|
// first time get caught when calling setup function
|
|
|
|
// second time get caught when calling render function
|
|
|
|
expect(errorHandler).toHaveBeenCalledTimes(2)
|
2020-08-18 00:25:10 +08:00
|
|
|
})
|
2020-08-28 10:47:02 +08:00
|
|
|
describe('trigger', () => {
|
|
|
|
test('should work with click trigger', async () => {
|
|
|
|
const wrapper = _mount({
|
2020-09-14 10:03:33 +08:00
|
|
|
trigger: [CLICK_EVENT],
|
2020-08-28 10:47:02 +08:00
|
|
|
appendToBody: false,
|
2020-09-14 22:08:56 +08:00
|
|
|
closeDelay: 0,
|
2020-08-28 10:47:02 +08:00
|
|
|
})
|
|
|
|
await nextTick()
|
|
|
|
|
|
|
|
const trigger = wrapper.find(`.${TEST_TRIGGER}`)
|
|
|
|
const popper = wrapper.findComponent(ElPopper)
|
2020-09-14 22:08:56 +08:00
|
|
|
|
2020-09-14 10:03:33 +08:00
|
|
|
expect(popper.vm.visibility).toBe(false)
|
2020-08-28 10:47:02 +08:00
|
|
|
// for now triggering event on element via DOMWrapper is not available so we need to apply
|
|
|
|
// old way
|
|
|
|
await trigger.trigger(CLICK_EVENT)
|
|
|
|
|
2020-09-14 10:03:33 +08:00
|
|
|
expect(popper.vm.visibility).toBe(true)
|
2020-08-28 10:47:02 +08:00
|
|
|
|
2020-09-14 10:03:33 +08:00
|
|
|
await trigger.trigger(MOUSE_LEAVE_EVENT)
|
|
|
|
expect(popper.vm.visibility).toBe(true)
|
2020-09-22 13:02:05 +08:00
|
|
|
|
|
|
|
await wrapper.find('.el-popper').trigger(MOUSE_LEAVE_EVENT)
|
|
|
|
expect(popper.vm.visibility).toBe(true)
|
2020-09-14 10:03:33 +08:00
|
|
|
await trigger.trigger(BLUR_EVENT)
|
|
|
|
expect(popper.vm.visibility).toBe(true)
|
|
|
|
await trigger.trigger(CLICK_EVENT)
|
|
|
|
expect(popper.vm.visibility).toBe(false)
|
2020-08-28 10:47:02 +08:00
|
|
|
})
|
|
|
|
|
2020-09-22 13:02:05 +08:00
|
|
|
test('should work with string trigger', async () => {
|
|
|
|
const wrapper = _mount({
|
|
|
|
trigger: CLICK_EVENT,
|
|
|
|
appendToBody: false,
|
|
|
|
closeDelay: 0,
|
|
|
|
})
|
|
|
|
await nextTick()
|
|
|
|
|
|
|
|
const trigger = wrapper.find(`.${TEST_TRIGGER}`)
|
|
|
|
const popper = wrapper.findComponent(ElPopper)
|
|
|
|
|
|
|
|
await trigger.trigger(CLICK_EVENT)
|
|
|
|
expect(popper.vm.visibility).toBe(true)
|
|
|
|
|
|
|
|
await wrapper.find('.el-popper').trigger(MOUSE_LEAVE_EVENT)
|
|
|
|
expect(popper.vm.visibility).toBe(true)
|
|
|
|
|
|
|
|
await trigger.trigger(CLICK_EVENT)
|
|
|
|
expect(popper.vm.visibility).toBe(false)
|
|
|
|
})
|
|
|
|
|
2020-08-28 10:47:02 +08:00
|
|
|
test('should work with hover trigger', async () => {
|
|
|
|
const wrapper = _mount({
|
|
|
|
trigger: ['hover'],
|
|
|
|
appendToBody: false,
|
2020-09-14 22:08:56 +08:00
|
|
|
closeDelay: 0,
|
2020-08-28 10:47:02 +08:00
|
|
|
})
|
|
|
|
await nextTick()
|
|
|
|
|
|
|
|
const trigger = wrapper.find(`.${TEST_TRIGGER}`)
|
|
|
|
const popper = wrapper.findComponent(ElPopper)
|
2020-09-14 10:03:33 +08:00
|
|
|
expect(popper.vm.visibility).toBe(false)
|
2020-08-28 10:47:02 +08:00
|
|
|
// for now triggering event on element via DOMWrapper is not available so we need to apply
|
|
|
|
// old way
|
|
|
|
await trigger.trigger(MOUSE_ENTER_EVENT)
|
|
|
|
|
2020-09-14 10:03:33 +08:00
|
|
|
expect(popper.vm.visibility).toBe(true)
|
|
|
|
|
|
|
|
await trigger.trigger(BLUR_EVENT)
|
|
|
|
expect(popper.vm.visibility).toBe(true)
|
2020-08-28 10:47:02 +08:00
|
|
|
|
|
|
|
await trigger.trigger(MOUSE_LEAVE_EVENT)
|
2020-09-14 10:03:33 +08:00
|
|
|
expect(popper.vm.visibility).toBe(false)
|
2020-08-28 10:47:02 +08:00
|
|
|
|
|
|
|
await trigger.trigger(FOCUS_EVENT)
|
2020-09-14 10:03:33 +08:00
|
|
|
expect(popper.vm.visibility).toBe(false)
|
2020-08-28 10:47:02 +08:00
|
|
|
|
|
|
|
await trigger.trigger(CLICK_EVENT)
|
2020-09-14 10:03:33 +08:00
|
|
|
expect(popper.vm.visibility).toBe(false)
|
2020-08-28 10:47:02 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
test('should work with focus trigger', async () => {
|
|
|
|
const wrapper = _mount({
|
|
|
|
trigger: [FOCUS_EVENT],
|
|
|
|
appendToBody: false,
|
2020-09-14 22:08:56 +08:00
|
|
|
closeDelay: 0,
|
2020-08-28 10:47:02 +08:00
|
|
|
})
|
|
|
|
await nextTick()
|
|
|
|
|
|
|
|
const trigger = wrapper.find(`.${TEST_TRIGGER}`)
|
|
|
|
const popper = wrapper.findComponent(ElPopper)
|
2020-09-14 10:03:33 +08:00
|
|
|
expect(popper.vm.visibility).toBe(false)
|
2020-08-28 10:47:02 +08:00
|
|
|
// for now triggering event on element via DOMWrapper is not available so we need to apply
|
|
|
|
// old way
|
|
|
|
await trigger.trigger(FOCUS_EVENT)
|
2020-09-14 10:03:33 +08:00
|
|
|
expect(popper.vm.visibility).toBe(true)
|
|
|
|
|
|
|
|
await trigger.trigger(MOUSE_LEAVE_EVENT)
|
|
|
|
expect(popper.vm.visibility).toBe(true)
|
2020-08-28 10:47:02 +08:00
|
|
|
|
2020-09-14 10:03:33 +08:00
|
|
|
await trigger.trigger(CLICK_EVENT)
|
|
|
|
expect(popper.vm.visibility).toBe(true)
|
2020-08-28 10:47:02 +08:00
|
|
|
|
|
|
|
await trigger.trigger(BLUR_EVENT)
|
2020-09-14 10:03:33 +08:00
|
|
|
expect(popper.vm.visibility).toBe(false)
|
2020-08-28 10:47:02 +08:00
|
|
|
|
|
|
|
await trigger.trigger(MOUSE_ENTER_EVENT)
|
2020-09-14 10:03:33 +08:00
|
|
|
expect(popper.vm.visibility).toBe(false)
|
2020-08-28 10:47:02 +08:00
|
|
|
|
|
|
|
await trigger.trigger(CLICK_EVENT)
|
2020-09-14 10:03:33 +08:00
|
|
|
expect(popper.vm.visibility).toBe(false)
|
2020-09-22 13:02:05 +08:00
|
|
|
|
|
|
|
// testing
|
|
|
|
await trigger.trigger(FOCUS_EVENT)
|
|
|
|
expect(popper.vm.visibility).toBe(true)
|
|
|
|
|
|
|
|
await popper.trigger(MOUSE_LEAVE_EVENT)
|
|
|
|
expect(popper.vm.visibility).toBe(true)
|
2020-08-28 10:47:02 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
test('combined trigger', async () => {
|
|
|
|
const wrapper = _mount({
|
|
|
|
trigger: [FOCUS_EVENT, CLICK_EVENT, 'hover'],
|
|
|
|
appendToBody: false,
|
2020-09-14 22:08:56 +08:00
|
|
|
closeDelay: 0,
|
2020-08-28 10:47:02 +08:00
|
|
|
})
|
|
|
|
await nextTick()
|
|
|
|
|
|
|
|
const trigger = wrapper.find(`.${TEST_TRIGGER}`)
|
|
|
|
const popper = wrapper.findComponent(ElPopper)
|
2020-09-14 10:03:33 +08:00
|
|
|
expect(popper.vm.visibility).toBe(false)
|
2020-08-28 10:47:02 +08:00
|
|
|
// for now triggering event on element via DOMWrapper is not available so we need to apply
|
|
|
|
// old way
|
|
|
|
await trigger.trigger(CLICK_EVENT)
|
|
|
|
|
2020-09-14 10:03:33 +08:00
|
|
|
expect(popper.vm.visibility).toBe(true)
|
2020-08-28 10:47:02 +08:00
|
|
|
|
|
|
|
await trigger.trigger(BLUR_EVENT)
|
2020-09-14 10:03:33 +08:00
|
|
|
expect(popper.vm.visibility).toBe(false)
|
2020-08-28 10:47:02 +08:00
|
|
|
|
|
|
|
await trigger.trigger(MOUSE_ENTER_EVENT)
|
2020-09-14 10:03:33 +08:00
|
|
|
expect(popper.vm.visibility).toBe(true)
|
2020-08-28 10:47:02 +08:00
|
|
|
|
|
|
|
await trigger.trigger(CLICK_EVENT)
|
2020-09-14 10:03:33 +08:00
|
|
|
expect(popper.vm.visibility).toBe(false)
|
2020-08-28 10:47:02 +08:00
|
|
|
|
|
|
|
await trigger.trigger(FOCUS_EVENT)
|
2020-09-14 10:03:33 +08:00
|
|
|
expect(popper.vm.visibility).toBe(true)
|
|
|
|
|
|
|
|
await trigger.trigger(CLICK_EVENT)
|
|
|
|
expect(popper.vm.visibility).toBe(true)
|
2020-08-28 10:47:02 +08:00
|
|
|
|
|
|
|
await trigger.trigger(CLICK_EVENT)
|
2020-09-14 10:03:33 +08:00
|
|
|
expect(popper.vm.visibility).toBe(false)
|
2020-08-28 10:47:02 +08:00
|
|
|
})
|
|
|
|
})
|
2020-08-18 00:25:10 +08:00
|
|
|
})
|