Skip to content

Commit

Permalink
Resolve lint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
connor-baer committed Apr 15, 2024
1 parent f2d891e commit 3c2763c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
33 changes: 17 additions & 16 deletions packages/circuit-ui/components/Anchor/Anchor.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 className={className} href="https://sumup.com">
Anchor
</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<HTMLButtonElement>();
const { container } = render(
render(
<Anchor ref={ref} onClick={vi.fn}>
Anchor
</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<HTMLAnchorElement>();
const { container } = render(
render(
<Anchor ref={ref} href="https://sumup.com">
Anchor
</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<HTMLSpanElement>();
const { container } = render(<Anchor ref={ref}>Anchor</Anchor>);
const span = container.querySelector('span');
render(<Anchor ref={ref}>Anchor</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(<Anchor {...baseProps} />);
const actual = container.querySelector('span');
render(<Anchor {...baseProps} />);
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(
<Anchor {...baseProps} href="https://sumup.com" onClick={vi.fn} />,
);
const actual = container.querySelector('a');
render(<Anchor {...baseProps} href="https://sumup.com" onClick={vi.fn} />);
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(<Anchor {...baseProps} onClick={vi.fn} />);
const actual = container.querySelector('button');
render(<Anchor {...baseProps} onClick={vi.fn} />);
const actual = screen.getByText('Anchor');
expect(actual.tagName).toBe('BUTTON');
expect(actual).toBeVisible();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* limitations under the License.
*/

/* eslint-disable testing-library/no-container */

import { describe, expect, it } from 'vitest';
import { createRef } from 'react';

Expand Down
1 change: 1 addition & 0 deletions packages/circuit-ui/components/Avatar/Avatar.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down

0 comments on commit 3c2763c

Please sign in to comment.