@axinom/mosaic-ui 0.32.0-rc.5 → 0.32.0-rc.6
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/components/Actions/Action/Action.d.ts.map +1 -1
- package/dist/components/Buttons/Button/Button.d.ts +9 -10
- package/dist/components/Buttons/Button/Button.d.ts.map +1 -1
- package/dist/components/Buttons/Button/Button.model.d.ts +21 -0
- package/dist/components/Buttons/Button/Button.model.d.ts.map +1 -0
- package/dist/components/Buttons/Button/index.d.ts +3 -0
- package/dist/components/Buttons/Button/index.d.ts.map +1 -0
- package/dist/components/Buttons/Button.model.d.ts +69 -7
- package/dist/components/Buttons/Button.model.d.ts.map +1 -1
- package/dist/components/Buttons/CompositeButton/CompositeButton.d.ts +5 -14
- package/dist/components/Buttons/CompositeButton/CompositeButton.d.ts.map +1 -1
- package/dist/components/Buttons/CompositeButton/CompositeButton.model.d.ts +20 -0
- package/dist/components/Buttons/CompositeButton/CompositeButton.model.d.ts.map +1 -0
- package/dist/components/Buttons/CompositeButton/index.d.ts +3 -0
- package/dist/components/Buttons/CompositeButton/index.d.ts.map +1 -0
- package/dist/components/Buttons/TextButton/TextButton.d.ts +5 -9
- package/dist/components/Buttons/TextButton/TextButton.d.ts.map +1 -1
- package/dist/components/Buttons/TextButton/TextButton.model.d.ts +18 -0
- package/dist/components/Buttons/TextButton/TextButton.model.d.ts.map +1 -0
- package/dist/components/Buttons/TextButton/index.d.ts +3 -0
- package/dist/components/Buttons/TextButton/index.d.ts.map +1 -0
- package/dist/components/Buttons/index.d.ts +3 -3
- package/dist/components/Buttons/index.d.ts.map +1 -1
- package/dist/components/Explorer/Explorer.d.ts.map +1 -1
- package/dist/components/Explorer/NavigationExplorer/NavigationExplorer.d.ts +3 -2
- package/dist/components/Explorer/NavigationExplorer/NavigationExplorer.d.ts.map +1 -1
- package/dist/components/FormElements/ToggleButton/ToggleButton.d.ts +2 -2
- package/dist/components/FormElements/ToggleButton/ToggleButton.d.ts.map +1 -1
- package/dist/components/List/ListRow/ListRow.d.ts.map +1 -1
- package/dist/components/PageHeader/PageHeaderAction/PageHeaderAction.d.ts.map +1 -1
- package/dist/components/models.d.ts +5 -2
- package/dist/components/models.d.ts.map +1 -1
- package/dist/index.es.js +3 -3
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/Actions/Action/Action.spec.tsx +14 -0
- package/src/components/Actions/Action/Action.tsx +5 -2
- package/src/components/Buttons/Button/Button.model.ts +30 -0
- package/src/components/Buttons/Button/Button.scss +3 -1
- package/src/components/Buttons/Button/Button.spec.tsx +254 -83
- package/src/components/Buttons/Button/Button.stories.tsx +20 -0
- package/src/components/Buttons/Button/Button.tsx +103 -32
- package/src/components/Buttons/Button/index.ts +2 -0
- package/src/components/Buttons/Button.model.ts +84 -9
- package/src/components/Buttons/CompositeButton/CompositeButton.model.ts +32 -0
- package/src/components/Buttons/CompositeButton/CompositeButton.scss +6 -1
- package/src/components/Buttons/CompositeButton/CompositeButton.spec.tsx +277 -89
- package/src/components/Buttons/CompositeButton/CompositeButton.stories.tsx +20 -0
- package/src/components/Buttons/CompositeButton/CompositeButton.tsx +94 -30
- package/src/components/Buttons/CompositeButton/index.ts +2 -0
- package/src/components/Buttons/TextButton/TextButton.model.ts +27 -0
- package/src/components/Buttons/TextButton/TextButton.scss +3 -1
- package/src/components/Buttons/TextButton/TextButton.spec.tsx +198 -87
- package/src/components/Buttons/TextButton/TextButton.stories.tsx +20 -0
- package/src/components/Buttons/TextButton/TextButton.tsx +74 -20
- package/src/components/Buttons/TextButton/index.ts +2 -0
- package/src/components/Buttons/index.ts +3 -6
- package/src/components/Explorer/Explorer.tsx +2 -2
- package/src/components/Explorer/NavigationExplorer/NavigationExplorer.tsx +4 -3
- package/src/components/FormElements/CustomTags/CustomTags.spec.tsx +26 -16
- package/src/components/FormElements/ToggleButton/ToggleButton.tsx +2 -2
- package/src/components/List/ListRow/ListRow.tsx +18 -13
- package/src/components/PageHeader/PageHeaderAction/PageHeaderAction.spec.tsx +513 -388
- package/src/components/PageHeader/PageHeaderAction/PageHeaderAction.tsx +11 -7
- package/src/components/models.ts +5 -2
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { mount, shallow } from 'enzyme';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { act } from 'react-dom/test-utils';
|
|
4
|
+
import { Link, BrowserRouter as Router } from 'react-router-dom';
|
|
4
5
|
import { noop } from '../../../helpers/utils';
|
|
5
6
|
import { TextButton } from '../../Buttons';
|
|
6
7
|
import { ConfirmationConfig, ConfirmDialog } from '../../ConfirmDialog';
|
|
7
8
|
import { IconName } from '../../Icons';
|
|
8
9
|
import {
|
|
10
|
+
PageHeaderAction,
|
|
9
11
|
isPageHeaderJsAction,
|
|
10
12
|
isPageHeaderNavigationAction,
|
|
11
|
-
PageHeaderAction,
|
|
12
13
|
} from './PageHeaderAction';
|
|
13
14
|
import {
|
|
14
15
|
PageHeaderActionProps,
|
|
@@ -21,515 +22,639 @@ const defaultProps: PageHeaderActionProps = {
|
|
|
21
22
|
};
|
|
22
23
|
|
|
23
24
|
describe('PageHeaderAction', () => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
expect(wrapper).toBeTruthy();
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('renders a label', () => {
|
|
31
|
-
const mockLabel = 'test-label';
|
|
32
|
-
const wrapper = mount(
|
|
33
|
-
<PageHeaderAction {...defaultProps} label={mockLabel} />,
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
const label = wrapper.find('span');
|
|
37
|
-
|
|
38
|
-
expect(label.text()).toBe(mockLabel);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('renders a Icon, if set', () => {
|
|
42
|
-
const mockLabel = 'test-label';
|
|
43
|
-
const wrapper = mount(
|
|
44
|
-
<PageHeaderAction
|
|
45
|
-
{...defaultProps}
|
|
46
|
-
label={mockLabel}
|
|
47
|
-
icon={IconName.ChevronRight}
|
|
48
|
-
/>,
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
const Icon = wrapper.find('.icons');
|
|
52
|
-
|
|
53
|
-
expect(Icon.exists()).toBe(true);
|
|
54
|
-
});
|
|
25
|
+
describe('PageHeaderJSAction', () => {
|
|
26
|
+
it('renders the component without crashing', () => {
|
|
27
|
+
const wrapper = shallow(<PageHeaderAction {...defaultProps} />);
|
|
55
28
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const wrapper = mount(
|
|
59
|
-
<PageHeaderAction
|
|
60
|
-
{...defaultProps}
|
|
61
|
-
label={mockLabel}
|
|
62
|
-
icon={'test'}
|
|
63
|
-
imgAlt={'alt'}
|
|
64
|
-
/>,
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
const Icon = wrapper.find('.icons');
|
|
68
|
-
|
|
69
|
-
expect(Icon.exists()).toBe(false);
|
|
70
|
-
});
|
|
29
|
+
expect(wrapper).toBeTruthy();
|
|
30
|
+
});
|
|
71
31
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
32
|
+
it('renders a label', () => {
|
|
33
|
+
const mockLabel = 'test-label';
|
|
34
|
+
const wrapper = mount(
|
|
35
|
+
<PageHeaderAction {...defaultProps} label={mockLabel} />,
|
|
36
|
+
);
|
|
75
37
|
|
|
76
|
-
|
|
77
|
-
container.simulate('click');
|
|
38
|
+
const label = wrapper.find('span');
|
|
78
39
|
|
|
79
|
-
|
|
80
|
-
|
|
40
|
+
expect(label.text()).toBe(mockLabel);
|
|
41
|
+
});
|
|
81
42
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const spy = jest.fn();
|
|
43
|
+
it('renders a Icon, if set', () => {
|
|
44
|
+
const mockLabel = 'test-label';
|
|
85
45
|
const wrapper = mount(
|
|
86
46
|
<PageHeaderAction
|
|
87
47
|
{...defaultProps}
|
|
88
|
-
label={
|
|
89
|
-
|
|
90
|
-
onClick={spy}
|
|
48
|
+
label={mockLabel}
|
|
49
|
+
icon={IconName.ChevronRight}
|
|
91
50
|
/>,
|
|
92
51
|
);
|
|
93
|
-
let container = wrapper.find('.container');
|
|
94
|
-
expect(container.hasClass('hasConfirm')).toBe(false);
|
|
95
|
-
|
|
96
|
-
wrapper.simulate('click');
|
|
97
|
-
wrapper.update();
|
|
98
52
|
|
|
99
|
-
|
|
53
|
+
const Icon = wrapper.find('.icons');
|
|
100
54
|
|
|
101
|
-
expect(
|
|
55
|
+
expect(Icon.exists()).toBe(true);
|
|
102
56
|
});
|
|
103
57
|
|
|
104
|
-
it(
|
|
58
|
+
it('image is used instead of icon if icon prop is a string', () => {
|
|
105
59
|
const mockLabel = 'test-label';
|
|
106
|
-
const confirmationMsg = 'Click again to confirm';
|
|
107
|
-
const spy = jest.fn();
|
|
108
60
|
const wrapper = mount(
|
|
109
61
|
<PageHeaderAction
|
|
110
62
|
{...defaultProps}
|
|
111
63
|
label={mockLabel}
|
|
112
|
-
|
|
113
|
-
|
|
64
|
+
icon={'test'}
|
|
65
|
+
imgAlt={'alt'}
|
|
114
66
|
/>,
|
|
115
67
|
);
|
|
116
68
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
expect(span.text()).toBe(mockLabel);
|
|
120
|
-
|
|
121
|
-
wrapper.simulate('click');
|
|
122
|
-
|
|
123
|
-
span = wrapper.find('span');
|
|
124
|
-
|
|
125
|
-
expect(span.text()).toBe(confirmationMsg);
|
|
126
|
-
|
|
127
|
-
wrapper.simulate('click');
|
|
69
|
+
const Icon = wrapper.find('.icons');
|
|
128
70
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
expect(spy).toHaveBeenCalledTimes(1);
|
|
132
|
-
expect(span.text()).toBe(mockLabel);
|
|
71
|
+
expect(Icon.exists()).toBe(false);
|
|
133
72
|
});
|
|
134
73
|
|
|
135
|
-
it(
|
|
136
|
-
const mockLabel = 'test-label';
|
|
137
|
-
const confirmationMsg = 'Click again to confirm';
|
|
74
|
+
it('raises onActionSelected', () => {
|
|
138
75
|
const spy = jest.fn();
|
|
139
|
-
jest.useFakeTimers();
|
|
140
|
-
|
|
141
76
|
const wrapper = mount(
|
|
142
|
-
<PageHeaderAction
|
|
143
|
-
{...defaultProps}
|
|
144
|
-
label={mockLabel}
|
|
145
|
-
confirmationMode="Simple"
|
|
146
|
-
onClick={spy}
|
|
147
|
-
/>,
|
|
77
|
+
<PageHeaderAction {...defaultProps} onClick={spy} />,
|
|
148
78
|
);
|
|
149
79
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
});
|
|
153
|
-
wrapper.update();
|
|
80
|
+
const container = wrapper.find('.container');
|
|
81
|
+
container.simulate('click');
|
|
154
82
|
|
|
155
|
-
|
|
156
|
-
|
|
83
|
+
expect(spy).toHaveBeenCalledTimes(1);
|
|
84
|
+
});
|
|
157
85
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
86
|
+
describe('confirmation', () => {
|
|
87
|
+
it(`'Simple' mode changes the background color when clicked for the first time`, () => {
|
|
88
|
+
const spy = jest.fn();
|
|
89
|
+
const wrapper = mount(
|
|
90
|
+
<PageHeaderAction
|
|
91
|
+
{...defaultProps}
|
|
92
|
+
label={'test-label'}
|
|
93
|
+
confirmationMode="Simple"
|
|
94
|
+
onClick={spy}
|
|
95
|
+
/>,
|
|
96
|
+
);
|
|
97
|
+
let container = wrapper.find('.container');
|
|
98
|
+
expect(container.hasClass('hasConfirm')).toBe(false);
|
|
161
99
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
100
|
+
wrapper.simulate('click');
|
|
101
|
+
wrapper.update();
|
|
102
|
+
|
|
103
|
+
container = wrapper.find('.container');
|
|
166
104
|
|
|
167
|
-
|
|
168
|
-
jest.runAllTimers();
|
|
105
|
+
expect(container.hasClass('hasConfirm')).toBe(true);
|
|
169
106
|
});
|
|
170
|
-
wrapper.update();
|
|
171
107
|
|
|
172
|
-
|
|
173
|
-
|
|
108
|
+
it(`'Simple' mode renders a confirmation message, raises the 'onClick' event after confirmation, and resets the action label`, () => {
|
|
109
|
+
const mockLabel = 'test-label';
|
|
110
|
+
const confirmationMsg = 'Click again to confirm';
|
|
111
|
+
const spy = jest.fn();
|
|
112
|
+
const wrapper = mount(
|
|
113
|
+
<PageHeaderAction
|
|
114
|
+
{...defaultProps}
|
|
115
|
+
label={mockLabel}
|
|
116
|
+
confirmationMode="Simple"
|
|
117
|
+
onClick={spy}
|
|
118
|
+
/>,
|
|
119
|
+
);
|
|
174
120
|
|
|
175
|
-
|
|
176
|
-
expect(spy).not.toHaveBeenCalled();
|
|
177
|
-
expect(container.hasClass('hasConfirm')).toBe(false);
|
|
178
|
-
});
|
|
121
|
+
let span = wrapper.find('span');
|
|
179
122
|
|
|
180
|
-
|
|
181
|
-
const spy = jest.fn();
|
|
182
|
-
const wrapper = mount(
|
|
183
|
-
<PageHeaderAction
|
|
184
|
-
{...defaultProps}
|
|
185
|
-
label={'test-label'}
|
|
186
|
-
confirmationMode="Advanced"
|
|
187
|
-
onClick={spy}
|
|
188
|
-
/>,
|
|
189
|
-
);
|
|
190
|
-
let container = wrapper.find('.container').first();
|
|
191
|
-
expect(container.hasClass('hasConfirm')).toBe(false);
|
|
123
|
+
expect(span.text()).toBe(mockLabel);
|
|
192
124
|
|
|
193
|
-
|
|
194
|
-
await wrapper.simulate('click');
|
|
195
|
-
});
|
|
196
|
-
wrapper.update();
|
|
125
|
+
wrapper.simulate('click');
|
|
197
126
|
|
|
198
|
-
|
|
127
|
+
span = wrapper.find('span');
|
|
199
128
|
|
|
200
|
-
|
|
201
|
-
});
|
|
129
|
+
expect(span.text()).toBe(confirmationMsg);
|
|
202
130
|
|
|
203
|
-
|
|
204
|
-
const spy = jest.fn();
|
|
205
|
-
const wrapper = mount(
|
|
206
|
-
<PageHeaderAction
|
|
207
|
-
{...defaultProps}
|
|
208
|
-
label={'test-label'}
|
|
209
|
-
confirmationMode="Advanced"
|
|
210
|
-
onClick={spy}
|
|
211
|
-
/>,
|
|
212
|
-
);
|
|
213
|
-
let confirmation = wrapper.find(ConfirmDialog);
|
|
131
|
+
wrapper.simulate('click');
|
|
214
132
|
|
|
215
|
-
|
|
133
|
+
span = wrapper.find('span');
|
|
216
134
|
|
|
217
|
-
|
|
218
|
-
|
|
135
|
+
expect(spy).toHaveBeenCalledTimes(1);
|
|
136
|
+
expect(span.text()).toBe(mockLabel);
|
|
219
137
|
});
|
|
220
|
-
wrapper.update();
|
|
221
|
-
|
|
222
|
-
confirmation = wrapper.find(ConfirmDialog);
|
|
223
138
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
139
|
+
it(`'Simple' mode renders a confirmation message, and doesn't raise the 'onClick' event on 'mouseleave' when confirmation is required`, async () => {
|
|
140
|
+
const mockLabel = 'test-label';
|
|
141
|
+
const confirmationMsg = 'Click again to confirm';
|
|
142
|
+
const spy = jest.fn();
|
|
143
|
+
jest.useFakeTimers();
|
|
144
|
+
|
|
145
|
+
const wrapper = mount(
|
|
146
|
+
<PageHeaderAction
|
|
147
|
+
{...defaultProps}
|
|
148
|
+
label={mockLabel}
|
|
149
|
+
confirmationMode="Simple"
|
|
150
|
+
onClick={spy}
|
|
151
|
+
/>,
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
await act(async () => {
|
|
155
|
+
wrapper.simulate('click');
|
|
156
|
+
});
|
|
157
|
+
wrapper.update();
|
|
158
|
+
|
|
159
|
+
let span = wrapper.find('span');
|
|
160
|
+
let container = wrapper.find('.container');
|
|
161
|
+
|
|
162
|
+
expect(container.hasClass('hasConfirm')).toBe(true);
|
|
163
|
+
expect(span.text()).toBe(confirmationMsg);
|
|
164
|
+
expect(spy).not.toHaveBeenCalled();
|
|
165
|
+
|
|
166
|
+
await act(async () => {
|
|
167
|
+
await wrapper.simulate('mouseleave');
|
|
168
|
+
});
|
|
169
|
+
wrapper.update();
|
|
170
|
+
|
|
171
|
+
await act(async () => {
|
|
172
|
+
jest.runAllTimers();
|
|
173
|
+
});
|
|
174
|
+
wrapper.update();
|
|
175
|
+
|
|
176
|
+
span = wrapper.find('span');
|
|
177
|
+
container = wrapper.find('.container');
|
|
178
|
+
|
|
179
|
+
expect(span.text()).toBe(mockLabel);
|
|
180
|
+
expect(spy).not.toHaveBeenCalled();
|
|
181
|
+
expect(container.hasClass('hasConfirm')).toBe(false);
|
|
182
|
+
});
|
|
227
183
|
|
|
228
|
-
|
|
229
|
-
|
|
184
|
+
it(`'Advanced' mode changes the background color when clicked for the first time`, async () => {
|
|
185
|
+
const spy = jest.fn();
|
|
186
|
+
const wrapper = mount(
|
|
187
|
+
<PageHeaderAction
|
|
188
|
+
{...defaultProps}
|
|
189
|
+
label={'test-label'}
|
|
190
|
+
confirmationMode="Advanced"
|
|
191
|
+
onClick={spy}
|
|
192
|
+
/>,
|
|
193
|
+
);
|
|
194
|
+
let container = wrapper.find('.container').first();
|
|
195
|
+
expect(container.hasClass('hasConfirm')).toBe(false);
|
|
196
|
+
|
|
197
|
+
await act(async () => {
|
|
198
|
+
await wrapper.simulate('click');
|
|
199
|
+
});
|
|
200
|
+
wrapper.update();
|
|
201
|
+
|
|
202
|
+
container = wrapper.find('.container').first();
|
|
203
|
+
|
|
204
|
+
expect(container.hasClass('hasConfirm')).toBe(true);
|
|
230
205
|
});
|
|
231
|
-
wrapper.update();
|
|
232
206
|
|
|
233
|
-
confirmation
|
|
207
|
+
it(`'Advanced' mode confirmation pop up, raises the 'onClick' event after the 'Confirm' button is clicked, and finally dismisses the confirmation pop up`, async () => {
|
|
208
|
+
const spy = jest.fn();
|
|
209
|
+
const wrapper = mount(
|
|
210
|
+
<PageHeaderAction
|
|
211
|
+
{...defaultProps}
|
|
212
|
+
label={'test-label'}
|
|
213
|
+
confirmationMode="Advanced"
|
|
214
|
+
onClick={spy}
|
|
215
|
+
/>,
|
|
216
|
+
);
|
|
217
|
+
let confirmation = wrapper.find(ConfirmDialog);
|
|
234
218
|
|
|
235
|
-
|
|
236
|
-
expect(spy).toHaveBeenCalledTimes(1);
|
|
237
|
-
});
|
|
219
|
+
expect(confirmation.exists()).toBe(false);
|
|
238
220
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
{...defaultProps}
|
|
244
|
-
label={'test-label'}
|
|
245
|
-
confirmationMode="Advanced"
|
|
246
|
-
onClick={spy}
|
|
247
|
-
/>,
|
|
248
|
-
);
|
|
249
|
-
let confirmation = wrapper.find(ConfirmDialog);
|
|
221
|
+
await act(async () => {
|
|
222
|
+
await wrapper.simulate('click');
|
|
223
|
+
});
|
|
224
|
+
wrapper.update();
|
|
250
225
|
|
|
251
|
-
|
|
226
|
+
confirmation = wrapper.find(ConfirmDialog);
|
|
252
227
|
|
|
253
|
-
|
|
254
|
-
await wrapper.simulate('click');
|
|
255
|
-
});
|
|
256
|
-
wrapper.update();
|
|
228
|
+
expect(confirmation.exists()).toBe(true);
|
|
257
229
|
|
|
258
|
-
|
|
230
|
+
const confirmButton = wrapper.find(TextButton).last();
|
|
259
231
|
|
|
260
|
-
|
|
232
|
+
act(() => {
|
|
233
|
+
confirmButton.simulate('click');
|
|
234
|
+
});
|
|
235
|
+
wrapper.update();
|
|
261
236
|
|
|
262
|
-
|
|
237
|
+
confirmation = wrapper.find(ConfirmDialog);
|
|
263
238
|
|
|
264
|
-
|
|
265
|
-
|
|
239
|
+
expect(confirmation.exists()).toBe(false);
|
|
240
|
+
expect(spy).toHaveBeenCalledTimes(1);
|
|
266
241
|
});
|
|
267
|
-
wrapper.update();
|
|
268
242
|
|
|
269
|
-
confirmation
|
|
243
|
+
it(`'Advanced' mode confirmation pop up, does not raise the 'onClick' event after the 'Cancel' button is clicked, and finally dismisses the confirmation pop up`, async () => {
|
|
244
|
+
const spy = jest.fn();
|
|
245
|
+
const wrapper = mount(
|
|
246
|
+
<PageHeaderAction
|
|
247
|
+
{...defaultProps}
|
|
248
|
+
label={'test-label'}
|
|
249
|
+
confirmationMode="Advanced"
|
|
250
|
+
onClick={spy}
|
|
251
|
+
/>,
|
|
252
|
+
);
|
|
253
|
+
let confirmation = wrapper.find(ConfirmDialog);
|
|
270
254
|
|
|
271
|
-
|
|
272
|
-
expect(spy).not.toHaveBeenCalled();
|
|
273
|
-
});
|
|
255
|
+
expect(confirmation.exists()).toBe(false);
|
|
274
256
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
257
|
+
await act(async () => {
|
|
258
|
+
await wrapper.simulate('click');
|
|
259
|
+
});
|
|
260
|
+
wrapper.update();
|
|
278
261
|
|
|
279
|
-
|
|
280
|
-
<PageHeaderAction
|
|
281
|
-
{...defaultProps}
|
|
282
|
-
label={'test-label'}
|
|
283
|
-
confirmationMode="Advanced"
|
|
284
|
-
onClick={spy}
|
|
285
|
-
/>,
|
|
286
|
-
);
|
|
287
|
-
let confirmation = wrapper.find(ConfirmDialog);
|
|
262
|
+
confirmation = wrapper.find(ConfirmDialog);
|
|
288
263
|
|
|
289
|
-
|
|
264
|
+
expect(confirmation.exists()).toBe(true);
|
|
290
265
|
|
|
291
|
-
|
|
292
|
-
await wrapper.simulate('click');
|
|
293
|
-
});
|
|
294
|
-
wrapper.update();
|
|
266
|
+
const confirmButton = wrapper.find(TextButton).first();
|
|
295
267
|
|
|
296
|
-
|
|
268
|
+
act(() => {
|
|
269
|
+
confirmButton.simulate('click');
|
|
270
|
+
});
|
|
271
|
+
wrapper.update();
|
|
297
272
|
|
|
298
|
-
|
|
273
|
+
confirmation = wrapper.find(ConfirmDialog);
|
|
299
274
|
|
|
300
|
-
|
|
301
|
-
|
|
275
|
+
expect(confirmation.exists()).toBe(false);
|
|
276
|
+
expect(spy).not.toHaveBeenCalled();
|
|
302
277
|
});
|
|
303
|
-
wrapper.update();
|
|
304
278
|
|
|
305
|
-
|
|
306
|
-
jest.
|
|
307
|
-
|
|
308
|
-
wrapper.update();
|
|
279
|
+
it(`'Advanced' mode renders a confirmation pop up, does not raise the 'onClick' event when the mouse leaves component, and finally dismisses the confirmation pop up`, async () => {
|
|
280
|
+
const spy = jest.fn();
|
|
281
|
+
jest.useFakeTimers();
|
|
309
282
|
|
|
310
|
-
|
|
283
|
+
const wrapper = mount(
|
|
284
|
+
<PageHeaderAction
|
|
285
|
+
{...defaultProps}
|
|
286
|
+
label={'test-label'}
|
|
287
|
+
confirmationMode="Advanced"
|
|
288
|
+
onClick={spy}
|
|
289
|
+
/>,
|
|
290
|
+
);
|
|
291
|
+
let confirmation = wrapper.find(ConfirmDialog);
|
|
311
292
|
|
|
312
|
-
|
|
313
|
-
// expect(confirmation.exists()).toBe(false);
|
|
314
|
-
expect(spy).not.toHaveBeenCalled();
|
|
315
|
-
});
|
|
293
|
+
expect(confirmation.exists()).toBe(false);
|
|
316
294
|
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
cancelButtonText: 'test-cancel',
|
|
322
|
-
confirmButtonText: 'test-confirm',
|
|
323
|
-
};
|
|
295
|
+
await act(async () => {
|
|
296
|
+
await wrapper.simulate('click');
|
|
297
|
+
});
|
|
298
|
+
wrapper.update();
|
|
324
299
|
|
|
325
|
-
|
|
326
|
-
<PageHeaderAction
|
|
327
|
-
{...defaultProps}
|
|
328
|
-
label={'test-label'}
|
|
329
|
-
confirmationMode="Advanced"
|
|
330
|
-
confirmationConfig={mockConfig}
|
|
331
|
-
/>,
|
|
332
|
-
);
|
|
300
|
+
confirmation = wrapper.find(ConfirmDialog);
|
|
333
301
|
|
|
334
|
-
|
|
335
|
-
await wrapper.simulate('click');
|
|
336
|
-
});
|
|
337
|
-
wrapper.update();
|
|
302
|
+
expect(confirmation.exists()).toBe(true);
|
|
338
303
|
|
|
339
|
-
|
|
304
|
+
await act(async () => {
|
|
305
|
+
await wrapper.simulate('mouseleave');
|
|
306
|
+
});
|
|
307
|
+
wrapper.update();
|
|
340
308
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
);
|
|
346
|
-
expect(confirmation.prop('confirmButtonText')).toBe(
|
|
347
|
-
mockConfig.confirmButtonText,
|
|
348
|
-
);
|
|
349
|
-
});
|
|
309
|
+
await act(async () => {
|
|
310
|
+
jest.runAllTimers();
|
|
311
|
+
});
|
|
312
|
+
wrapper.update();
|
|
350
313
|
|
|
351
|
-
|
|
352
|
-
const confirmToggleSpy = jest.fn();
|
|
314
|
+
confirmation = wrapper.find(ConfirmDialog);
|
|
353
315
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
confirmationMode="Simple"
|
|
359
|
-
confirmationConfig={{ onConfirmOpen: confirmToggleSpy }}
|
|
360
|
-
/>,
|
|
361
|
-
);
|
|
316
|
+
// TODO: Debug why this isn't passing
|
|
317
|
+
// expect(confirmation.exists()).toBe(false);
|
|
318
|
+
expect(spy).not.toHaveBeenCalled();
|
|
319
|
+
});
|
|
362
320
|
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
321
|
+
it(`'Advanced' mode accepts a 'confirmationConfig' object`, async () => {
|
|
322
|
+
const mockConfig: ConfirmationConfig = {
|
|
323
|
+
title: 'test-title',
|
|
324
|
+
body: 'test-body',
|
|
325
|
+
cancelButtonText: 'test-cancel',
|
|
326
|
+
confirmButtonText: 'test-confirm',
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
const wrapper = mount(
|
|
330
|
+
<PageHeaderAction
|
|
331
|
+
{...defaultProps}
|
|
332
|
+
label={'test-label'}
|
|
333
|
+
confirmationMode="Advanced"
|
|
334
|
+
confirmationConfig={mockConfig}
|
|
335
|
+
/>,
|
|
336
|
+
);
|
|
337
|
+
|
|
338
|
+
await act(async () => {
|
|
339
|
+
await wrapper.simulate('click');
|
|
340
|
+
});
|
|
341
|
+
wrapper.update();
|
|
342
|
+
|
|
343
|
+
const confirmation = wrapper.find(ConfirmDialog);
|
|
344
|
+
|
|
345
|
+
expect(confirmation.prop('title')).toBe(mockConfig.title);
|
|
346
|
+
expect(confirmation.prop('children')).toBe(mockConfig.body);
|
|
347
|
+
expect(confirmation.prop('cancelButtonText')).toBe(
|
|
348
|
+
mockConfig.cancelButtonText,
|
|
349
|
+
);
|
|
350
|
+
expect(confirmation.prop('confirmButtonText')).toBe(
|
|
351
|
+
mockConfig.confirmButtonText,
|
|
352
|
+
);
|
|
366
353
|
});
|
|
367
354
|
|
|
368
|
-
|
|
355
|
+
it(`'Simple' raises onConfirmOpen if set`, () => {
|
|
356
|
+
const confirmToggleSpy = jest.fn();
|
|
357
|
+
|
|
358
|
+
const wrapper = mount(
|
|
359
|
+
<PageHeaderAction
|
|
360
|
+
{...defaultProps}
|
|
361
|
+
label={'test-label'}
|
|
362
|
+
confirmationMode="Simple"
|
|
363
|
+
confirmationConfig={{ onConfirmOpen: confirmToggleSpy }}
|
|
364
|
+
/>,
|
|
365
|
+
);
|
|
366
|
+
|
|
367
|
+
// toggle confirmation on
|
|
368
|
+
act(() => {
|
|
369
|
+
wrapper.simulate('click');
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
expect(confirmToggleSpy).toHaveBeenCalledTimes(1);
|
|
373
|
+
|
|
374
|
+
// toggle confirmation off
|
|
375
|
+
act(() => {
|
|
376
|
+
wrapper.simulate('click');
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
expect(confirmToggleSpy).toHaveBeenCalledTimes(2);
|
|
380
|
+
expect(confirmToggleSpy).toHaveBeenNthCalledWith(1, true, {
|
|
381
|
+
mode: 'Simple',
|
|
382
|
+
});
|
|
383
|
+
expect(confirmToggleSpy).toHaveBeenNthCalledWith(2, false, {
|
|
384
|
+
mode: 'Simple',
|
|
385
|
+
});
|
|
386
|
+
});
|
|
369
387
|
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
388
|
+
it(`'Simple' raises onConfirmOpen when 'mouseleave' if set`, async () => {
|
|
389
|
+
const confirmToggleSpy = jest.fn();
|
|
390
|
+
|
|
391
|
+
jest.useFakeTimers();
|
|
392
|
+
|
|
393
|
+
const wrapper = mount(
|
|
394
|
+
<PageHeaderAction
|
|
395
|
+
{...defaultProps}
|
|
396
|
+
label={'test-label'}
|
|
397
|
+
confirmationMode="Simple"
|
|
398
|
+
confirmationConfig={{ onConfirmOpen: confirmToggleSpy }}
|
|
399
|
+
/>,
|
|
400
|
+
);
|
|
401
|
+
|
|
402
|
+
await act(async () => {
|
|
403
|
+
wrapper.simulate('click');
|
|
404
|
+
});
|
|
405
|
+
wrapper.update();
|
|
406
|
+
|
|
407
|
+
await act(async () => {
|
|
408
|
+
await wrapper.simulate('mouseleave');
|
|
409
|
+
});
|
|
410
|
+
wrapper.update();
|
|
411
|
+
|
|
412
|
+
await act(async () => {
|
|
413
|
+
jest.runAllTimers();
|
|
414
|
+
});
|
|
415
|
+
wrapper.update();
|
|
416
|
+
|
|
417
|
+
expect(confirmToggleSpy).toHaveBeenCalledTimes(2);
|
|
418
|
+
expect(confirmToggleSpy).toHaveBeenNthCalledWith(1, true, {
|
|
419
|
+
mode: 'Simple',
|
|
420
|
+
});
|
|
421
|
+
expect(confirmToggleSpy).toHaveBeenNthCalledWith(2, false, {
|
|
422
|
+
mode: 'Simple',
|
|
423
|
+
});
|
|
373
424
|
});
|
|
374
425
|
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
426
|
+
it(`'Advanced' raises onConfirmOpen when 'Cancel' is clicked, if set`, () => {
|
|
427
|
+
const confirmToggleSpy = jest.fn();
|
|
428
|
+
|
|
429
|
+
const wrapper = mount(
|
|
430
|
+
<PageHeaderAction
|
|
431
|
+
{...defaultProps}
|
|
432
|
+
label={'test-label'}
|
|
433
|
+
confirmationMode="Advanced"
|
|
434
|
+
confirmationConfig={{ onConfirmOpen: confirmToggleSpy }}
|
|
435
|
+
/>,
|
|
436
|
+
);
|
|
437
|
+
|
|
438
|
+
// toggle confirmation on
|
|
439
|
+
act(() => {
|
|
440
|
+
wrapper.simulate('click');
|
|
441
|
+
});
|
|
442
|
+
wrapper.update();
|
|
443
|
+
|
|
444
|
+
const cancelButton = wrapper.find(TextButton).first();
|
|
445
|
+
|
|
446
|
+
act(() => {
|
|
447
|
+
cancelButton.simulate('click');
|
|
448
|
+
});
|
|
449
|
+
wrapper.update();
|
|
450
|
+
|
|
451
|
+
expect(confirmToggleSpy).toHaveBeenCalledTimes(2);
|
|
452
|
+
expect(confirmToggleSpy).toHaveBeenNthCalledWith(1, true, {
|
|
453
|
+
mode: 'Advanced',
|
|
454
|
+
});
|
|
455
|
+
expect(confirmToggleSpy).toHaveBeenNthCalledWith(2, false, {
|
|
456
|
+
mode: 'Advanced',
|
|
457
|
+
});
|
|
378
458
|
});
|
|
379
|
-
|
|
380
|
-
|
|
459
|
+
|
|
460
|
+
it(`'Advanced' raises onConfirmOpen when 'Confirm' is clicked, if set`, () => {
|
|
461
|
+
const confirmToggleSpy = jest.fn();
|
|
462
|
+
|
|
463
|
+
const wrapper = mount(
|
|
464
|
+
<PageHeaderAction
|
|
465
|
+
{...defaultProps}
|
|
466
|
+
label={'test-label'}
|
|
467
|
+
confirmationMode="Advanced"
|
|
468
|
+
confirmationConfig={{ onConfirmOpen: confirmToggleSpy }}
|
|
469
|
+
/>,
|
|
470
|
+
);
|
|
471
|
+
|
|
472
|
+
// toggle confirmation on
|
|
473
|
+
act(() => {
|
|
474
|
+
wrapper.simulate('click');
|
|
475
|
+
});
|
|
476
|
+
wrapper.update();
|
|
477
|
+
|
|
478
|
+
const confirmButton = wrapper.find(TextButton).last();
|
|
479
|
+
|
|
480
|
+
act(() => {
|
|
481
|
+
confirmButton.simulate('click');
|
|
482
|
+
});
|
|
483
|
+
wrapper.update();
|
|
484
|
+
|
|
485
|
+
expect(confirmToggleSpy).toHaveBeenCalledTimes(2);
|
|
486
|
+
expect(confirmToggleSpy).toHaveBeenNthCalledWith(1, true, {
|
|
487
|
+
mode: 'Advanced',
|
|
488
|
+
});
|
|
489
|
+
expect(confirmToggleSpy).toHaveBeenNthCalledWith(2, false, {
|
|
490
|
+
mode: 'Advanced',
|
|
491
|
+
});
|
|
381
492
|
});
|
|
382
493
|
});
|
|
383
494
|
|
|
384
|
-
it(`
|
|
385
|
-
const
|
|
386
|
-
|
|
387
|
-
jest.useFakeTimers();
|
|
388
|
-
|
|
495
|
+
it(`sets background color when actionType is 'Context'`, () => {
|
|
496
|
+
const spy = jest.fn();
|
|
389
497
|
const wrapper = mount(
|
|
390
498
|
<PageHeaderAction
|
|
391
|
-
{
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
confirmationConfig={{ onConfirmOpen: confirmToggleSpy }}
|
|
499
|
+
label={'action-label'}
|
|
500
|
+
actionType={PageHeaderActionType.Context}
|
|
501
|
+
onClick={spy}
|
|
395
502
|
/>,
|
|
396
503
|
);
|
|
397
504
|
|
|
398
|
-
|
|
399
|
-
wrapper.simulate('click');
|
|
400
|
-
});
|
|
401
|
-
wrapper.update();
|
|
402
|
-
|
|
403
|
-
await act(async () => {
|
|
404
|
-
await wrapper.simulate('mouseleave');
|
|
405
|
-
});
|
|
406
|
-
wrapper.update();
|
|
407
|
-
|
|
408
|
-
await act(async () => {
|
|
409
|
-
jest.runAllTimers();
|
|
410
|
-
});
|
|
411
|
-
wrapper.update();
|
|
505
|
+
const container = wrapper.find('.container');
|
|
412
506
|
|
|
413
|
-
expect(
|
|
414
|
-
expect(confirmToggleSpy).toHaveBeenNthCalledWith(1, true, {
|
|
415
|
-
mode: 'Simple',
|
|
416
|
-
});
|
|
417
|
-
expect(confirmToggleSpy).toHaveBeenNthCalledWith(2, false, {
|
|
418
|
-
mode: 'Simple',
|
|
419
|
-
});
|
|
507
|
+
expect(container.hasClass('context')).toBe(true);
|
|
420
508
|
});
|
|
421
509
|
|
|
422
|
-
it(`
|
|
423
|
-
const
|
|
424
|
-
|
|
510
|
+
it(`sets background color when actionType is 'Active'`, () => {
|
|
511
|
+
const spy = jest.fn();
|
|
425
512
|
const wrapper = mount(
|
|
426
513
|
<PageHeaderAction
|
|
427
|
-
{
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
confirmationConfig={{ onConfirmOpen: confirmToggleSpy }}
|
|
514
|
+
label={'action-label'}
|
|
515
|
+
actionType={PageHeaderActionType.Active}
|
|
516
|
+
onClick={spy}
|
|
431
517
|
/>,
|
|
432
518
|
);
|
|
433
519
|
|
|
434
|
-
|
|
435
|
-
act(() => {
|
|
436
|
-
wrapper.simulate('click');
|
|
437
|
-
});
|
|
438
|
-
wrapper.update();
|
|
439
|
-
|
|
440
|
-
const cancelButton = wrapper.find(TextButton).first();
|
|
520
|
+
const container = wrapper.find('.container');
|
|
441
521
|
|
|
442
|
-
|
|
443
|
-
cancelButton.simulate('click');
|
|
444
|
-
});
|
|
445
|
-
wrapper.update();
|
|
446
|
-
|
|
447
|
-
expect(confirmToggleSpy).toHaveBeenCalledTimes(2);
|
|
448
|
-
expect(confirmToggleSpy).toHaveBeenNthCalledWith(1, true, {
|
|
449
|
-
mode: 'Advanced',
|
|
450
|
-
});
|
|
451
|
-
expect(confirmToggleSpy).toHaveBeenNthCalledWith(2, false, {
|
|
452
|
-
mode: 'Advanced',
|
|
453
|
-
});
|
|
522
|
+
expect(container.hasClass('active')).toBe(true);
|
|
454
523
|
});
|
|
455
524
|
|
|
456
|
-
it(`
|
|
457
|
-
const
|
|
458
|
-
|
|
525
|
+
it(`disallows interactions when action is set to disabled`, () => {
|
|
526
|
+
const spy = jest.fn();
|
|
459
527
|
const wrapper = mount(
|
|
460
528
|
<PageHeaderAction
|
|
461
|
-
{
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
confirmationConfig={{ onConfirmOpen: confirmToggleSpy }}
|
|
529
|
+
label={'action-label'}
|
|
530
|
+
disabled={true}
|
|
531
|
+
onClick={spy}
|
|
465
532
|
/>,
|
|
466
533
|
);
|
|
467
534
|
|
|
468
|
-
|
|
469
|
-
act(() => {
|
|
470
|
-
wrapper.simulate('click');
|
|
471
|
-
});
|
|
472
|
-
wrapper.update();
|
|
473
|
-
|
|
474
|
-
const confirmButton = wrapper.find(TextButton).last();
|
|
535
|
+
const disabledAttribute = wrapper.find('.container').prop('disabled');
|
|
475
536
|
|
|
476
|
-
|
|
477
|
-
confirmButton.simulate('click');
|
|
478
|
-
});
|
|
479
|
-
wrapper.update();
|
|
537
|
+
wrapper.simulate('click');
|
|
480
538
|
|
|
481
|
-
expect(
|
|
482
|
-
expect(
|
|
483
|
-
mode: 'Advanced',
|
|
484
|
-
});
|
|
485
|
-
expect(confirmToggleSpy).toHaveBeenNthCalledWith(2, false, {
|
|
486
|
-
mode: 'Advanced',
|
|
487
|
-
});
|
|
539
|
+
expect(disabledAttribute).toBe(true);
|
|
540
|
+
expect(spy).not.toHaveBeenCalled();
|
|
488
541
|
});
|
|
489
542
|
});
|
|
490
543
|
|
|
491
|
-
|
|
492
|
-
const
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
actionType={PageHeaderActionType.Context}
|
|
497
|
-
onClick={spy}
|
|
498
|
-
/>,
|
|
499
|
-
);
|
|
544
|
+
describe('PageHeaderNavigationAction', () => {
|
|
545
|
+
const defaultProps = {
|
|
546
|
+
label: 'Action Label',
|
|
547
|
+
path: '/action-path',
|
|
548
|
+
};
|
|
500
549
|
|
|
501
|
-
|
|
550
|
+
it('renders the component without crashing', () => {
|
|
551
|
+
const wrapper = shallow(
|
|
552
|
+
<PageHeaderAction {...defaultProps} path="/test" />,
|
|
553
|
+
);
|
|
554
|
+
expect(wrapper).toBeTruthy();
|
|
555
|
+
});
|
|
502
556
|
|
|
503
|
-
|
|
504
|
-
|
|
557
|
+
it('renders a Link when path is provided', () => {
|
|
558
|
+
const wrapper = mount(
|
|
559
|
+
<Router>
|
|
560
|
+
<PageHeaderAction {...defaultProps} />
|
|
561
|
+
</Router>,
|
|
562
|
+
);
|
|
563
|
+
|
|
564
|
+
expect(wrapper.find(Link)).toHaveLength(1);
|
|
565
|
+
});
|
|
505
566
|
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
567
|
+
it('renders a label', () => {
|
|
568
|
+
const mockLabel = 'test-label';
|
|
569
|
+
const wrapper = mount(
|
|
570
|
+
<Router>
|
|
571
|
+
<PageHeaderAction {...defaultProps} label={mockLabel} path="/test" />
|
|
572
|
+
</Router>,
|
|
573
|
+
);
|
|
574
|
+
const label = wrapper.find('span');
|
|
575
|
+
expect(label.text()).toBe(mockLabel);
|
|
576
|
+
});
|
|
515
577
|
|
|
516
|
-
|
|
578
|
+
it('renders an icon, if set', () => {
|
|
579
|
+
const mockLabel = 'test-label';
|
|
580
|
+
const wrapper = mount(
|
|
581
|
+
<Router>
|
|
582
|
+
{' '}
|
|
583
|
+
<PageHeaderAction
|
|
584
|
+
{...defaultProps}
|
|
585
|
+
label={mockLabel}
|
|
586
|
+
icon={IconName.ChevronRight}
|
|
587
|
+
path="/test"
|
|
588
|
+
/>
|
|
589
|
+
</Router>,
|
|
590
|
+
);
|
|
591
|
+
const icon = wrapper.find('.icons');
|
|
592
|
+
expect(icon.exists()).toBe(true);
|
|
593
|
+
});
|
|
517
594
|
|
|
518
|
-
|
|
519
|
-
|
|
595
|
+
it('renders an image instead of icon if icon prop is a string', () => {
|
|
596
|
+
const mockLabel = 'test-label';
|
|
597
|
+
const wrapper = mount(
|
|
598
|
+
<Router>
|
|
599
|
+
<PageHeaderAction
|
|
600
|
+
{...defaultProps}
|
|
601
|
+
label={mockLabel}
|
|
602
|
+
icon="test"
|
|
603
|
+
imgAlt="alt"
|
|
604
|
+
path="/test"
|
|
605
|
+
/>
|
|
606
|
+
</Router>,
|
|
607
|
+
);
|
|
608
|
+
const icon = wrapper.find('.icons');
|
|
609
|
+
expect(icon.exists()).toBe(false);
|
|
610
|
+
const image = wrapper.find('img');
|
|
611
|
+
expect(image.exists()).toBe(true);
|
|
612
|
+
});
|
|
520
613
|
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
614
|
+
it('renders a link with correct path', () => {
|
|
615
|
+
const mockPath = '/test-path';
|
|
616
|
+
const wrapper = mount(
|
|
617
|
+
<Router>
|
|
618
|
+
<PageHeaderAction {...defaultProps} path={mockPath} />
|
|
619
|
+
</Router>,
|
|
620
|
+
);
|
|
621
|
+
const link = wrapper.find('Link');
|
|
622
|
+
expect(link.prop('to')).toBe(mockPath);
|
|
623
|
+
});
|
|
526
624
|
|
|
527
|
-
|
|
625
|
+
it('opens link in a new tab if openInNewTab is true', () => {
|
|
626
|
+
const wrapper = mount(
|
|
627
|
+
<Router>
|
|
628
|
+
<PageHeaderAction {...defaultProps} path="/test" openInNewTab />
|
|
629
|
+
</Router>,
|
|
630
|
+
);
|
|
631
|
+
const link = wrapper.find('a');
|
|
632
|
+
expect(link.prop('target')).toBe('_blank');
|
|
633
|
+
});
|
|
528
634
|
|
|
529
|
-
|
|
635
|
+
it('does not open link in a new tab if openInNewTab is false', () => {
|
|
636
|
+
const wrapper = mount(
|
|
637
|
+
<Router>
|
|
638
|
+
<PageHeaderAction
|
|
639
|
+
{...defaultProps}
|
|
640
|
+
path="/test"
|
|
641
|
+
openInNewTab={false}
|
|
642
|
+
/>
|
|
643
|
+
</Router>,
|
|
644
|
+
);
|
|
645
|
+
const link = wrapper.find('Link');
|
|
646
|
+
expect(link.prop('target')).toBeUndefined();
|
|
647
|
+
});
|
|
530
648
|
|
|
531
|
-
|
|
532
|
-
|
|
649
|
+
it('renders with disabled class if disabled prop is true', () => {
|
|
650
|
+
const wrapper = mount(
|
|
651
|
+
<Router>
|
|
652
|
+
<PageHeaderAction {...defaultProps} path="/test" disabled />
|
|
653
|
+
</Router>,
|
|
654
|
+
);
|
|
655
|
+
const container = wrapper.find('.container').hostNodes();
|
|
656
|
+
expect(container.hasClass('disabled')).toBe(true);
|
|
657
|
+
});
|
|
533
658
|
});
|
|
534
659
|
});
|
|
535
660
|
|