import { defineComponent, nextTick } from 'vue' import { mount } from '@vue/test-utils' import { afterAll, afterEach, describe, expect, test, vi } from 'vitest' import * as Aria from '@element-plus/utils/dom/aria' import TrapFocus, { FOCUSABLE_CHILDREN } from '../trap-focus' import type { ComponentPublicInstance, VNode } from 'vue' import type { VueWrapper } from '@vue/test-utils' import type { TrapFocusElement } from '../trap-focus' const isVisibleMock = vi.spyOn(Aria, 'isVisible').mockImplementation(() => true) let wrapper: VueWrapper const _mount = (render: () => VNode) => mount(render, { global: { directives: { TrapFocus }, }, attachTo: document.body, }) afterAll(() => { isVisibleMock.mockRestore() }) afterEach(() => { wrapper.unmount() }) describe('v-trap-focus', () => { test('should fetch all focusable element', () => { wrapper = _mount(() => (
)) expect( (wrapper.element as TrapFocusElement)[FOCUSABLE_CHILDREN].length ).toBe(1) }) test('should not fetch disabled element', () => { wrapper = _mount(() => (