import { mount } from '@vue/test-utils' import * as Aria from '@element-plus/utils/aria' const isVisibleMock = jest .spyOn(Aria, 'isVisible') .mockImplementation(() => true) import TrapFocus, { ITrapFocusElement, FOCUSABLE_CHILDREN, TRAP_FOCUS_HANDLER, } from '../trap-focus' 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) expect( (wrapper.element as ITrapFocusElement)[TRAP_FOCUS_HANDLER].length, ).toBeDefined() }) test('should not fetch disabled element', () => { wrapper = _mount(`