import { nextTick } from 'vue' import { mount } from '@vue/test-utils' import * as Aria from '@element-plus/utils/aria' import TrapFocus, { FOCUSABLE_CHILDREN } from '../trap-focus' import type { ITrapFocusElement } from '../trap-focus' const isVisibleMock = jest .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(`