@patternfly/react-core 4.202.15 → 4.202.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/package.json +5 -5
  3. package/src/components/ContextSelector/examples/ContextSelector.md +3 -279
  4. package/src/components/ContextSelector/examples/ContextSelectorBasic.tsx +84 -0
  5. package/src/components/ContextSelector/examples/ContextSelectorPlainText.tsx +85 -0
  6. package/src/components/ContextSelector/examples/ContextSelectorWithFooter.tsx +91 -0
  7. package/src/components/Divider/examples/Divider.md +15 -68
  8. package/src/components/Divider/examples/DividerInsetMedium.tsx +4 -0
  9. package/src/components/Divider/examples/DividerInsetVariousBreakpoints.tsx +13 -0
  10. package/src/components/Divider/examples/DividerUsingDiv.tsx +4 -0
  11. package/src/components/Divider/examples/DividerUsingHr.tsx +4 -0
  12. package/src/components/Divider/examples/DividerUsingLi.tsx +10 -0
  13. package/src/components/Divider/examples/DividerVerticalFlex.tsx +10 -0
  14. package/src/components/Divider/examples/DividerVerticalFlexInsetMedium.tsx +10 -0
  15. package/src/components/Divider/examples/DividerVerticalFlexInsetVariousBreakpoints.tsx +18 -0
  16. package/src/components/FormSelect/__tests__/FormSelect.test.tsx +0 -1
  17. package/src/components/List/__tests__/List.test.tsx +33 -33
  18. package/src/components/List/__tests__/__snapshots__/List.test.tsx.snap +33 -64
  19. package/src/components/Menu/__tests__/Menu.test.tsx +37 -33
  20. package/src/components/Menu/__tests__/__snapshots__/Menu.test.tsx.snap +3 -36
  21. package/src/components/Modal/__tests__/Modal.test.tsx +65 -67
  22. package/src/components/Modal/__tests__/ModalBoxCloseButton.test.tsx +13 -10
  23. package/src/components/Nav/__tests__/Nav.test.tsx +185 -214
  24. package/src/components/Nav/__tests__/__snapshots__/Nav.test.tsx.snap +877 -1729
  25. package/src/components/NotificationDrawer/__tests__/NotificationDrawer.test.tsx +13 -15
  26. package/src/components/NotificationDrawer/__tests__/NotificationDrawerBody.test.tsx +13 -15
  27. package/src/components/NotificationDrawer/__tests__/NotificationDrawerGroup.test.tsx +21 -27
  28. package/src/components/NotificationDrawer/__tests__/NotificationDrawerGroupList.test.tsx +13 -15
  29. package/src/components/NotificationDrawer/__tests__/NotificationDrawerHeader.test.tsx +25 -27
  30. package/src/components/NotificationDrawer/__tests__/NotificationDrawerList.test.tsx +17 -19
  31. package/src/components/NotificationDrawer/__tests__/NotificationDrawerListItem.test.tsx +20 -27
  32. package/src/components/NotificationDrawer/__tests__/NotificationDrawerListItemBody.test.tsx +17 -13
  33. package/src/components/NotificationDrawer/__tests__/NotificationDrawerListItemHeader.test.tsx +30 -25
  34. package/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawer.test.tsx.snap +3 -5
  35. package/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerBody.test.tsx.snap +3 -5
  36. package/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerGroup.test.tsx.snap +9 -11
  37. package/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerGroupList.test.tsx.snap +3 -5
  38. package/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerHeader.test.tsx.snap +16 -18
  39. package/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerList.test.tsx.snap +7 -8
  40. package/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerListItem.test.tsx.snap +3 -5
  41. package/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerListItemBody.test.tsx.snap +6 -8
  42. package/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerListItemHeader.test.tsx.snap +12 -14
  43. package/src/components/OverflowMenu/__tests__/OverflowMenu.test.tsx +15 -12
  44. package/src/components/OverflowMenu/__tests__/OverflowMenuControl.test.tsx +9 -8
  45. package/src/components/OverflowMenu/__tests__/OverflowMenuGroup.test.tsx +17 -18
  46. package/src/components/OverflowMenu/__tests__/OverflowMenuItem.test.tsx +10 -9
  47. package/src/components/OverflowMenu/__tests__/__snapshots__/OverflowMenu.test.tsx.snap +6 -16
  48. package/src/components/OverflowMenu/__tests__/__snapshots__/OverflowMenuControl.test.tsx.snap +3 -15
  49. package/src/components/OverflowMenu/__tests__/__snapshots__/OverflowMenuItem.test.tsx.snap +3 -17
  50. package/src/components/Modal/__tests__/__snapshots__/ModalBoxCloseButton.test.tsx.snap +0 -16
  51. package/src/components/OverflowMenu/__tests__/__snapshots__/OverflowMenuGroup.test.tsx.snap +0 -33
