generated from uc-cdis/commons-frontend-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(quickLinks): updated unit tests
- Loading branch information
1 parent
1057f3a
commit d2eb4e3
Showing
3 changed files
with
36 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 33 additions & 9 deletions
42
src/lib/Home/Components/ResourceCallout/ResourceCallout.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,36 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; | ||
import ResourceCallout from './ResourceCallout'; | ||
|
||
describe('ResourceCallout Component', () => { | ||
test('renders the ResourceCallout component', () => { | ||
render(<ResourceCallout />); | ||
const element = screen.getByTestId('resource-callout'); | ||
expect(element).toBeInTheDocument(); | ||
import ResourceCallout from './ResourceCallout'; // Adjust the import path as needed | ||
|
||
const mockData = { | ||
title: 'Test Resources', | ||
links: [ | ||
{ title: 'Select a Repository', href: 'https://www.testUrl.com' }, | ||
{ | ||
title: 'Register Your Study', | ||
href: 'https://www.testUrl2.com', | ||
}, | ||
], | ||
}; | ||
|
||
describe('ResourceCallout', () => { | ||
test('renders the ResourceCallout component correctly', () => { | ||
render(<ResourceCallout resourceCalloutData={mockData} />); | ||
const headerElement = screen.getByTestId('resource-callout-header'); | ||
expect(headerElement).toHaveTextContent('Test Resources'); | ||
|
||
const listItems = screen.getAllByRole('listitem'); | ||
expect(listItems.length).toBe(mockData.links.length); | ||
|
||
mockData.links.forEach((linkData) => { | ||
const link = screen.getByText(linkData.title); | ||
expect(link).toBeInTheDocument(); | ||
expect(link).toHaveAttribute('href', linkData.href); | ||
}); | ||
}); | ||
|
||
test('should render an arrow icon for each link', () => { | ||
render(<ResourceCallout resourceCalloutData={mockData} />); | ||
const icons = screen.getAllByTestId('icon-link-arrow'); | ||
expect(icons.length).toBe(mockData.links.length); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters