box-ui-elements 23.4.0-beta.18 → 23.4.0-beta.19
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.
- package/dist/explorer.css +1 -1
- package/dist/explorer.js +1 -1
- package/dist/preview.css +1 -1
- package/dist/preview.js +1 -1
- package/dist/sidebar.css +1 -1
- package/dist/sidebar.js +1 -1
- package/es/elements/common/back-button/BackButton.js.map +1 -0
- package/es/elements/common/back-button/index.js +3 -0
- package/es/elements/common/{nav-button → back-button}/index.js.flow +1 -1
- package/es/elements/common/back-button/index.js.map +1 -0
- package/es/elements/content-sidebar/SidebarNavButton.js +29 -22
- package/es/elements/content-sidebar/SidebarNavButton.js.flow +28 -21
- package/es/elements/content-sidebar/SidebarNavButton.js.map +1 -1
- package/es/elements/content-sidebar/SidebarNavButton.scss +13 -0
- package/es/elements/content-sidebar/versions/StaticVersionSidebar.js +1 -1
- package/es/elements/content-sidebar/versions/StaticVersionSidebar.js.flow +1 -1
- package/es/elements/content-sidebar/versions/StaticVersionSidebar.js.map +1 -1
- package/es/elements/content-sidebar/versions/VersionsSidebar.js +1 -1
- package/es/elements/content-sidebar/versions/VersionsSidebar.js.flow +1 -1
- package/es/elements/content-sidebar/versions/VersionsSidebar.js.map +1 -1
- package/package.json +1 -1
- package/src/elements/common/{nav-button → back-button}/__tests__/BackButton.test.js +1 -1
- package/src/elements/common/{nav-button → back-button}/index.js +1 -1
- package/src/elements/content-sidebar/SidebarNavButton.js +28 -21
- package/src/elements/content-sidebar/SidebarNavButton.scss +13 -0
- package/src/elements/content-sidebar/__tests__/SidebarNavButton.test.js +208 -26
- package/src/elements/content-sidebar/versions/StaticVersionSidebar.js +1 -1
- package/src/elements/content-sidebar/versions/VersionsSidebar.js +1 -1
- package/src/elements/content-sidebar/versions/__tests__/StaticVersionSidebar.test.js +5 -7
- package/src/elements/content-sidebar/versions/__tests__/VersionsSidebar.test.js +5 -7
- package/es/elements/common/nav-button/BackButton.js.map +0 -1
- package/es/elements/common/nav-button/NavButton.js +0 -63
- package/es/elements/common/nav-button/NavButton.js.flow +0 -80
- package/es/elements/common/nav-button/NavButton.js.map +0 -1
- package/es/elements/common/nav-button/index.js +0 -3
- package/es/elements/common/nav-button/index.js.map +0 -1
- package/src/elements/common/nav-button/NavButton.js +0 -80
- package/src/elements/common/nav-button/__tests__/NavButton.test.js +0 -265
- /package/es/elements/common/{nav-button → back-button}/BackButton.js +0 -0
- /package/es/elements/common/{nav-button → back-button}/BackButton.js.flow +0 -0
- /package/es/elements/common/{nav-button → back-button}/BackButton.scss +0 -0
- /package/src/elements/common/{nav-button → back-button}/BackButton.js +0 -0
- /package/src/elements/common/{nav-button → back-button}/BackButton.scss +0 -0
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { mount, render } from 'enzyme';
|
|
3
|
-
import { MemoryRouter, Router } from 'react-router-dom';
|
|
4
|
-
import { render as rtlRender, screen } from '../../../../test-utils/testing-library';
|
|
5
|
-
import NavButton from '..';
|
|
6
|
-
|
|
7
|
-
describe('elements/common/nav-button/NavButton', () => {
|
|
8
|
-
const getNavButton = (content, { path = '/activity', ...props }) => (
|
|
9
|
-
<MemoryRouter initialEntries={[path]}>
|
|
10
|
-
<NavButton to={path} {...props}>
|
|
11
|
-
{content}
|
|
12
|
-
</NavButton>
|
|
13
|
-
</MemoryRouter>
|
|
14
|
-
);
|
|
15
|
-
|
|
16
|
-
describe('when active', () => {
|
|
17
|
-
test('applies its default activeClassName', () => {
|
|
18
|
-
const button = render(
|
|
19
|
-
<MemoryRouter initialEntries={['/activity']}>
|
|
20
|
-
<NavButton to="/activity">Activity</NavButton>
|
|
21
|
-
</MemoryRouter>,
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
expect(button.hasClass('bdl-is-active')).toBe(true);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
test('applies a custom activeClassName instead of the default', () => {
|
|
28
|
-
const button = render(
|
|
29
|
-
<MemoryRouter initialEntries={['/activity']}>
|
|
30
|
-
<NavButton to="/activity" activeClassName="bdl-is-selected">
|
|
31
|
-
Activity
|
|
32
|
-
</NavButton>
|
|
33
|
-
</MemoryRouter>,
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
expect(button.hasClass('bdl-is-active')).toBe(false);
|
|
37
|
-
expect(button.hasClass('bdl-is-selected')).toBe(true);
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
describe('when inactive', () => {
|
|
42
|
-
test('does not apply its default activeClassName', () => {
|
|
43
|
-
const button = render(
|
|
44
|
-
<MemoryRouter initialEntries={['/activity']}>
|
|
45
|
-
<NavButton to="/details">Details</NavButton>
|
|
46
|
-
</MemoryRouter>,
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
expect(button.hasClass('bdl-is-active')).toBe(false);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
test('does not apply its activeClassName', () => {
|
|
53
|
-
const button = render(
|
|
54
|
-
<MemoryRouter initialEntries={['/activity']}>
|
|
55
|
-
<NavButton to="/details" activeClassName="bdl-is-selected">
|
|
56
|
-
Details
|
|
57
|
-
</NavButton>
|
|
58
|
-
</MemoryRouter>,
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
expect(button.hasClass('bdl-is-active')).toBe(false);
|
|
62
|
-
expect(button.hasClass('bdl-is-selected')).toBe(false);
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
describe('when disabled', () => {
|
|
67
|
-
test('applies bdl-is-disabled class name', () => {
|
|
68
|
-
const content = 'Activity';
|
|
69
|
-
rtlRender(getNavButton(content, { isDisabled: true }));
|
|
70
|
-
|
|
71
|
-
expect(screen.getByText(content, { selector: '.bdl-is-disabled' })).toBeInTheDocument();
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
describe('exact', () => {
|
|
76
|
-
test('does not do exact matching by default', () => {
|
|
77
|
-
const button = render(
|
|
78
|
-
<MemoryRouter initialEntries={['/activity/versions']}>
|
|
79
|
-
<NavButton to="/activity">Activity</NavButton>
|
|
80
|
-
</MemoryRouter>,
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
expect(button.hasClass('bdl-is-active')).toBe(true);
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
test('applies default activeClassName for exact matches', () => {
|
|
87
|
-
const button = render(
|
|
88
|
-
<MemoryRouter initialEntries={['/activity']}>
|
|
89
|
-
<NavButton exact to="/activity">
|
|
90
|
-
Activity
|
|
91
|
-
</NavButton>
|
|
92
|
-
</MemoryRouter>,
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
expect(button.hasClass('bdl-is-active')).toBe(true);
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
test('does not apply default activeClassName for partial matches', () => {
|
|
99
|
-
const button = render(
|
|
100
|
-
<MemoryRouter initialEntries={['/activity/versions']}>
|
|
101
|
-
<NavButton exact to="/activity">
|
|
102
|
-
Activity
|
|
103
|
-
</NavButton>
|
|
104
|
-
</MemoryRouter>,
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
expect(button.hasClass('bdl-is-active')).toBe(false);
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
test('applies custom activeClassName for exact matches', () => {
|
|
111
|
-
const button = render(
|
|
112
|
-
<MemoryRouter initialEntries={['/activity']}>
|
|
113
|
-
<NavButton exact to="/activity" activeClassName="bdl-is-selected">
|
|
114
|
-
Activity
|
|
115
|
-
</NavButton>
|
|
116
|
-
</MemoryRouter>,
|
|
117
|
-
);
|
|
118
|
-
|
|
119
|
-
expect(button.hasClass('bdl-is-selected')).toBe(true);
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
test('applies custom activeClassName for partial matches', () => {
|
|
123
|
-
const button = render(
|
|
124
|
-
<MemoryRouter initialEntries={['/activity/versions']}>
|
|
125
|
-
<NavButton exact to="/activity" activeClassName="bdl-is-selected">
|
|
126
|
-
Activity
|
|
127
|
-
</NavButton>
|
|
128
|
-
</MemoryRouter>,
|
|
129
|
-
);
|
|
130
|
-
|
|
131
|
-
expect(button.hasClass('bdl-is-selected')).toBe(false);
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
describe('isActive', () => {
|
|
136
|
-
test('overrides the default matching behavior and sets the active class name', () => {
|
|
137
|
-
const button = render(
|
|
138
|
-
<MemoryRouter initialEntries={['/activity']}>
|
|
139
|
-
<NavButton isActive={() => true} to="/skills">
|
|
140
|
-
Skills
|
|
141
|
-
</NavButton>
|
|
142
|
-
</MemoryRouter>,
|
|
143
|
-
);
|
|
144
|
-
|
|
145
|
-
expect(button.hasClass('bdl-is-active')).toBe(true);
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
describe('strict', () => {
|
|
150
|
-
test('does not do strict matching by default', () => {
|
|
151
|
-
const button = render(
|
|
152
|
-
<MemoryRouter initialEntries={['/activity']}>
|
|
153
|
-
<NavButton to="/activity/">Activity</NavButton>
|
|
154
|
-
</MemoryRouter>,
|
|
155
|
-
);
|
|
156
|
-
|
|
157
|
-
expect(button.hasClass('bdl-is-active')).toBe(true);
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
test('applies default activeClassName for strict matches', () => {
|
|
161
|
-
const button = render(
|
|
162
|
-
<MemoryRouter initialEntries={['/activity/']}>
|
|
163
|
-
<NavButton strict to="/activity/">
|
|
164
|
-
Activity
|
|
165
|
-
</NavButton>
|
|
166
|
-
</MemoryRouter>,
|
|
167
|
-
);
|
|
168
|
-
|
|
169
|
-
expect(button.hasClass('bdl-is-active')).toBe(true);
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
test('does not apply default activeClassName for non-strict matches', () => {
|
|
173
|
-
const button = render(
|
|
174
|
-
<MemoryRouter initialEntries={['/activity']}>
|
|
175
|
-
<NavButton strict to="/activity/">
|
|
176
|
-
Activity
|
|
177
|
-
</NavButton>
|
|
178
|
-
</MemoryRouter>,
|
|
179
|
-
);
|
|
180
|
-
|
|
181
|
-
expect(button.hasClass('bdl-is-active')).toBe(false);
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
test('applies custom activeClassName for strict matches', () => {
|
|
185
|
-
const button = render(
|
|
186
|
-
<MemoryRouter initialEntries={['/activity/']}>
|
|
187
|
-
<NavButton strict to="/activity/" activeClassName="bdl-is-selected">
|
|
188
|
-
Activity
|
|
189
|
-
</NavButton>
|
|
190
|
-
</MemoryRouter>,
|
|
191
|
-
);
|
|
192
|
-
|
|
193
|
-
expect(button.hasClass('bdl-is-selected')).toBe(true);
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
test('does not apply custom activeClassName for non-strict matches', () => {
|
|
197
|
-
const button = render(
|
|
198
|
-
<MemoryRouter initialEntries={['/activity']}>
|
|
199
|
-
<NavButton strict to="/activity/" activeClassName="bdl-is-selected">
|
|
200
|
-
Activity
|
|
201
|
-
</NavButton>
|
|
202
|
-
</MemoryRouter>,
|
|
203
|
-
);
|
|
204
|
-
|
|
205
|
-
expect(button.hasClass('bdl-is-selected')).toBe(false);
|
|
206
|
-
});
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
describe('onClick', () => {
|
|
210
|
-
const mockHistory = {
|
|
211
|
-
listen: jest.fn(),
|
|
212
|
-
location: {},
|
|
213
|
-
push: jest.fn(),
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
test('calls onClick eventhandler and history.push', () => {
|
|
217
|
-
const clickHandler = jest.fn();
|
|
218
|
-
|
|
219
|
-
const button = mount(
|
|
220
|
-
<Router history={mockHistory}>
|
|
221
|
-
<NavButton to="/activity/test" onClick={clickHandler}>
|
|
222
|
-
Activity Test
|
|
223
|
-
</NavButton>
|
|
224
|
-
</Router>,
|
|
225
|
-
);
|
|
226
|
-
|
|
227
|
-
button.simulate('click', {
|
|
228
|
-
button: 0,
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
expect(clickHandler).toBeCalledTimes(1);
|
|
232
|
-
expect(mockHistory.push).toBeCalledTimes(1);
|
|
233
|
-
expect(mockHistory.push).toBeCalledWith('/activity/test');
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
test('does not call history.push on right click', () => {
|
|
237
|
-
const button = mount(
|
|
238
|
-
<Router history={mockHistory}>
|
|
239
|
-
<NavButton to="/activity/test">Activity Test</NavButton>
|
|
240
|
-
</Router>,
|
|
241
|
-
);
|
|
242
|
-
|
|
243
|
-
button.simulate('click', {
|
|
244
|
-
button: 1,
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
expect(mockHistory.push).toBeCalledTimes(0);
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
test('does not call history.push on prevented event', () => {
|
|
251
|
-
const button = mount(
|
|
252
|
-
<Router history={mockHistory}>
|
|
253
|
-
<NavButton to="/activity/test">Activity Test</NavButton>
|
|
254
|
-
</Router>,
|
|
255
|
-
);
|
|
256
|
-
|
|
257
|
-
button.simulate('click', {
|
|
258
|
-
defaultPrevented: true,
|
|
259
|
-
button: 0,
|
|
260
|
-
});
|
|
261
|
-
|
|
262
|
-
expect(mockHistory.push).toBeCalledTimes(0);
|
|
263
|
-
});
|
|
264
|
-
});
|
|
265
|
-
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|