Skip to content

Commit

Permalink
[test] Component unit tests - AdditionalResources (#1098)
Browse files Browse the repository at this point in the history
Closes #1088 

## Changes

- Unit tests for `<AdditionalResources/>` component

## How to test this PR

1. `yarn vitest src/**/AdditionalResources.test.tsx`

## Screenshots
<img width="1125" alt="Screenshot 2024-12-18 at 3 44 23 PM"
src="https://github.com/user-attachments/assets/4bc86cbb-c8af-425a-a5eb-3dec0f679070"
/>

<img width="885" alt="Screenshot 2024-12-19 at 9 34 55 AM"
src="https://github.com/user-attachments/assets/8ff238a1-8aaa-4733-9384-5c2136709217"
/>
  • Loading branch information
meissadia authored Dec 20, 2024
1 parent 61edf51 commit b2108a0
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/components/__tests__/AdditionalResources.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { render, screen } from '@testing-library/react';
import AdditionalResources from 'components/AdditionalResources';
import { ListLink } from 'components/Link';
import { MemoryRouter } from 'react-router-dom';

describe('<AdditionalResources />', () => {
it('Renders expected content', async () => {
render(
<MemoryRouter>
<AdditionalResources>
<ListLink href='first-link'>First link</ListLink>
<ListLink href='second-link'>Second link</ListLink>
</AdditionalResources>
</MemoryRouter>,
);

// Heading
expect(
screen.getByText('Additional resources', { selector: 'h4' }),
).toBeInTheDocument();

// Links
for (const link of [
{ name: 'First link', href: '/first-link' },
{ name: 'Second link', href: '/second-link' },
]) {
const element = screen.getByRole('link', { name: link.name });
expect(element).toBeInTheDocument();
expect(element).toHaveAttribute('href', link.href);
}
});
});

0 comments on commit b2108a0

Please sign in to comment.