-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
SectionHeading.spec.tsx
60 lines (51 loc) · 1.42 KB
/
SectionHeading.spec.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import React from 'react';
import { shallow, mount } from 'enzyme';
import SectionHeading from './index';
import SectionHeadingRenderer from './SectionHeadingRenderer';
describe('SectionHeading', () => {
const FakeToolbar = () => <div>Fake toolbar</div>;
test('should forward slot properties to the toolbar', () => {
const actual = shallow(
<SectionHeading
id="section"
slotName="slot"
href="/#section"
slotProps={{ foo: 1, bar: 'baz' }}
depth={2}
>
A Section
</SectionHeading>
);
expect(actual).toMatchSnapshot();
});
test('render a section heading', () => {
const actual = mount(
<SectionHeadingRenderer id="section" href="/section" depth={2} toolbar={<FakeToolbar />}>
A Section
</SectionHeadingRenderer>
);
expect(actual.find('h2')).toMatchSnapshot();
});
test('render a deprecated section heading', () => {
const actual = mount(
<SectionHeadingRenderer
id="section"
href="/section"
depth={2}
toolbar={<FakeToolbar />}
deprecated
>
A Section
</SectionHeadingRenderer>
);
expect(actual.find('h2')).toMatchSnapshot();
});
test('prevent the heading level from exceeding the maximum allowed by the Heading component', () => {
const actual = mount(
<SectionHeadingRenderer id="section" href="/section" depth={7} toolbar={<FakeToolbar />}>
A Section
</SectionHeadingRenderer>
);
expect(actual.find('h6')).toHaveLength(1);
});
});