From 68eda84053f607184d62879746b05667392fa7fe Mon Sep 17 00:00:00 2001
From: Marco Pasqualetti <24919330+marcalexiei@users.noreply.github.com>
Date: Sun, 9 Feb 2025 19:01:30 +0100
Subject: [PATCH] test(packages/tuono-router): use screen instead of render
matchers (#540)
---
.../tuono-router/src/components/Link.spec.tsx | 20 +++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/packages/tuono-router/src/components/Link.spec.tsx b/packages/tuono-router/src/components/Link.spec.tsx
index 883c4cbd..a8c3f6ca 100644
--- a/packages/tuono-router/src/components/Link.spec.tsx
+++ b/packages/tuono-router/src/components/Link.spec.tsx
@@ -44,16 +44,16 @@ describe('Link Component', () => {
})
it('calls router.push on normal click', () => {
- const { getByRole } = render(Test Link)
- const link = getByRole('link')
+ render(Test Link)
+ const link = screen.getByRole('link')
fireEvent.click(link)
expect(pushMock).toHaveBeenCalledWith('/test', { scroll: true })
})
it('does not navigate if href starts with "#"', () => {
- const { getByRole } = render(Anchor Link)
- const link = getByRole('link')
+ render(Anchor Link)
+ const link = screen.getByRole('link')
fireEvent.click(link)
expect(pushMock).not.toHaveBeenCalled()
@@ -82,8 +82,8 @@ describe('Link Component', () => {
})
it('does not call router.push when clicked with a modifier key', () => {
- const { getByRole } = render(Test Link)
- const link = getByRole('link')
+ render(Test Link)
+ const link = screen.getByRole('link')
fireEvent.click(link, { ctrlKey: true })
fireEvent.click(link, { metaKey: true })
@@ -95,12 +95,12 @@ describe('Link Component', () => {
it('calls onClick handler when clicked', () => {
const onClickMock = vi.fn()
- const { getByRole } = render(
+ render(
Test Link
,
)
- const link = getByRole('link')
+ const link = screen.getByRole('link')
fireEvent.click(link)
@@ -110,12 +110,12 @@ describe('Link Component', () => {
it('calls onClick but does not navigate when clicked with a modifier key', () => {
const onClickMock = vi.fn()
- const { getByRole } = render(
+ render(
Test Link
,
)
- const link = getByRole('link')
+ const link = screen.getByRole('link')
fireEvent.click(link, { ctrlKey: true })
fireEvent.click(link, { metaKey: true })