Vladimir 937cca80a3
chore: update lit example to use the new locators API (#6628)
Co-authored-by: Hiroshi Ogawa <hi.ogawa.zz@gmail.com>
2024-10-03 16:24:06 +02:00

24 lines
657 B
TypeScript

import React from 'react'
import { expect, test } from 'vitest'
import { render, screen } from '@testing-library/react'
import { userEvent } from '@testing-library/user-event'
import Link from '../components/Link.jsx'
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')
})