@@ -1,6 +1,9 @@
1
1
  import * as React from 'react';
2
- import { shallow, mount } from 'enzyme';
3
- import { KEY_CODES } from '../../../helpers/constants';
2
+
3
+ import { render, screen } from '@testing-library/react';
4
+ import userEvent from '@testing-library/user-event';
5
+ import '@testing-library/jest-dom';
6
+
4
7
  import { css } from '../../../../../react-styles/dist/js';
5
8
  import styles from '@patternfly/react-styles/css/components/Backdrop/backdrop';
6
9
 
@@ -16,76 +19,71 @@ const props = {
16
19
  children: 'modal content'
17
20
  };
18
21
 
19
- test('Modal creates a container element once for div', () => {
20
- const view = shallow(<Modal {...props} />);
21
- view.update();
22
- expect(document.createElement).toBeCalledWith('div');
23
- expect(document.createElement).toHaveBeenCalledTimes(1);
24
- });
22
+ describe('Modal', () => {
23
+ test('Modal creates a container element once for div', () => {
24
+ render(<Modal {...props} />);
25
+ expect(document.createElement).toBeCalledWith('div');
26
+ });
25
27
 
26
- test('modal closes with escape', () => {
27
- shallow(<Modal {...props} isOpen appendTo={document.body} />);
28
- const mock: any = (document.body.addEventListener as any).mock;
29
- const [event, handler] = mock.calls[0];
30
- expect(event).toBe('keydown');
31
- handler({ keyCode: KEY_CODES.ESCAPE_KEY });
32
- expect(props.onClose).toBeCalled();
33
- });
28
+ test('modal closes with escape', () => {
29
+ render(<Modal {...props} isOpen appendTo={document.body} />);
34
30
 
35
- test('modal does not call onClose for esc key if it is not open', () => {
36
- shallow(<Modal {...props} />);
37
- const mock: any = (document.body.addEventListener as any).mock;
38
- const [event, handler] = mock.calls[0];
39
- expect(event).toBe('keydown');
40
- handler({ keyCode: KEY_CODES.ESCAPE_KEY });
41
- expect(props.onClose).not.toBeCalled();
42
- });
31
+ userEvent.type(screen.getByText(props.title), '{esc}');
32
+ expect(props.onClose).toBeCalled();
33
+ });
43
34
 
44
- test('Each modal is given a new id', () => {
45
- const first = shallow(<Modal {...props} />);
46
- const second = shallow(<Modal {...props} />);
47
- expect((first.instance() as any).descriptorId).not.toBe((second.instance() as any).descriptorId);
48
- });
35
+ test('modal does not call onClose for esc key if it is not open', () => {
36
+ render(<Modal {...props} />);
37
+ expect(screen.queryByRole('dialog')).toBeNull();
38
+ expect(props.onClose).not.toBeCalled();
39
+ });
49
40
 
50
- test('modal removes body backdropOpen class when removed', () => {
51
- const view = shallow(<Modal {...props} isOpen />);
52
- view.update();
53
- expect(document.body.className).toContain(css(styles.backdropOpen));
54
- view.setProps({ isOpen: false });
55
- view.update();
56
- expect(document.body.className).not.toContain(css(styles.backdropOpen));
57
- });
41
+ test('modal has body backdropOpen class when open', () => {
42
+ render(<Modal {...props} isOpen />);
43
+ expect(document.body).toHaveClass(css(styles.backdropOpen));
44
+ });
58
45
 
59
- test('modal shows/hides the close button based on showClose (default true)', () => {
60
- const view = mount(<Modal {...props} isOpen />);
61
- view.update();
62
- expect(view.exists('.pf-c-modal-box .pf-c-button')).toBeTruthy();
63
- view.setProps({ showClose: false });
64
- view.update();
65
- expect(view.exists('.pf-c-modal-box .pf-c-button')).toBeFalsy();
66
- });
46
+ test('modal has no body backdropOpen class when not open', () => {
47
+ render(<Modal {...props} />);
48
+ expect(document.body).not.toHaveClass(css(styles.backdropOpen));
49
+ });
67
50
 
68
- test('modal generates console error when no accessible name is provided', () => {
69
- const props = {
70
- onClose: jest.fn(),
71
- isOpen: true,
72
- children: 'modal content'
73
- };
74
- const consoleErrorMock = jest.fn();
75
- global.console = { error: consoleErrorMock } as any;
76
- shallow(<Modal {...props} />);
77
- expect(consoleErrorMock).toBeCalled();
78
- });
51
+ test('modal shows the close button when showClose is true (true by default)', () => {
52
+ render(<Modal {...props} isOpen />);
53
+ expect(screen.getByRole('button', { name: 'Close' })).toBeInTheDocument();
54
+ });
55
+
56
+ test('modal does not show the close button when showClose is false', () => {
57
+ render(<Modal {...props} isOpen showClose={false} tabIndex={0} />);
58
+ expect(screen.queryByRole('button', { name: 'Close' })).toBeNull();
59
+ });
60
+
61
+ test('modal generates console error when no accessible name is provided', () => {
62
+ const props = {
63
+ onClose: jest.fn(),
64
+ isOpen: true,
65
+ children: 'modal content'
66
+ };
67
+ const consoleErrorMock = jest.fn();
68
+ global.console = { error: consoleErrorMock } as any;
69
+
70
+ render(<Modal {...props} />);
71
+
72
+ expect(consoleErrorMock).toBeCalled();
73
+ });
74
+
75
+ test('modal generates console warning when conflicting accessible name strategies are provided', () => {
76
+ const props = {
77
+ hasNoBodyWrapper: true,
78
+ onClose: jest.fn(),
79
+ isOpen: true,
80
+ children: 'modal content'
81
+ };
82
+ const consoleErrorMock = jest.fn();
83
+ global.console = { error: consoleErrorMock } as any;
84
+
85
+ render(<Modal {...props} />);
79
86
 
80
- test('modal generates console warning when conflicting accessible name strategies are provided', () => {
81
- const props = {
82
- hasNoBodyWrapper: true,
83
- onClose: jest.fn(),
84
- isOpen: true,
85
- children: 'modal content'
86
- };
87
- const consoleErrorMock = jest.fn();
88
- global.console = { error: consoleErrorMock } as any;
89
- shallow(<Modal {...props} />);
90
- expect(consoleErrorMock).toBeCalled();
87
+ expect(consoleErrorMock).toBeCalled();
88
+ });
91
89
  });
@@ -1,14 +1,17 @@
1
1
  import * as React from 'react';
2
- import { shallow } from 'enzyme';
2
+
3
+ import { render, screen } from '@testing-library/react';
4
+ import userEvent from '@testing-library/user-event';
5
+
3
6
  import { ModalBoxCloseButton } from '../ModalBoxCloseButton';
4
7
 
5
- test('ModalBoxCloseButton Test', () => {
6
- const mockfn = jest.fn();
7
- const view = shallow(<ModalBoxCloseButton className="test-box-close-button-class" onClose={mockfn} />);
8
- expect(view).toMatchSnapshot();
9
- view
10
- .find('.test-box-close-button-class')
11
- .at(0)
12
- .simulate('click');
13
- expect(mockfn.mock.calls).toHaveLength(1);
8
+ describe('ModalBoxCloseButton', () => {
9
+ test('onClose called when clicked', () => {
10
+ const onClose = jest.fn();
11
+
12
+ render(<ModalBoxCloseButton className="test-box-close-button-class" onClose={onClose} />);
13
+
14
+ userEvent.click(screen.getByRole('button'));
15
+ expect(onClose).toHaveBeenCalledTimes(1);
16
+ });
14
17
  });
@@ -1,6 +1,9 @@
1
1
  import * as React from 'react';
2
- import { mount } from 'enzyme';
3
- import { Nav } from '../Nav';
2
+
3
+ import { render, screen } from '@testing-library/react';
4
+ import userEvent from '@testing-library/user-event';
5
+
6
+ import { Nav, NavContext } from '../Nav';
4
7
  import { NavList } from '../NavList';
5
8
  import { NavGroup } from '../NavGroup';
6
9
  import { NavItem } from '../NavItem';
@@ -15,250 +18,218 @@ const props = {
15
18
  ]
16
19
  };
17
20
 
18
- // eslint-disable-next-line no-undef
19
- beforeEach(() => {
20
- window.location.hash = '#link1';
21
- });
22
-
23
- const context = {
24
- onSelect: () => undefined as any,
25
- onToggle: () => undefined as any
26
- };
27
-
28
- test('Default Nav List', () => {
29
- const view = mount(
30
- <Nav className="test=nav-class">
31
- <NavList className="test-nav-list-class">
32
- {props.items.map(item => (
33
- <NavItem to={item.to} key={item.to} className="test-nav-item-class">
34
- {item.label}
35
- </NavItem>
36
- ))}
37
- </NavList>
38
- </Nav>,
39
- { context }
40
- );
41
- expect(view).toMatchSnapshot();
42
- });
43
-
44
- test('Dark Nav List', () => {
45
- const view = mount(
46
- <Nav className="test=nav-class" theme="dark">
47
- <NavList className="test-nav-list-class">
48
- {props.items.map(item => (
49
- <NavItem to={item.to} key={item.to} className="test-nav-item-class">
50
- {item.label}
51
- </NavItem>
52
- ))}
53
- </NavList>
54
- </Nav>,
55
- { context }
56
- );
57
- expect(view).toMatchSnapshot();
58
- });
59
-
60
- test('Default Nav List - Trigger item active update', () => {
61
- window.location.hash = '#link2';
62
- const view = mount(
63
- <Nav>
64
- <NavList>
65
- {props.items.map(item => (
66
- <NavItem to={item.to} key={item.to}>
67
- {item.label}
68
- </NavItem>
69
- ))}
70
- </NavList>
71
- </Nav>,
72
- { context }
73
- );
74
- view
75
- .find({ href: '#link2' })
76
- .first()
77
- .simulate('click');
78
- expect(view).toMatchSnapshot();
79
- });
21
+ const renderNav = (ui: React.ReactElement<any, string | React.JSXElementConstructor<any>>) =>
22
+ render(<NavContext.Provider value={{ onSelect: jest.fn(), onToggle: jest.fn() }}>{ui}</NavContext.Provider>);
80
23
 
81
- test('Simple Nav List', () => {
82
- const view = mount(
83
- <Nav>
84
- <NavList>
85
- {props.items.map(item => (
86
- <NavItem to={item.to} key={item.to}>
87
- {item.label}
88
- </NavItem>
89
- ))}
90
- </NavList>
91
- </Nav>,
92
- { context }
93
- );
94
- expect(view).toMatchSnapshot();
95
- });
24
+ describe('Nav', () => {
25
+ beforeEach(() => {
26
+ window.location.hash = '#link1';
27
+ });
96
28
 
97
- test('Expandable Nav List', () => {
98
- const view = mount(
99
- <Nav>
100
- <NavList>
101
- <NavExpandable id="grp-1" title="Section 1">
29
+ test('Default Nav List', () => {
30
+ const { asFragment } = renderNav(
31
+ <Nav className="test-nav-class">
32
+ <NavList className="test-nav-list-class">
102
33
  {props.items.map(item => (
103
- <NavItem to={item.to} key={item.to}>
34
+ <NavItem to={item.to} key={item.to} className="test-nav-item-class">
104
35
  {item.label}
105
36
  </NavItem>
106
37
  ))}
107
- </NavExpandable>
108
- </NavList>
109
- </Nav>,
110
- { context }
111
- );
112
- expect(view).toMatchSnapshot();
113
- });
114
-
115
- test('Expandable Nav verify onExpand', () => {
116
- const onExpandSpy = jest.fn();
117
- const view = mount(
118
- <Nav>
119
- <NavList>
120
- <NavExpandable id="grp-1" title="Section 1" onExpand={onExpandSpy}>
38
+ </NavList>
39
+ </Nav>
40
+ );
41
+ expect(asFragment()).toMatchSnapshot();
42
+ });
43
+
44
+ test('Dark Nav List', () => {
45
+ const { asFragment } = renderNav(
46
+ <Nav className="test=nav-class" theme="dark">
47
+ <NavList className="test-nav-list-class">
121
48
  {props.items.map(item => (
122
- <NavItem to={item.to} key={item.to}>
49
+ <NavItem to={item.to} key={item.to} className="test-nav-item-class">
123
50
  {item.label}
124
51
  </NavItem>
125
52
  ))}
126
- </NavExpandable>
127
- </NavList>
128
- </Nav>,
129
- { context }
130
- );
131
- const btn = view.find('button');
132
- btn.simulate('click');
133
- expect(onExpandSpy).toBeCalled();
134
- });
135
-
136
- test('Expandable Nav List - Trigger toggle', () => {
137
- window.location.hash = '#link2';
138
- const view = mount(
139
- <Nav>
140
- <NavList>
141
- <NavExpandable id="grp-1" title="Section 1" className="expandable-group" isExpanded>
53
+ </NavList>
54
+ </Nav>
55
+ );
56
+ expect(asFragment()).toMatchSnapshot();
57
+ });
58
+
59
+ test('Default Nav List - Trigger item active update', () => {
60
+ const { asFragment } = renderNav(
61
+ <Nav>
62
+ <NavList>
142
63
  {props.items.map(item => (
143
64
  <NavItem to={item.to} key={item.to}>
144
65
  {item.label}
145
66
  </NavItem>
146
67
  ))}
147
- </NavExpandable>
148
- </NavList>
149
- </Nav>,
150
- { context }
151
- );
152
- view
153
- .find('li.expandable-group')
154
- .first()
155
- .simulate('click');
156
- expect(view).toMatchSnapshot();
157
- });
68
+ </NavList>
69
+ </Nav>
70
+ );
71
+
72
+ userEvent.click(screen.getByText('Link 2'));
73
+ expect(asFragment()).toMatchSnapshot();
74
+ });
75
+
76
+ test('Expandable Nav List', () => {
77
+ const { asFragment } = renderNav(
78
+ <Nav>
79
+ <NavList>
80
+ <NavExpandable id="grp-1" title="Section 1">
81
+ {props.items.map(item => (
82
+ <NavItem to={item.to} key={item.to}>
83
+ {item.label}
84
+ </NavItem>
85
+ ))}
86
+ </NavExpandable>
87
+ </NavList>
88
+ </Nav>
89
+ );
90
+ expect(asFragment()).toMatchSnapshot();
91
+ });
158
92
 
159
- test('Expandable Nav List with aria label', () => {
160
- const view = mount(
161
- <Nav aria-label="Test">
162
- <NavList>
163
- <NavExpandable id="grp-1" title="Section 1" srText="Section 1 - Example sub-navigation">
93
+ test('Expandable Nav verify onExpand', () => {
94
+ const onExpand = jest.fn();
95
+
96
+ renderNav(
97
+ <Nav>
98
+ <NavList>
99
+ <NavExpandable id="grp-1" title="Section 1" onExpand={onExpand}>
100
+ {props.items.map(item => (
101
+ <NavItem to={item.to} key={item.to}>
102
+ {item.label}
103
+ </NavItem>
104
+ ))}
105
+ </NavExpandable>
106
+ </NavList>
107
+ </Nav>
108
+ );
109
+
110
+ userEvent.click(screen.getByRole('button'));
111
+ expect(onExpand).toBeCalled();
112
+ });
113
+
114
+ test('Expandable Nav List - Trigger toggle', () => {
115
+ window.location.hash = '#link2';
116
+
117
+ const { asFragment } = renderNav(
118
+ <Nav>
119
+ <NavList>
120
+ <NavExpandable id="grp-1" title="Section 1" className="expandable-group" isExpanded>
121
+ {props.items.map(item => (
122
+ <NavItem to={item.to} key={item.to}>
123
+ {item.label}
124
+ </NavItem>
125
+ ))}
126
+ </NavExpandable>
127
+ </NavList>
128
+ </Nav>
129
+ );
130
+
131
+ userEvent.click(screen.getByText('Section 1'));
132
+ expect(asFragment()).toMatchSnapshot();
133
+ });
134
+
135
+ test('Expandable Nav List with aria label', () => {
136
+ const { asFragment } = renderNav(
137
+ <Nav aria-label="Test">
138
+ <NavList>
139
+ <NavExpandable id="grp-1" title="Section 1" srText="Section 1 - Example sub-navigation">
140
+ {props.items.map(item => (
141
+ <NavItem to={item.to} key={item.to}>
142
+ {item.label}
143
+ </NavItem>
144
+ ))}
145
+ </NavExpandable>
146
+ </NavList>
147
+ </Nav>
148
+ );
149
+ expect(asFragment()).toMatchSnapshot();
150
+ });
151
+
152
+ test('Nav Grouped List', () => {
153
+ const { asFragment } = renderNav(
154
+ <Nav>
155
+ <NavGroup id="grp-1" title="Section 1">
156
+ <NavList>
157
+ {props.items.map(item => (
158
+ <NavItem to={item.to} key={`section1_${item.to}`}>
159
+ {item.label}
160
+ </NavItem>
161
+ ))}
162
+ </NavList>
163
+ </NavGroup>
164
+ <NavGroup id="grp-2" title="Section 2">
165
+ <NavList>
166
+ {props.items.map(item => (
167
+ <NavItem to={item.to} key={`section2_${item.to}`}>
168
+ {item.label}
169
+ </NavItem>
170
+ ))}
171
+ </NavList>
172
+ </NavGroup>
173
+ </Nav>
174
+ );
175
+ expect(asFragment()).toMatchSnapshot();
176
+ });
177
+
178
+ test('Horizontal Nav List', () => {
179
+ const { asFragment } = renderNav(
180
+ <Nav variant="horizontal">
181
+ <NavList>
164
182
  {props.items.map(item => (
165
183
  <NavItem to={item.to} key={item.to}>
166
184
  {item.label}
167
185
  </NavItem>
168
186
  ))}
169
- </NavExpandable>
170
- </NavList>
171
- </Nav>,
172
- { context }
173
- );
174
- expect(view).toMatchSnapshot();
175
- });
176
-
177
- test('Nav Grouped List', () => {
178
- const view = mount(
179
- <Nav>
180
- <NavGroup id="grp-1" title="Section 1">
187
+ </NavList>
188
+ </Nav>
189
+ );
190
+ expect(asFragment()).toMatchSnapshot();
191
+ });
192
+
193
+ test('Horizontal SubNav List', () => {
194
+ const { asFragment } = renderNav(
195
+ <Nav variant="horizontal-subnav">
181
196
  <NavList>
182
197
  {props.items.map(item => (
183
- <NavItem to={item.to} key={`section1_${item.to}`}>
198
+ <NavItem to={item.to} key={item.to}>
184
199
  {item.label}
185
200
  </NavItem>
186
201
  ))}
187
202
  </NavList>
188
- </NavGroup>
189
- <NavGroup id="grp-2" title="Section 2">
203
+ </Nav>
204
+ );
205
+ expect(asFragment()).toMatchSnapshot();
206
+ });
207
+
208
+ test('Tertiary Nav List', () => {
209
+ const { asFragment } = renderNav(
210
+ <Nav variant="tertiary">
190
211
  <NavList>
191
212
  {props.items.map(item => (
192
- <NavItem to={item.to} key={`section2_${item.to}`}>
213
+ <NavItem to={item.to} key={item.to}>
193
214
  {item.label}
194
215
  </NavItem>
195
216
  ))}
196
217
  </NavList>
197
- </NavGroup>
198
- </Nav>,
199
- { context }
200
- );
201
- expect(view).toMatchSnapshot();
202
- });
203
-
204
- test('Horizontal Nav List', () => {
205
- const view = mount(
206
- <Nav variant="horizontal">
207
- <NavList>
208
- {props.items.map(item => (
209
- <NavItem to={item.to} key={item.to}>
210
- {item.label}
211
- </NavItem>
212
- ))}
213
- </NavList>
214
- </Nav>,
215
- { context }
216
- );
217
- expect(view).toMatchSnapshot();
218
- });
219
-
220
- test('Horizontal SubNav List', () => {
221
- const view = mount(
222
- <Nav variant="horizontal-subnav">
223
- <NavList>
224
- {props.items.map(item => (
225
- <NavItem to={item.to} key={item.to}>
226
- {item.label}
227
- </NavItem>
228
- ))}
229
- </NavList>
230
- </Nav>,
231
- { context }
232
- );
233
- expect(view).toMatchSnapshot();
234
- });
235
-
236
- test('Tertiary Nav List', () => {
237
- const view = mount(
238
- <Nav variant="tertiary">
239
- <NavList>
240
- {props.items.map(item => (
241
- <NavItem to={item.to} key={item.to}>
242
- {item.label}
218
+ </Nav>
219
+ );
220
+ expect(asFragment()).toMatchSnapshot();
221
+ });
222
+
223
+ test('Nav List with custom item nodes', () => {
224
+ const { asFragment } = renderNav(
225
+ <Nav variant="tertiary">
226
+ <NavList>
227
+ <NavItem to="/components/nav#link1" className="test-nav-item-class">
228
+ <div className="my-custom-node">My custom node</div>
243
229
  </NavItem>
244
- ))}
245
- </NavList>
246
- </Nav>,
247
- { context }
248
- );
249
- expect(view).toMatchSnapshot();
250
- });
251
-
252
- test('Nav List with custom item nodes', () => {
253
- const view = mount(
254
- <Nav variant="tertiary">
255
- <NavList>
256
- <NavItem to="/components/nav#link1" className="test-nav-item-class">
257
- <div className="my-custom-node">My custom node</div>
258
- </NavItem>
259
- </NavList>
260
- </Nav>,
261
- { context }
262
- );
263
- expect(view).toMatchSnapshot();
230
+ </NavList>
231
+ </Nav>
232
+ );
233
+ expect(asFragment()).toMatchSnapshot();
234
+ });
264
235
  });