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