diff --git a/src/shared/GlobalBanners/GitHubRateLimitExceeded/GitHubRateLimitExceededBanner.test.tsx b/src/shared/GlobalBanners/GitHubRateLimitExceeded/GitHubRateLimitExceededBanner.test.tsx new file mode 100644 index 0000000000..e3f30e2f9e --- /dev/null +++ b/src/shared/GlobalBanners/GitHubRateLimitExceeded/GitHubRateLimitExceededBanner.test.tsx @@ -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 => + ({ children }) => ( + + {children} + + ) + +describe('GitHubRateLimitExceededBanner', () => { + describe('provider is GH', () => { + it('renders the banner', () => { + render(, { + 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(, { + wrapper: wrapper('/bb'), + }) + + expect(container).toBeEmptyDOMElement() + }) + }) +})