From 3c2763cef4896ea9935f97bf48489940af72e52f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Connor=20B=C3=A4r?= Date: Mon, 15 Apr 2024 10:50:21 +0200 Subject: [PATCH] Resolve lint warnings --- .../components/Anchor/Anchor.spec.tsx | 33 ++++++++++--------- .../AspectRatio/AspectRatio.spec.tsx | 2 ++ .../components/Avatar/Avatar.spec.tsx | 1 + 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/packages/circuit-ui/components/Anchor/Anchor.spec.tsx b/packages/circuit-ui/components/Anchor/Anchor.spec.tsx index a41a2f5448..db799a39bb 100644 --- a/packages/circuit-ui/components/Anchor/Anchor.spec.tsx +++ b/packages/circuit-ui/components/Anchor/Anchor.spec.tsx @@ -26,61 +26,62 @@ describe('Anchor', () => { it('should merge a custom class name with the default ones', () => { const className = 'foo'; - const { container } = render( + render( Anchor , ); - const anchor = container.querySelector('a'); + const anchor = screen.getByRole('link'); expect(anchor?.className).toContain(className); }); it('should forward a ref for a button', () => { const ref = createRef(); - const { container } = render( + render( Anchor , ); - const button = container.querySelector('button'); + const button = screen.getByRole('button'); expect(ref.current).toBe(button); }); it('should forward a ref for a link', () => { const ref = createRef(); - const { container } = render( + render( Anchor , ); - const anchor = container.querySelector('a'); + const anchor = screen.getByRole('link'); expect(ref.current).toBe(anchor); }); it('should forward a ref for a span', () => { const ref = createRef(); - const { container } = render(Anchor); - const span = container.querySelector('span'); + render(Anchor); + const span = screen.getByText('Anchor'); expect(ref.current).toBe(span); }); it('should render as a `span` when neither href nor onClick is passed', () => { - const { container } = render(); - const actual = container.querySelector('span'); + render(); + const actual = screen.getByText('Anchor'); + expect(actual.tagName).toBe('SPAN'); expect(actual).toBeVisible(); }); it('should render as an `a` when an href (and onClick) is passed', () => { - const { container } = render( - , - ); - const actual = container.querySelector('a'); + render(); + const actual = screen.getByText('Anchor'); + expect(actual.tagName).toBe('A'); expect(actual).toBeVisible(); }); it('should render as a `button` when an onClick is passed', () => { - const { container } = render(); - const actual = container.querySelector('button'); + render(); + const actual = screen.getByText('Anchor'); + expect(actual.tagName).toBe('BUTTON'); expect(actual).toBeVisible(); }); diff --git a/packages/circuit-ui/components/AspectRatio/AspectRatio.spec.tsx b/packages/circuit-ui/components/AspectRatio/AspectRatio.spec.tsx index 1fe99a4a6c..18a98e5b56 100644 --- a/packages/circuit-ui/components/AspectRatio/AspectRatio.spec.tsx +++ b/packages/circuit-ui/components/AspectRatio/AspectRatio.spec.tsx @@ -13,6 +13,8 @@ * limitations under the License. */ +/* eslint-disable testing-library/no-container */ + import { describe, expect, it } from 'vitest'; import { createRef } from 'react'; diff --git a/packages/circuit-ui/components/Avatar/Avatar.spec.tsx b/packages/circuit-ui/components/Avatar/Avatar.spec.tsx index 840c196b34..0ab3b102f2 100644 --- a/packages/circuit-ui/components/Avatar/Avatar.spec.tsx +++ b/packages/circuit-ui/components/Avatar/Avatar.spec.tsx @@ -70,6 +70,7 @@ describe('Avatar', () => { const avatarWithAlternativeText = screen.queryByRole('img'); expect(avatarWithAlternativeText).not.toBeInTheDocument(); + // eslint-disable-next-line testing-library/no-container const avatarEl = container.querySelector('[aria-hidden=true]'); expect(avatarEl).toBeInTheDocument(); });