import { 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 { ITrapFocusElement } from '../trap-focus' const isVisibleMock = vi.spyOn(Aria, 'isVisible').mockImplementation(() => true) let wrapper const _mount = (template: string) => mount( { template, props: {}, }, { 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 ITrapFocusElement)[FOCUSABLE_CHILDREN].length ).toBe(1) }) test('should not fetch disabled element', () => { wrapper = _mount(`