mirror of
https://github.com/vitest-dev/vitest.git
synced 2025-12-08 18:26:03 +00:00
24 lines
656 B
TypeScript
24 lines
656 B
TypeScript
import { render, screen } from '@testing-library/react'
|
|
import { userEvent } from '@testing-library/user-event'
|
|
import React from 'react'
|
|
import { expect, test } from 'vitest'
|
|
import Link from '../components/Link.js'
|
|
|
|
test('Link changes the state when hovered', async () => {
|
|
render(
|
|
<Link page="http://antfu.me">Anthony Fu</Link>,
|
|
)
|
|
|
|
const link = screen.getByText('Anthony Fu')
|
|
|
|
expect(link).toHaveAccessibleName('Link is normal')
|
|
|
|
await userEvent.hover(link)
|
|
|
|
await expect.poll(() => link).toHaveAccessibleName('Link is hovered')
|
|
|
|
await userEvent.unhover(link)
|
|
|
|
await expect.poll(() => link).toHaveAccessibleName('Link is normal')
|
|
})
|