-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: HTML Validation issues with GitHub Rate Limit Banner (#3538)
- Loading branch information
1 parent
f399f75
commit b2a584b
Showing
2 changed files
with
61 additions
and
16 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
src/shared/GlobalBanners/GitHubRateLimitExceeded/GitHubRateLimitExceededBanner.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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { render, screen } from '@testing-library/react' | ||
import { MemoryRouter, Route } from 'react-router' | ||
|
||
import GitHubRateLimitExceededBanner from './GitHubRateLimitExceededBanner' | ||
|
||
const wrapper = | ||
(initialEntry = '/gh'): React.FC<React.PropsWithChildren> => | ||
({ children }) => ( | ||
<MemoryRouter initialEntries={[initialEntry]}> | ||
<Route path="/:provider">{children}</Route> | ||
</MemoryRouter> | ||
) | ||
|
||
describe('GitHubRateLimitExceededBanner', () => { | ||
describe('provider is GH', () => { | ||
it('renders the banner', () => { | ||
render(<GitHubRateLimitExceededBanner />, { | ||
wrapper: wrapper('/gh'), | ||
}) | ||
|
||
const title = screen.getByText('Rate limit exceeded') | ||
expect(title).toBeInTheDocument() | ||
|
||
const description = screen.getByText(/Unable to calculate/) | ||
expect(description).toBeInTheDocument() | ||
|
||
const link = screen.getByRole('link', { name: 'Github documentation.' }) | ||
expect(link).toBeInTheDocument() | ||
expect(link).toHaveAttribute( | ||
'href', | ||
'https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api' | ||
) | ||
}) | ||
}) | ||
|
||
describe('provider is not GH', () => { | ||
it('does not render', () => { | ||
const { container } = render(<GitHubRateLimitExceededBanner />, { | ||
wrapper: wrapper('/bb'), | ||
}) | ||
|
||
expect(container).toBeEmptyDOMElement() | ||
}) | ||
}) | ||
}) |
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