@patternfly/react-core 4.202.29 → 4.202.32
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/CHANGELOG.md +24 -0
- package/dist/esm/helpers/Popper/Popper.d.ts.map +1 -1
- package/dist/esm/helpers/Popper/Popper.js +1 -7
- package/dist/esm/helpers/Popper/Popper.js.map +1 -1
- package/dist/js/helpers/Popper/Popper.d.ts.map +1 -1
- package/dist/js/helpers/Popper/Popper.js +1 -7
- package/dist/js/helpers/Popper/Popper.js.map +1 -1
- package/dist/umd/react-core.js +1 -7
- package/package.json +5 -5
- package/src/components/Dropdown/__tests__/DropdownToggleCheckbox.test.tsx +1 -1
- package/src/components/Page/__tests__/Page.test.tsx +225 -205
- package/src/components/Page/__tests__/__snapshots__/Page.test.tsx.snap +1088 -2059
- package/src/components/Pagination/__tests__/Pagination.test.tsx +235 -283
- package/src/components/Pagination/__tests__/__snapshots__/Pagination.test.tsx.snap +143 -577
- package/src/components/Radio/__tests__/Radio.test.tsx +38 -44
- package/src/components/Radio/__tests__/__snapshots__/Radio.test.tsx.snap +30 -30
- package/src/components/SearchInput/__tests__/SearchInput.test.tsx +87 -68
- package/src/components/SearchInput/__tests__/__snapshots__/SearchInput.test.tsx.snap +230 -137
- package/src/components/Select/__tests__/Select.test.tsx +238 -195
- package/src/components/Select/__tests__/SelectToggle.test.tsx +68 -130
- package/src/components/Select/__tests__/__snapshots__/Select.test.tsx.snap +978 -2149
- package/src/components/Select/__tests__/__snapshots__/SelectToggle.test.tsx.snap +3 -3
- package/src/components/SimpleList/__tests__/SimpleList.test.tsx +29 -32
- package/src/components/SimpleList/__tests__/__snapshots__/SimpleList.test.tsx.snap +4 -366
- package/src/components/Switch/__tests__/Switch.test.tsx +85 -75
- package/src/components/Switch/__tests__/__snapshots__/Switch.test.tsx.snap +30 -40
- package/src/components/TextArea/__tests__/TextArea.test.tsx +98 -103
- package/src/components/TextArea/__tests__/__snapshots__/TextArea.test.tsx.snap +24 -103
- package/src/components/TextInput/__tests__/TextInput.test.tsx +71 -70
- package/src/components/TextInput/__tests__/__snapshots__/TextInput.test.tsx.snap +15 -103
- package/src/components/TextInputGroup/__tests__/TextInputGroup.test.tsx +65 -39
- package/src/components/TextInputGroup/__tests__/__snapshots__/TextInputGroup.test.tsx.snap +53 -14
- package/src/components/TimePicker/__tests__/TimePicker.test.tsx +113 -110
- package/src/components/Title/__tests__/Title.test.tsx +21 -20
- package/src/components/Title/__tests__/__snapshots__/Title.test.tsx.snap +24 -30
- package/src/components/ToggleGroup/__tests__/ToggleGroup.test.tsx +43 -39
- package/src/components/ToggleGroup/__tests__/__snapshots__/ToggleGroup.test.tsx.snap +20 -19
- package/src/components/Wizard/__tests__/Wizard.test.tsx +195 -189
- package/src/components/Wizard/__tests__/__snapshots__/Wizard.test.tsx.snap +131 -10
- package/src/helpers/Popper/Popper.tsx +5 -7
- package/src/helpers/__tests__/util.test.ts +113 -0
- package/src/layouts/Bullseye/__tests__/Bullseye.test.tsx +25 -25
- package/src/layouts/Bullseye/__tests__/__snapshots__/Bullseye.test.tsx.snap +3 -5
- package/src/layouts/Flex/__tests__/Flex.test.tsx +159 -96
- package/src/layouts/Flex/__tests__/__snapshots__/Flex.test.tsx.snap +9 -17
- package/src/components/Page/__tests__/Generated/Page.test.tsx +0 -28
- package/src/components/Page/__tests__/Generated/__snapshots__/Page.test.tsx.snap +0 -19
- package/src/components/Pagination/__tests__/Generated/Pagination.test.tsx +0 -58
- package/src/components/Pagination/__tests__/Generated/__snapshots__/Pagination.test.tsx.snap +0 -205
- package/src/components/Radio/__tests__/Generated/Radio.test.tsx +0 -29
- package/src/components/Radio/__tests__/Generated/__snapshots__/Radio.test.tsx.snap +0 -36
- package/src/components/Select/__tests__/Generated/Select.test.tsx +0 -49
- package/src/components/Select/__tests__/Generated/SelectToggle.test.tsx +0 -34
- package/src/components/Select/__tests__/Generated/__snapshots__/Select.test.tsx.snap +0 -48
- package/src/components/Select/__tests__/Generated/__snapshots__/SelectToggle.test.tsx.snap +0 -36
- package/src/components/SimpleList/__tests__/Generated/SimpleList.test.tsx +0 -22
- package/src/components/SimpleList/__tests__/Generated/__snapshots__/SimpleList.test.tsx.snap +0 -13
- package/src/components/Switch/__tests__/Generated/Switch.test.tsx +0 -24
- package/src/components/Switch/__tests__/Generated/__snapshots__/Switch.test.tsx.snap +0 -36
- package/src/components/TextArea/__tests__/Generated/TextArea.test.tsx +0 -23
- package/src/components/TextArea/__tests__/Generated/__snapshots__/TextArea.test.tsx.snap +0 -13
- package/src/components/Title/__tests__/Generated/Title.test.tsx +0 -13
- package/src/components/Title/__tests__/Generated/__snapshots__/Title.test.tsx.snap +0 -12
- package/src/helpers/__tests__/util.test.js +0 -235
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { mount } from 'enzyme';
|
|
3
|
-
import { ApplicationLauncher, DropdownItem, Dropdown, DropdownToggle } from '@patternfly/react-core';
|
|
4
|
-
import {
|
|
5
|
-
capitalize,
|
|
6
|
-
getUniqueId,
|
|
7
|
-
debounce,
|
|
8
|
-
isElementInView,
|
|
9
|
-
sideElementIsOutOfView,
|
|
10
|
-
fillTemplate,
|
|
11
|
-
pluralize,
|
|
12
|
-
formatBreakpointMods
|
|
13
|
-
} from '../util';
|
|
14
|
-
import { KEY_CODES, SIDE } from '../constants';
|
|
15
|
-
import styles from '@patternfly/react-styles/css/layouts/Flex/flex';
|
|
16
|
-
|
|
17
|
-
const createMockHtmlElement = bounds => ({
|
|
18
|
-
getBoundingClientRect: () => bounds
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
test('capitalize', () => {
|
|
22
|
-
expect(capitalize('foo')).toBe('Foo');
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
test('getUniqueId', () => {
|
|
26
|
-
expect(getUniqueId()).not.toBe(getUniqueId());
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
test('getUniqueId prefixed', () => {
|
|
30
|
-
expect(getUniqueId().substring(0, 3)).toBe('pf-');
|
|
31
|
-
expect(getUniqueId('pf-switch').substring(0, 10)).toBe('pf-switch-');
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
test('debounce', () => {
|
|
35
|
-
jest.useFakeTimers();
|
|
36
|
-
const callback = jest.fn();
|
|
37
|
-
const debouncedFunction = debounce(callback, 50);
|
|
38
|
-
|
|
39
|
-
debouncedFunction();
|
|
40
|
-
// At this point in time, the callback should not have been called yet
|
|
41
|
-
expect(callback).toHaveBeenCalledTimes(0);
|
|
42
|
-
|
|
43
|
-
for (let i = 0; i < 10; i++) {
|
|
44
|
-
jest.advanceTimersByTime(50);
|
|
45
|
-
debouncedFunction();
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
expect(callback).toBeCalledTimes(10);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
test('isElementInView should be true when partial out of view and with partial true', () => {
|
|
52
|
-
const container = createMockHtmlElement({ left: 0, right: 200 });
|
|
53
|
-
const element = createMockHtmlElement({ left: 10, right: 210 });
|
|
54
|
-
expect(isElementInView(container, element, true)).toBe(true);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
test('isElementInView should be false when partial out of view and with partial false ', () => {
|
|
58
|
-
const container = createMockHtmlElement({ left: 0, right: 200 });
|
|
59
|
-
const element = createMockHtmlElement({ left: 10, right: 210 });
|
|
60
|
-
expect(isElementInView(container, element, false)).toBe(false);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
test('isElementInView should be false completely out of view ', () => {
|
|
64
|
-
const container = createMockHtmlElement({ left: 0, right: 200 });
|
|
65
|
-
const element = createMockHtmlElement({ left: 200, right: 300 });
|
|
66
|
-
expect(isElementInView(container, element, true)).toBe(false);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
test('isElementInView should be false completely out of view when partial false ', () => {
|
|
70
|
-
const container = createMockHtmlElement({ left: 0, right: 200 });
|
|
71
|
-
const element = createMockHtmlElement({ left: 200, right: 300 });
|
|
72
|
-
expect(isElementInView(container, element, false)).toBe(false);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
test('sideElementIsOutOfView Returns left when off on left side', () => {
|
|
76
|
-
const container = createMockHtmlElement({ left: 20, right: 220 });
|
|
77
|
-
const element = createMockHtmlElement({ left: 10, right: 210 });
|
|
78
|
-
expect(sideElementIsOutOfView(container, element)).toBe(SIDE.LEFT);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
test('sideElementIsOutOfView Returns right when off on right side', () => {
|
|
82
|
-
const container = createMockHtmlElement({ left: 0, right: 200 });
|
|
83
|
-
const element = createMockHtmlElement({ left: 210, right: 410 });
|
|
84
|
-
expect(sideElementIsOutOfView(container, element)).toBe(SIDE.RIGHT);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
test('sideElementIsOutOfView Returns NONE when in view', () => {
|
|
88
|
-
const container = createMockHtmlElement({ left: 0, right: 200 });
|
|
89
|
-
const element = createMockHtmlElement({ left: 10, right: 110 });
|
|
90
|
-
expect(sideElementIsOutOfView(container, element)).toBe(SIDE.NONE);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
xdescribe('keyHandler works on ApplicationLauncher', () => {
|
|
94
|
-
document.body.innerHTML = '<!doctype html><html><body></body></html>';
|
|
95
|
-
const dropdownItems = [
|
|
96
|
-
<DropdownItem key=" 1" id="first" componentID="first-button" component="button">
|
|
97
|
-
Action 1
|
|
98
|
-
</DropdownItem>,
|
|
99
|
-
<DropdownItem key="2" id="second" componentID="second-button" component="button">
|
|
100
|
-
Action 2
|
|
101
|
-
</DropdownItem>,
|
|
102
|
-
<DropdownItem key="3" id="third" componentID="third-button" component="button" isDisabled>
|
|
103
|
-
Disabled Link
|
|
104
|
-
</DropdownItem>
|
|
105
|
-
];
|
|
106
|
-
|
|
107
|
-
const view = mount(<ApplicationLauncher items={dropdownItems} isOpen />, {
|
|
108
|
-
attachTo: document.getElementsByName('div')[0]
|
|
109
|
-
});
|
|
110
|
-
const firstDropdownItem = view.find('#first button').first();
|
|
111
|
-
const secondDropdownItem = view.find('#second button').first();
|
|
112
|
-
|
|
113
|
-
test('keyHandler advances forward', () => {
|
|
114
|
-
firstDropdownItem.simulate('keydown', {
|
|
115
|
-
key: 'ArrowDown',
|
|
116
|
-
keyCode: KEY_CODES.ARROW_DOWN,
|
|
117
|
-
which: KEY_CODES.ARROW_DOWN
|
|
118
|
-
});
|
|
119
|
-
const focusedElement = document.activeElement;
|
|
120
|
-
console.log(focusedElement);
|
|
121
|
-
expect(focusedElement.getAttribute('id')).toEqual('second-button');
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
test('keyHandler regresses backward', () => {
|
|
125
|
-
secondDropdownItem.simulate('keydown', {
|
|
126
|
-
key: 'ArrowUp',
|
|
127
|
-
keyCode: KEY_CODES.ARROW_UP,
|
|
128
|
-
which: KEY_CODES.ARROW_UP
|
|
129
|
-
});
|
|
130
|
-
const focusedElement = document.activeElement;
|
|
131
|
-
expect(focusedElement.getAttribute('id')).toEqual('first-button');
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
test('keyHandler loops top to bottom', () => {
|
|
135
|
-
firstDropdownItem.simulate('keydown', {
|
|
136
|
-
key: 'ArrowUp',
|
|
137
|
-
keyCode: KEY_CODES.ARROW_UP,
|
|
138
|
-
which: KEY_CODES.ARROW_UP
|
|
139
|
-
});
|
|
140
|
-
const focusedElement = document.activeElement;
|
|
141
|
-
expect(focusedElement.getAttribute('id')).toEqual('third-button');
|
|
142
|
-
});
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
xdescribe('keyHandler works on Dropdown', () => {
|
|
146
|
-
document.body.innerHTML = '<!doctype html><html><body></body></html>';
|
|
147
|
-
const dropdownItems = [
|
|
148
|
-
<DropdownItem key="1" id="first" componentID="first-button" component="button">
|
|
149
|
-
Action 1
|
|
150
|
-
</DropdownItem>,
|
|
151
|
-
<DropdownItem key="2" id="second" componentID="second-button" component="button">
|
|
152
|
-
Action 2
|
|
153
|
-
</DropdownItem>,
|
|
154
|
-
<DropdownItem key="3" id="third" componentID="third-button" component="button" isDisabled>
|
|
155
|
-
Disabled Link
|
|
156
|
-
</DropdownItem>
|
|
157
|
-
];
|
|
158
|
-
const view = mount(
|
|
159
|
-
<Dropdown dropdownItems={dropdownItems} isOpen toggle={<DropdownToggle>Expanded Dropdown</DropdownToggle>} />,
|
|
160
|
-
{
|
|
161
|
-
attachTo: document.getElementsByName('div')[0]
|
|
162
|
-
}
|
|
163
|
-
);
|
|
164
|
-
const firstDropdownItem = view.find('#first button').first();
|
|
165
|
-
const secondDropdownItem = view.find('#second button').first();
|
|
166
|
-
const thirdDropdownItem = view.find('#third button').first();
|
|
167
|
-
|
|
168
|
-
test('keyHandler advances forward', () => {
|
|
169
|
-
firstDropdownItem.simulate('keydown', {
|
|
170
|
-
key: 'ArrowDown',
|
|
171
|
-
keyCode: KEY_CODES.ARROW_DOWN,
|
|
172
|
-
which: KEY_CODES.ARROW_DOWN
|
|
173
|
-
});
|
|
174
|
-
const focusedElement = document.activeElement;
|
|
175
|
-
expect(focusedElement.getAttribute('id')).toEqual('second-button');
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
test('keyHandler regresses backward', () => {
|
|
179
|
-
secondDropdownItem.simulate('keydown', {
|
|
180
|
-
key: 'ArrowUp',
|
|
181
|
-
keyCode: KEY_CODES.ARROW_UP,
|
|
182
|
-
which: KEY_CODES.ARROW_UP
|
|
183
|
-
});
|
|
184
|
-
const focusedElement = document.activeElement;
|
|
185
|
-
expect(focusedElement.getAttribute('id')).toEqual('first-button');
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
test('keyHandler loops top to bottom', () => {
|
|
189
|
-
firstDropdownItem.simulate('keydown', {
|
|
190
|
-
key: 'ArrowUp',
|
|
191
|
-
keyCode: KEY_CODES.ARROW_UP,
|
|
192
|
-
which: KEY_CODES.ARROW_UP
|
|
193
|
-
});
|
|
194
|
-
const focusedElement = document.activeElement;
|
|
195
|
-
expect(focusedElement.getAttribute('id')).toEqual('third-button');
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
test('keyHandler loops down to top', () => {
|
|
199
|
-
thirdDropdownItem.simulate('keydown', {
|
|
200
|
-
key: 'ArrowDown',
|
|
201
|
-
keyCode: KEY_CODES.ARROW_DOWN,
|
|
202
|
-
which: KEY_CODES.ARROW_DOWN
|
|
203
|
-
});
|
|
204
|
-
const focusedElement = document.activeElement;
|
|
205
|
-
expect(focusedElement.getAttribute('id')).toEqual('first-button');
|
|
206
|
-
});
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
test('fillTemplate interpolates strings correctly', () => {
|
|
210
|
-
// eslint-disable-next-line no-template-curly-in-string
|
|
211
|
-
const templateString = 'My name is ${firstName} ${lastName}';
|
|
212
|
-
const expected = 'My name is Jon Dough';
|
|
213
|
-
const templatVars = {
|
|
214
|
-
firstName: 'Jon',
|
|
215
|
-
lastName: 'Dough'
|
|
216
|
-
};
|
|
217
|
-
const actual = fillTemplate(templateString, templatVars);
|
|
218
|
-
expect(actual).toEqual(expected);
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
test('text pluralize', () => {
|
|
222
|
-
expect(pluralize(1, 'dog')).toEqual('1 dog');
|
|
223
|
-
expect(pluralize(2, 'dog')).toEqual('2 dogs');
|
|
224
|
-
expect(pluralize(2, 'finch', 'finches')).toEqual('2 finches');
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
test('formatBreakpointMods', () => {
|
|
228
|
-
expect(formatBreakpointMods({ default: 'spacerNone' }, styles)).toEqual('pf-m-spacer-none');
|
|
229
|
-
expect(formatBreakpointMods({ md: 'spacerNone' }, styles)).toEqual(
|
|
230
|
-
'pf-m-spacer-none-on-md'
|
|
231
|
-
);
|
|
232
|
-
expect(formatBreakpointMods({ default: 'column', lg: 'row' }, styles)).toEqual(
|
|
233
|
-
'pf-m-column pf-m-row-on-lg'
|
|
234
|
-
);
|
|
235
|
-
});
|