@patternfly/react-core 4.202.28 → 4.202.31
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/components/JumpLinks/JumpLinksItem.d.ts.map +1 -1
- package/dist/esm/components/JumpLinks/JumpLinksItem.js +1 -1
- package/dist/esm/components/JumpLinks/JumpLinksItem.js.map +1 -1
- package/dist/esm/components/ProgressStepper/ProgressStep.d.ts +3 -0
- package/dist/esm/components/ProgressStepper/ProgressStep.d.ts.map +1 -1
- package/dist/esm/components/ProgressStepper/ProgressStep.js +2 -2
- package/dist/esm/components/ProgressStepper/ProgressStep.js.map +1 -1
- package/dist/esm/components/Tabs/Tab.d.ts.map +1 -1
- package/dist/esm/components/Tabs/Tab.js +2 -2
- package/dist/esm/components/Tabs/Tab.js.map +1 -1
- package/dist/esm/components/Tabs/Tabs.d.ts +1 -1
- package/dist/esm/components/Tabs/Tabs.d.ts.map +1 -1
- package/dist/esm/components/Tabs/Tabs.js +1 -1
- package/dist/esm/components/Tabs/Tabs.js.map +1 -1
- 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/components/JumpLinks/JumpLinksItem.d.ts.map +1 -1
- package/dist/js/components/JumpLinks/JumpLinksItem.js +1 -1
- package/dist/js/components/JumpLinks/JumpLinksItem.js.map +1 -1
- package/dist/js/components/ProgressStepper/ProgressStep.d.ts +3 -0
- package/dist/js/components/ProgressStepper/ProgressStep.d.ts.map +1 -1
- package/dist/js/components/ProgressStepper/ProgressStep.js +2 -2
- package/dist/js/components/ProgressStepper/ProgressStep.js.map +1 -1
- package/dist/js/components/Tabs/Tab.d.ts.map +1 -1
- package/dist/js/components/Tabs/Tab.js +2 -2
- package/dist/js/components/Tabs/Tab.js.map +1 -1
- package/dist/js/components/Tabs/Tabs.d.ts +1 -1
- package/dist/js/components/Tabs/Tabs.d.ts.map +1 -1
- package/dist/js/components/Tabs/Tabs.js +1 -1
- package/dist/js/components/Tabs/Tabs.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 +7 -13
- package/dist/umd/react-core.min.js +1 -1
- package/package.json +5 -5
- package/src/components/Dropdown/__tests__/DropdownToggleCheckbox.test.tsx +1 -1
- package/src/components/ExpandableSection/examples/ExpandableSection.md +1 -1
- package/src/components/JumpLinks/JumpLinksItem.tsx +5 -1
- package/src/components/JumpLinks/__tests__/__snapshots__/JumpLinks.test.tsx.snap +5 -0
- 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/ProgressStepper/ProgressStep.tsx +6 -0
- package/src/components/ProgressStepper/__tests__/__snapshots__/ProgressStepper.test.tsx.snap +1 -0
- package/src/components/ProgressStepper/examples/ProgressStepper.md +9 -9
- 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/Tabs/Tab.tsx +6 -1
- package/src/components/Tabs/Tabs.tsx +2 -2
- package/src/components/Tabs/__tests__/Generated/__snapshots__/Tabs.test.tsx.snap +1 -0
- package/src/components/Tabs/__tests__/__snapshots__/Tab.test.tsx.snap +3 -0
- package/src/components/Tabs/__tests__/__snapshots__/Tabs.test.tsx.snap +135 -0
- package/src/components/Tabs/examples/Tabs.md +32 -26
- 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,7 +1,7 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`TextInputGroup gets custom class and id 1`] = `
|
|
4
|
-
<
|
|
4
|
+
<DocumentFragment>
|
|
5
5
|
<div
|
|
6
6
|
class="pf-c-text-input-group custom-class"
|
|
7
7
|
id="test-id"
|
|
@@ -25,11 +25,11 @@ exports[`TextInputGroup gets custom class and id 1`] = `
|
|
|
25
25
|
class="pf-c-text-input-group__utilities"
|
|
26
26
|
/>
|
|
27
27
|
</div>
|
|
28
|
-
</
|
|
28
|
+
</DocumentFragment>
|
|
29
29
|
`;
|
|
30
30
|
|
|
31
31
|
exports[`TextInputGroup renders content 1`] = `
|
|
32
|
-
<
|
|
32
|
+
<DocumentFragment>
|
|
33
33
|
<div
|
|
34
34
|
class="pf-c-text-input-group"
|
|
35
35
|
>
|
|
@@ -52,11 +52,11 @@ exports[`TextInputGroup renders content 1`] = `
|
|
|
52
52
|
class="pf-c-text-input-group__utilities"
|
|
53
53
|
/>
|
|
54
54
|
</div>
|
|
55
|
-
</
|
|
55
|
+
</DocumentFragment>
|
|
56
56
|
`;
|
|
57
57
|
|
|
58
58
|
exports[`TextInputGroup renders with the proper stying when disabled 1`] = `
|
|
59
|
-
<
|
|
59
|
+
<DocumentFragment>
|
|
60
60
|
<div
|
|
61
61
|
class="pf-c-text-input-group pf-m-disabled"
|
|
62
62
|
>
|
|
@@ -80,11 +80,50 @@ exports[`TextInputGroup renders with the proper stying when disabled 1`] = `
|
|
|
80
80
|
class="pf-c-text-input-group__utilities"
|
|
81
81
|
/>
|
|
82
82
|
</div>
|
|
83
|
-
</
|
|
83
|
+
</DocumentFragment>
|
|
84
|
+
`;
|
|
85
|
+
|
|
86
|
+
exports[`TextInputGroupMain input is disabled when TextInputGroupContext isDisabled is true 1`] = `
|
|
87
|
+
<DocumentFragment>
|
|
88
|
+
<div
|
|
89
|
+
class="pf-c-text-input-group__main"
|
|
90
|
+
>
|
|
91
|
+
<span
|
|
92
|
+
class="pf-c-text-input-group__text"
|
|
93
|
+
>
|
|
94
|
+
<input
|
|
95
|
+
aria-label="Type to filter"
|
|
96
|
+
class="pf-c-text-input-group__text-input"
|
|
97
|
+
disabled=""
|
|
98
|
+
type="text"
|
|
99
|
+
value=""
|
|
100
|
+
/>
|
|
101
|
+
</span>
|
|
102
|
+
</div>
|
|
103
|
+
</DocumentFragment>
|
|
104
|
+
`;
|
|
105
|
+
|
|
106
|
+
exports[`TextInputGroupMain input is not disabled when TextInputGroupContext isDisabled is false 1`] = `
|
|
107
|
+
<DocumentFragment>
|
|
108
|
+
<div
|
|
109
|
+
class="pf-c-text-input-group__main"
|
|
110
|
+
>
|
|
111
|
+
<span
|
|
112
|
+
class="pf-c-text-input-group__text"
|
|
113
|
+
>
|
|
114
|
+
<input
|
|
115
|
+
aria-label="Type to filter"
|
|
116
|
+
class="pf-c-text-input-group__text-input"
|
|
117
|
+
type="text"
|
|
118
|
+
value=""
|
|
119
|
+
/>
|
|
120
|
+
</span>
|
|
121
|
+
</div>
|
|
122
|
+
</DocumentFragment>
|
|
84
123
|
`;
|
|
85
124
|
|
|
86
125
|
exports[`TextInputGroupMain renders content 1`] = `
|
|
87
|
-
<
|
|
126
|
+
<DocumentFragment>
|
|
88
127
|
<div
|
|
89
128
|
class="pf-c-text-input-group__main"
|
|
90
129
|
>
|
|
@@ -100,11 +139,11 @@ exports[`TextInputGroupMain renders content 1`] = `
|
|
|
100
139
|
/>
|
|
101
140
|
</span>
|
|
102
141
|
</div>
|
|
103
|
-
</
|
|
142
|
+
</DocumentFragment>
|
|
104
143
|
`;
|
|
105
144
|
|
|
106
145
|
exports[`TextInputGroupMain renders given input icon props 1`] = `
|
|
107
|
-
<
|
|
146
|
+
<DocumentFragment>
|
|
108
147
|
<div
|
|
109
148
|
class="pf-c-text-input-group__main pf-m-icon"
|
|
110
149
|
>
|
|
@@ -137,11 +176,11 @@ exports[`TextInputGroupMain renders given input icon props 1`] = `
|
|
|
137
176
|
/>
|
|
138
177
|
</span>
|
|
139
178
|
</div>
|
|
140
|
-
</
|
|
179
|
+
</DocumentFragment>
|
|
141
180
|
`;
|
|
142
181
|
|
|
143
182
|
exports[`TextInputGroupMain renders the input with custom aria label when given 1`] = `
|
|
144
|
-
<
|
|
183
|
+
<DocumentFragment>
|
|
145
184
|
<div
|
|
146
185
|
class="pf-c-text-input-group__main"
|
|
147
186
|
>
|
|
@@ -157,11 +196,11 @@ exports[`TextInputGroupMain renders the input with custom aria label when given
|
|
|
157
196
|
/>
|
|
158
197
|
</span>
|
|
159
198
|
</div>
|
|
160
|
-
</
|
|
199
|
+
</DocumentFragment>
|
|
161
200
|
`;
|
|
162
201
|
|
|
163
202
|
exports[`TextInputGroupUtilities renders the content 1`] = `
|
|
164
|
-
<
|
|
203
|
+
<DocumentFragment>
|
|
165
204
|
<div
|
|
166
205
|
class="pf-c-text-input-group__utilities"
|
|
167
206
|
>
|
|
@@ -169,5 +208,5 @@ exports[`TextInputGroupUtilities renders the content 1`] = `
|
|
|
169
208
|
Foo
|
|
170
209
|
</button>
|
|
171
210
|
</div>
|
|
172
|
-
</
|
|
211
|
+
</DocumentFragment>
|
|
173
212
|
`;
|
|
@@ -1,139 +1,142 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { render } from '@testing-library/react';
|
|
3
|
-
import { mount } from 'enzyme';
|
|
4
|
-
import { act } from 'react-dom/test-utils';
|
|
5
|
-
import { TimePicker } from '../TimePicker'
|
|
6
2
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
4
|
+
import userEvent from '@testing-library/user-event';
|
|
5
|
+
import '@testing-library/jest-dom';
|
|
10
6
|
|
|
11
|
-
|
|
12
|
-
currentTarget: { value: inputProps.value }
|
|
13
|
-
};
|
|
14
|
-
const view = mount(<TimePicker onChange={onChange} {...inputProps} aria-label="time picker" />);
|
|
15
|
-
|
|
16
|
-
act(() => {
|
|
17
|
-
view.find('input').prop('onChange')(event);
|
|
18
|
-
})
|
|
19
|
-
expect(onChange).toBeCalledWith(inputProps.value, expects.hour, expects.minutes, expects.seconds, true);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
test('should return the correct value using the AM/PM pattern - midnight', () => {
|
|
23
|
-
testOnChange({ inputProps: { value: "12:00 AM", is24Hour: false }, expects: { hour: 0, minutes: 0, seconds: null }})
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
test('should return the correct value using the AM/PM pattern - midday', () => {
|
|
27
|
-
testOnChange({ inputProps: { value: "12:35 PM", is24Hour: false }, expects: { hour: 12, minutes: 35, seconds: null }})
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
test('should return the correct value using the AM/PM pattern - last minute of the day', () => {
|
|
31
|
-
testOnChange({ inputProps: { value: "11:59 PM", is24Hour: false }, expects: { hour: 23, minutes: 59, seconds: null }})
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
test('should return the correct value using the 24h pattern - midnight', () => {
|
|
35
|
-
testOnChange({ inputProps: { value: "00:00:00", is24Hour: true, includeSeconds: true }, expects: { hour: 0, minutes: 0, seconds: 0 }})
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
test('should return the correct value using the 24h pattern - midday', () => {
|
|
39
|
-
testOnChange({ inputProps: { value: "12:35", is24Hour: false }, expects: { hour: 12, minutes: 35, seconds: null }})
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
test('should return the correct value using the 24h pattern - last minute of the day', () => {
|
|
43
|
-
testOnChange({ inputProps: { value: "23:59", is24Hour: true }, expects: { hour: 23, minutes: 59, seconds: null }})
|
|
44
|
-
})
|
|
45
|
-
})
|
|
7
|
+
import { TimePicker } from '../TimePicker';
|
|
46
8
|
|
|
47
|
-
describe('
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
9
|
+
describe('TimePicker', () => {
|
|
10
|
+
describe('test timepicker onChange method with valid values', () => {
|
|
11
|
+
const testOnChange = ({ inputProps, expects }) => {
|
|
12
|
+
const onChange = jest.fn();
|
|
13
|
+
render(<TimePicker onChange={onChange} {...inputProps} aria-label="time picker" />);
|
|
52
14
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
expect(view.find('.pf-m-error')).toHaveLength(0);
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
test('should stay valid after onChange', () => {
|
|
59
|
-
const validateTime = (time: string) => {
|
|
60
|
-
return true;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const event: any = {
|
|
64
|
-
currentTarget: { value: "01:00" }
|
|
15
|
+
userEvent.type(screen.getByLabelText('time picker'), inputProps.value);
|
|
16
|
+
expect(onChange).toBeCalledWith(inputProps.value, expects.hour, expects.minutes, expects.seconds, true);
|
|
65
17
|
};
|
|
66
|
-
const view = mount(<TimePicker value={"00:00"} validateTime={validateTime} aria-label="time picker" />);
|
|
67
18
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
19
|
+
test('should return the correct value using the AM/PM pattern - midnight', () => {
|
|
20
|
+
testOnChange({
|
|
21
|
+
inputProps: { value: '12:00 AM', is24Hour: false },
|
|
22
|
+
expects: { hour: 0, minutes: 0, seconds: null }
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test('should return the correct value using the AM/PM pattern - midday', () => {
|
|
27
|
+
testOnChange({
|
|
28
|
+
inputProps: { value: '12:35 PM', is24Hour: false },
|
|
29
|
+
expects: { hour: 12, minutes: 35, seconds: null }
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test('should return the correct value using the AM/PM pattern - last minute of the day', () => {
|
|
34
|
+
testOnChange({
|
|
35
|
+
inputProps: { value: '11:59 PM', is24Hour: false },
|
|
36
|
+
expects: { hour: 23, minutes: 59, seconds: null }
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test('should return the correct value using the 24h pattern - midnight', () => {
|
|
41
|
+
testOnChange({
|
|
42
|
+
inputProps: { value: '00:00:00', is24Hour: true, includeSeconds: true },
|
|
43
|
+
expects: { hour: 0, minutes: 0, seconds: 0 }
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test('should return the correct value using the 24h pattern - midday', () => {
|
|
48
|
+
testOnChange({
|
|
49
|
+
inputProps: { value: '12:35', is24Hour: false },
|
|
50
|
+
expects: { hour: 12, minutes: 35, seconds: null }
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test('should return the correct value using the 24h pattern - last minute of the day', () => {
|
|
55
|
+
testOnChange({
|
|
56
|
+
inputProps: { value: '23:59', is24Hour: true },
|
|
57
|
+
expects: { hour: 23, minutes: 59, seconds: null }
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
});
|
|
72
61
|
|
|
73
|
-
|
|
74
|
-
|
|
62
|
+
describe('test isInvalid', () => {
|
|
63
|
+
test('should be valid by default', () => {
|
|
64
|
+
const validateTime = (_time: string) => {
|
|
65
|
+
return true;
|
|
66
|
+
};
|
|
75
67
|
|
|
76
|
-
|
|
77
|
-
const validateTime = (time: string) => {
|
|
78
|
-
return false;
|
|
79
|
-
}
|
|
68
|
+
render(<TimePicker value={'00:00'} validateTime={validateTime} aria-label="time picker" />);
|
|
80
69
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
};
|
|
84
|
-
const view = mount(<TimePicker value={"00:00"} validateTime={validateTime} aria-label="time picker" />);
|
|
70
|
+
expect(screen.getByLabelText('time picker')).not.toHaveClass('pf-m-error');
|
|
71
|
+
});
|
|
85
72
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
73
|
+
test('should stay valid after onChange', () => {
|
|
74
|
+
const validateTime = (_time: string) => {
|
|
75
|
+
return true;
|
|
76
|
+
};
|
|
90
77
|
|
|
91
|
-
|
|
78
|
+
render(<TimePicker value="00:00" validateTime={validateTime} aria-label="time picker" />);
|
|
92
79
|
|
|
93
|
-
|
|
80
|
+
const input = screen.getByLabelText('time picker');
|
|
94
81
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
})
|
|
82
|
+
userEvent.type(input, '01:00');
|
|
83
|
+
expect(input).not.toHaveClass('pf-m-error');
|
|
84
|
+
});
|
|
98
85
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
includeSeconds: true
|
|
104
|
-
};
|
|
86
|
+
test('should be invalid after onBlur', async () => {
|
|
87
|
+
const validateTime = (_time: string) => {
|
|
88
|
+
return false;
|
|
89
|
+
};
|
|
105
90
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
91
|
+
render(
|
|
92
|
+
<>
|
|
93
|
+
<div>Other element</div>
|
|
94
|
+
<TimePicker value={'00:00'} validateTime={validateTime} aria-label="time picker" />
|
|
95
|
+
</>
|
|
96
|
+
);
|
|
109
97
|
|
|
110
|
-
|
|
111
|
-
|
|
98
|
+
userEvent.type(screen.getByLabelText('time picker'), '01:00');
|
|
99
|
+
expect(screen.queryByText('Invalid time format')).toBeNull();
|
|
112
100
|
|
|
113
|
-
|
|
101
|
+
userEvent.click(screen.getByText('Other element'));
|
|
102
|
+
expect(screen.getByText('Invalid time format')).toBeInTheDocument();
|
|
103
|
+
});
|
|
114
104
|
});
|
|
115
105
|
|
|
116
|
-
|
|
117
|
-
const
|
|
118
|
-
|
|
106
|
+
describe('test includeSeconds', () => {
|
|
107
|
+
const baseProps = {
|
|
108
|
+
'aria-label': 'time picker',
|
|
109
|
+
value: '12:00 PM',
|
|
110
|
+
includeSeconds: true
|
|
111
|
+
};
|
|
119
112
|
|
|
120
|
-
|
|
121
|
-
|
|
113
|
+
it('should be valid still with a max value of "11:59:59 PM" by default', () => {
|
|
114
|
+
render(<TimePicker {...baseProps} />);
|
|
122
115
|
|
|
123
|
-
|
|
124
|
-
|
|
116
|
+
userEvent.type(screen.getByLabelText(baseProps['aria-label']), '11:59:59 PM');
|
|
117
|
+
expect(screen.queryByText('Invalid time format')).toBeNull();
|
|
118
|
+
});
|
|
125
119
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
const view = mount(<TimePicker {...baseProps} value="20:00" is24Hour />);
|
|
120
|
+
it('should be valid still with a max value of "23:59:59" by default when using 24 hour time', () => {
|
|
121
|
+
render(<TimePicker {...baseProps} value="20:00" is24Hour />);
|
|
129
122
|
|
|
130
|
-
|
|
131
|
-
|
|
123
|
+
userEvent.type(screen.getByLabelText(baseProps['aria-label']), '23:59:59');
|
|
124
|
+
expect(screen.queryByText('Invalid time format')).toBeNull();
|
|
125
|
+
});
|
|
132
126
|
|
|
133
|
-
|
|
127
|
+
it('should be invalid with a max value of "24:00:00" by default', () => {
|
|
128
|
+
render(
|
|
129
|
+
<>
|
|
130
|
+
<div>Other element</div>
|
|
131
|
+
<TimePicker {...baseProps} value="20:00" is24Hour />
|
|
132
|
+
</>
|
|
133
|
+
);
|
|
134
134
|
|
|
135
|
-
|
|
135
|
+
userEvent.type(screen.getByLabelText(baseProps['aria-label']), '24:00:00');
|
|
136
|
+
expect(screen.queryByText('Invalid time format')).toBeNull();
|
|
136
137
|
|
|
137
|
-
|
|
138
|
+
userEvent.click(screen.getByText('Other element'));
|
|
139
|
+
expect(screen.getByText('Invalid time format')).toBeInTheDocument();
|
|
140
|
+
});
|
|
138
141
|
});
|
|
139
142
|
});
|
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
import {
|
|
2
|
+
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
4
|
+
import '@testing-library/jest-dom';
|
|
5
|
+
|
|
4
6
|
import { Title, TitleSizes } from '..';
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
{size}
|
|
8
|
+
describe('Title', () => {
|
|
9
|
+
Object.values(TitleSizes).forEach(size => {
|
|
10
|
+
test(`${size} Title`, () => {
|
|
11
|
+
const { asFragment } = render(
|
|
12
|
+
<Title size={size} headingLevel="h1">
|
|
13
|
+
{size} Title
|
|
14
|
+
</Title>
|
|
15
|
+
);
|
|
16
|
+
expect(asFragment()).toMatchSnapshot();
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test('Heading level can be set using a string value', () => {
|
|
21
|
+
render(
|
|
22
|
+
<Title size="lg" headingLevel="h3">
|
|
23
|
+
H3 Heading
|
|
11
24
|
</Title>
|
|
12
25
|
);
|
|
13
|
-
expect(
|
|
26
|
+
expect(screen.getByRole('heading').parentElement.querySelector('h3')).toBeInTheDocument();
|
|
14
27
|
});
|
|
15
28
|
});
|
|
16
|
-
|
|
17
|
-
test('Heading level can be set using a string value', () => {
|
|
18
|
-
const view = shallow(
|
|
19
|
-
<Title size="lg" headingLevel="h3">
|
|
20
|
-
H3 Heading
|
|
21
|
-
</Title>
|
|
22
|
-
);
|
|
23
|
-
const isH3 = view.find('h3').length === 1;
|
|
24
|
-
const isH1 = view.find('h1').length === 1;
|
|
25
|
-
expect(isH1).toBe(false);
|
|
26
|
-
expect(isH3).toBe(true);
|
|
27
|
-
});
|
|
@@ -1,85 +1,79 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`2xl Title 1`] = `
|
|
4
|
-
<
|
|
3
|
+
exports[`Title 2xl Title 1`] = `
|
|
4
|
+
<DocumentFragment>
|
|
5
5
|
<h1
|
|
6
6
|
class="pf-c-title pf-m-2xl"
|
|
7
7
|
data-ouia-component-id="OUIA-Generated-Title-4"
|
|
8
8
|
data-ouia-component-type="PF4/Title"
|
|
9
9
|
data-ouia-safe="true"
|
|
10
10
|
>
|
|
11
|
-
2xl
|
|
12
|
-
Title
|
|
11
|
+
2xl Title
|
|
13
12
|
</h1>
|
|
14
|
-
</
|
|
13
|
+
</DocumentFragment>
|
|
15
14
|
`;
|
|
16
15
|
|
|
17
|
-
exports[`3xl Title 1`] = `
|
|
18
|
-
<
|
|
16
|
+
exports[`Title 3xl Title 1`] = `
|
|
17
|
+
<DocumentFragment>
|
|
19
18
|
<h1
|
|
20
19
|
class="pf-c-title pf-m-3xl"
|
|
21
20
|
data-ouia-component-id="OUIA-Generated-Title-5"
|
|
22
21
|
data-ouia-component-type="PF4/Title"
|
|
23
22
|
data-ouia-safe="true"
|
|
24
23
|
>
|
|
25
|
-
3xl
|
|
26
|
-
Title
|
|
24
|
+
3xl Title
|
|
27
25
|
</h1>
|
|
28
|
-
</
|
|
26
|
+
</DocumentFragment>
|
|
29
27
|
`;
|
|
30
28
|
|
|
31
|
-
exports[`4xl Title 1`] = `
|
|
32
|
-
<
|
|
29
|
+
exports[`Title 4xl Title 1`] = `
|
|
30
|
+
<DocumentFragment>
|
|
33
31
|
<h1
|
|
34
32
|
class="pf-c-title pf-m-4xl"
|
|
35
33
|
data-ouia-component-id="OUIA-Generated-Title-6"
|
|
36
34
|
data-ouia-component-type="PF4/Title"
|
|
37
35
|
data-ouia-safe="true"
|
|
38
36
|
>
|
|
39
|
-
4xl
|
|
40
|
-
Title
|
|
37
|
+
4xl Title
|
|
41
38
|
</h1>
|
|
42
|
-
</
|
|
39
|
+
</DocumentFragment>
|
|
43
40
|
`;
|
|
44
41
|
|
|
45
|
-
exports[`lg Title 1`] = `
|
|
46
|
-
<
|
|
42
|
+
exports[`Title lg Title 1`] = `
|
|
43
|
+
<DocumentFragment>
|
|
47
44
|
<h1
|
|
48
45
|
class="pf-c-title pf-m-lg"
|
|
49
46
|
data-ouia-component-id="OUIA-Generated-Title-2"
|
|
50
47
|
data-ouia-component-type="PF4/Title"
|
|
51
48
|
data-ouia-safe="true"
|
|
52
49
|
>
|
|
53
|
-
lg
|
|
54
|
-
Title
|
|
50
|
+
lg Title
|
|
55
51
|
</h1>
|
|
56
|
-
</
|
|
52
|
+
</DocumentFragment>
|
|
57
53
|
`;
|
|
58
54
|
|
|
59
|
-
exports[`md Title 1`] = `
|
|
60
|
-
<
|
|
55
|
+
exports[`Title md Title 1`] = `
|
|
56
|
+
<DocumentFragment>
|
|
61
57
|
<h1
|
|
62
58
|
class="pf-c-title pf-m-md"
|
|
63
59
|
data-ouia-component-id="OUIA-Generated-Title-1"
|
|
64
60
|
data-ouia-component-type="PF4/Title"
|
|
65
61
|
data-ouia-safe="true"
|
|
66
62
|
>
|
|
67
|
-
md
|
|
68
|
-
Title
|
|
63
|
+
md Title
|
|
69
64
|
</h1>
|
|
70
|
-
</
|
|
65
|
+
</DocumentFragment>
|
|
71
66
|
`;
|
|
72
67
|
|
|
73
|
-
exports[`xl Title 1`] = `
|
|
74
|
-
<
|
|
68
|
+
exports[`Title xl Title 1`] = `
|
|
69
|
+
<DocumentFragment>
|
|
75
70
|
<h1
|
|
76
71
|
class="pf-c-title pf-m-xl"
|
|
77
72
|
data-ouia-component-id="OUIA-Generated-Title-3"
|
|
78
73
|
data-ouia-component-type="PF4/Title"
|
|
79
74
|
data-ouia-safe="true"
|
|
80
75
|
>
|
|
81
|
-
xl
|
|
82
|
-
Title
|
|
76
|
+
xl Title
|
|
83
77
|
</h1>
|
|
84
|
-
</
|
|
78
|
+
</DocumentFragment>
|
|
85
79
|
`;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
import {
|
|
2
|
+
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
4
|
+
import userEvent from '@testing-library/user-event';
|
|
5
|
+
|
|
4
6
|
import { ToggleGroup } from '../ToggleGroup';
|
|
5
7
|
import { ToggleGroupItem } from '../ToggleGroupItem';
|
|
6
8
|
|
|
@@ -9,41 +11,43 @@ const props = {
|
|
|
9
11
|
selected: false
|
|
10
12
|
};
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
describe('ToggleGroup', () => {
|
|
15
|
+
test('basic selected', () => {
|
|
16
|
+
const { asFragment } = render(<ToggleGroupItem text="test" isSelected buttonId="toggleGroupItem" aria-label="basic selected" />);
|
|
17
|
+
expect(asFragment()).toMatchSnapshot();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test('basic not selected', () => {
|
|
21
|
+
const { asFragment } = render(<ToggleGroupItem text="test" buttonId="toggleGroupItem" aria-label="basic not selected" />);
|
|
22
|
+
expect(asFragment()).toMatchSnapshot();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test('icon variant', () => {
|
|
26
|
+
const { asFragment } = render(<ToggleGroupItem isSelected icon="icon" buttonId="toggleGroupItem" aria-label="icon variant" />);
|
|
27
|
+
expect(asFragment()).toMatchSnapshot();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('isDisabled', () => {
|
|
31
|
+
const { asFragment } = render(<ToggleGroupItem text="test" isDisabled buttonId="toggleGroupItem" aria-label="isDisabled" />);
|
|
32
|
+
expect(asFragment()).toMatchSnapshot();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test('item passes selection and event to onChange handler', () => {
|
|
36
|
+
render(
|
|
37
|
+
<ToggleGroupItem text="test" buttonId="toggleGroupItem" onChange={props.onChange} aria-label="onChange handler" />
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
userEvent.click(screen.getByRole('button'));
|
|
41
|
+
expect(props.onChange).toHaveBeenCalledWith(true, expect.any(Object));
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test('isCompact', () => {
|
|
45
|
+
const { asFragment } = render(
|
|
46
|
+
<ToggleGroup isCompact aria-label="Label">
|
|
47
|
+
<ToggleGroupItem text="Test" />
|
|
48
|
+
<ToggleGroupItem text="Test" />
|
|
49
|
+
</ToggleGroup>
|
|
50
|
+
);
|
|
51
|
+
expect(asFragment()).toMatchSnapshot();
|
|
52
|
+
});
|
|
20
53
|
});
|
|
21
|
-
|
|
22
|
-
test('icon variant', () => {
|
|
23
|
-
const view = render(<ToggleGroupItem selected icon="icon" buttonId="toggleGroupItem" aria-label="icon variant" />);
|
|
24
|
-
expect(view.container).toMatchSnapshot();
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
test('isDisabled', () => {
|
|
28
|
-
const view = render(<ToggleGroupItem text="test" isDisabled buttonId="toggleGroupItem" aria-label="isDisabled" />);
|
|
29
|
-
expect(view.container).toMatchSnapshot();
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
test('item passes selection and event to onChange handler', () => {
|
|
33
|
-
const selected = true;
|
|
34
|
-
const event = {};
|
|
35
|
-
const view = shallow(<ToggleGroupItem text="test" buttonId="toggleGroupItem" onChange={props.onChange} aria-label="onChange handler" />);
|
|
36
|
-
view.find('button').simulate('click', event, selected);
|
|
37
|
-
expect(props.onChange).toBeCalledWith(selected, event);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
test('isCompact', () => {
|
|
41
|
-
const view = render(
|
|
42
|
-
<ToggleGroup isCompact>
|
|
43
|
-
<ToggleGroupItem text="Test" />
|
|
44
|
-
<ToggleGroupItem text="Test" />
|
|
45
|
-
</ToggleGroup>
|
|
46
|
-
);
|
|
47
|
-
expect(view.container).toMatchSnapshot();
|
|
48
|
-
});
|
|
49
|
-
|