47 lines
2.0 KiB
TypeScript
47 lines
2.0 KiB
TypeScript
/**
|
|||
|
|
* The footer is the only navigational route to /about and /blog, so it is
|
||
|
|
* where a dark flag would otherwise leave a link into a 404.
|
||
|
|
*
|
||
|
|
* Both props default to false. A caller that forgets to pass them hides the
|
||
|
|
* links, which is the direction that cannot break a page — the same reasoning
|
||
|
|
* as backend/flags.py's "every flag defaults to False".
|
||
|
|
*/
|
||
|
|
import { render, screen } from '@testing-library/react';
|
||
|
|
import { Footer } from '@/components/Footer';
|
||
|
|
|
||
|
|
describe('footer feature links', () => {
|
||
|
|
it('links to both when both flags are on', () => {
|
||
|
|
render(<Footer aboutEnabled blogEnabled />);
|
||
|
|
expect(screen.getByRole('link', { name: /who's behind this/i }))
|
||
|
|
.toHaveAttribute('href', '/about');
|
||
|
|
expect(screen.getByRole('link', { name: /^blog$/i }))
|
||
|
|
.toHaveAttribute('href', '/blog');
|
||
|
|
});
|
||
|
|
|
||
|
|
it('omits the about link when that flag is dark', () => {
|
||
|
|
render(<Footer blogEnabled />);
|
||
|
|
expect(screen.queryByRole('link', { name: /who's behind this/i })).toBeNull();
|
||
|
|
expect(screen.getByRole('link', { name: /^blog$/i })).toBeInTheDocument();
|
||
|
|
});
|
||
|
|
|
||
|
|
it('omits the blog link when that flag is dark', () => {
|
||
|
|
render(<Footer aboutEnabled />);
|
||
|
|
expect(screen.queryByRole('link', { name: /^blog$/i })).toBeNull();
|
||
|
|
expect(screen.getByRole('link', { name: /who's behind this/i }))
|
||
|
|
.toBeInTheDocument();
|
||
|
|
});
|
||
|
|
|
||
|
|
it('drops the whole section when both are dark, not an empty heading', () => {
|
||
|
|
// Shipping dark means the footer renders as it did before the feature
|
||
|
|
// existed, not as a section with its contents removed.
|
||
|
|
render(<Footer />);
|
||
|
|
expect(screen.queryByRole('heading', { name: /^about$/i })).toBeNull();
|
||
|
|
expect(screen.queryByRole('link', { name: /who's behind this/i })).toBeNull();
|
||
|
|
expect(screen.queryByRole('link', { name: /^blog$/i })).toBeNull();
|
||
|
|
});
|
||
|
|
|
||
|
|
it('defaults to dark when a caller passes nothing', () => {
|
||
|
|
render(<Footer />);
|
||
|
|
expect(screen.queryByRole('link', { name: /who's behind this/i })).toBeNull();
|
||
|
|
});
|
||
|
|
});
|