Skip to content

Commit 7a0f542

Browse files
committed
adds test for heading visibility
1 parent ac3ba6d commit 7a0f542

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import { render } from '@testing-library/react';
2+
3+
import MetaBar from '..';
4+
5+
describe('MetaBar', () => {
6+
it('does not render h5s in the table of contents', () => {
7+
const { queryByText, getByText } = render(
8+
<MetaBar
9+
items={{}}
10+
headings={{
11+
items: [
12+
{
13+
value: 'Heading Level 1',
14+
depth: 1,
15+
data: { id: 'heading-1' },
16+
},
17+
{
18+
value: 'Heading Level 2',
19+
depth: 2,
20+
data: { id: 'heading-2' },
21+
},
22+
{
23+
value: 'Heading Level 3',
24+
depth: 3,
25+
data: { id: 'heading-3' },
26+
},
27+
{
28+
value: 'Heading Level 4',
29+
depth: 4,
30+
data: { id: 'heading-4' },
31+
},
32+
{
33+
value: 'Heading Level 5',
34+
depth: 5,
35+
data: { id: 'heading-5' },
36+
},
37+
{
38+
value: 'Heading Level 6',
39+
depth: 6,
40+
data: { id: 'heading-6' },
41+
},
42+
],
43+
}}
44+
/>
45+
);
46+
47+
const h1Element = queryByText('Heading Level 1');
48+
expect(h1Element).not.toBeInTheDocument();
49+
50+
getByText('Heading Level 2');
51+
getByText('Heading Level 3');
52+
getByText('Heading Level 4');
53+
54+
const h5Element = queryByText('Heading Level 5');
55+
expect(h5Element).not.toBeInTheDocument();
56+
57+
const h6Element = queryByText('Heading Level 6');
58+
expect(h6Element).not.toBeInTheDocument();
59+
});
60+
});

0 commit comments

Comments
 (0)