Skip to content

Commit

Permalink
adds test for heading visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
bmuenzenmeyer committed Jan 3, 2025
1 parent ac3ba6d commit 7a0f542
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions apps/site/components/Containers/MetaBar/__tests__/index.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { render } from '@testing-library/react';

import MetaBar from '..';

describe('MetaBar', () => {
it('does not render h5s in the table of contents', () => {
const { queryByText, getByText } = render(
<MetaBar
items={{}}
headings={{
items: [
{
value: 'Heading Level 1',
depth: 1,
data: { id: 'heading-1' },
},
{
value: 'Heading Level 2',
depth: 2,
data: { id: 'heading-2' },
},
{
value: 'Heading Level 3',
depth: 3,
data: { id: 'heading-3' },
},
{
value: 'Heading Level 4',
depth: 4,
data: { id: 'heading-4' },
},
{
value: 'Heading Level 5',
depth: 5,
data: { id: 'heading-5' },
},
{
value: 'Heading Level 6',
depth: 6,
data: { id: 'heading-6' },
},
],
}}
/>
);

const h1Element = queryByText('Heading Level 1');
expect(h1Element).not.toBeInTheDocument();

getByText('Heading Level 2');
getByText('Heading Level 3');
getByText('Heading Level 4');

const h5Element = queryByText('Heading Level 5');
expect(h5Element).not.toBeInTheDocument();

const h6Element = queryByText('Heading Level 6');
expect(h6Element).not.toBeInTheDocument();
});
});

0 comments on commit 7a0f542

Please sign in to comment.