element-plus/packages/hooks/__tests__/use-focus.vitest.ts

18 lines
420 B
TypeScript
Raw Normal View History

import { ref } from 'vue'
import { describe, it, expect } from 'vitest'
import { useFocus } from '../use-focus'
describe('useFocus', () => {
it('should focus el', async () => {
const inputEl = document.createElement('input')
document.body.appendChild(inputEl)
const reference = ref(inputEl)
const { focus } = useFocus(reference)
focus()
expect(document.activeElement).toBe(inputEl)
})
})