@patternfly/react-core 4.202.30 → 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 +8 -0
- 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/__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
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import {
|
|
2
|
+
capitalize,
|
|
3
|
+
getUniqueId,
|
|
4
|
+
debounce,
|
|
5
|
+
isElementInView,
|
|
6
|
+
sideElementIsOutOfView,
|
|
7
|
+
fillTemplate,
|
|
8
|
+
pluralize,
|
|
9
|
+
formatBreakpointMods
|
|
10
|
+
} from '../util';
|
|
11
|
+
import { SIDE } from '../constants';
|
|
12
|
+
import styles from '@patternfly/react-styles/css/layouts/Flex/flex';
|
|
13
|
+
|
|
14
|
+
const createMockHtmlElement = bounds =>
|
|
15
|
+
({
|
|
16
|
+
getBoundingClientRect: () => bounds
|
|
17
|
+
} as HTMLElement);
|
|
18
|
+
|
|
19
|
+
test('capitalize', () => {
|
|
20
|
+
expect(capitalize('foo')).toBe('Foo');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test('getUniqueId', () => {
|
|
24
|
+
expect(getUniqueId()).not.toBe(getUniqueId());
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test('getUniqueId prefixed', () => {
|
|
28
|
+
expect(getUniqueId().substring(0, 3)).toBe('pf-');
|
|
29
|
+
expect(getUniqueId('pf-switch').substring(0, 10)).toBe('pf-switch-');
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test('debounce', () => {
|
|
33
|
+
jest.useFakeTimers();
|
|
34
|
+
const callback = jest.fn();
|
|
35
|
+
const debouncedFunction = debounce(callback, 50);
|
|
36
|
+
|
|
37
|
+
debouncedFunction();
|
|
38
|
+
// At this point in time, the callback should not have been called yet
|
|
39
|
+
expect(callback).toHaveBeenCalledTimes(0);
|
|
40
|
+
|
|
41
|
+
for (let i = 0; i < 10; i++) {
|
|
42
|
+
jest.advanceTimersByTime(50);
|
|
43
|
+
debouncedFunction();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
expect(callback).toBeCalledTimes(10);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('isElementInView should be true when partial out of view and with partial true', () => {
|
|
50
|
+
const container = createMockHtmlElement({ left: 0, right: 200 });
|
|
51
|
+
const element = createMockHtmlElement({ left: 10, right: 210 });
|
|
52
|
+
expect(isElementInView(container, element, true)).toBe(true);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test('isElementInView should be false when partial out of view and with partial false ', () => {
|
|
56
|
+
const container = createMockHtmlElement({ left: 0, right: 200 });
|
|
57
|
+
const element = createMockHtmlElement({ left: 10, right: 210 });
|
|
58
|
+
expect(isElementInView(container, element, false)).toBe(false);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test('isElementInView should be false completely out of view ', () => {
|
|
62
|
+
const container = createMockHtmlElement({ left: 0, right: 200 });
|
|
63
|
+
const element = createMockHtmlElement({ left: 200, right: 300 });
|
|
64
|
+
expect(isElementInView(container, element, true)).toBe(false);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
test('isElementInView should be false completely out of view when partial false ', () => {
|
|
68
|
+
const container = createMockHtmlElement({ left: 0, right: 200 });
|
|
69
|
+
const element = createMockHtmlElement({ left: 200, right: 300 });
|
|
70
|
+
expect(isElementInView(container, element, false)).toBe(false);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test('sideElementIsOutOfView Returns left when off on left side', () => {
|
|
74
|
+
const container = createMockHtmlElement({ left: 20, right: 220 });
|
|
75
|
+
const element = createMockHtmlElement({ left: 10, right: 210 });
|
|
76
|
+
expect(sideElementIsOutOfView(container, element)).toBe(SIDE.LEFT);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
test('sideElementIsOutOfView Returns right when off on right side', () => {
|
|
80
|
+
const container = createMockHtmlElement({ left: 0, right: 200 });
|
|
81
|
+
const element = createMockHtmlElement({ left: 210, right: 410 });
|
|
82
|
+
expect(sideElementIsOutOfView(container, element)).toBe(SIDE.RIGHT);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test('sideElementIsOutOfView Returns NONE when in view', () => {
|
|
86
|
+
const container = createMockHtmlElement({ left: 0, right: 200 });
|
|
87
|
+
const element = createMockHtmlElement({ left: 10, right: 110 });
|
|
88
|
+
expect(sideElementIsOutOfView(container, element)).toBe(SIDE.NONE);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test('fillTemplate interpolates strings correctly', () => {
|
|
92
|
+
// eslint-disable-next-line no-template-curly-in-string
|
|
93
|
+
const templateString = 'My name is ${firstName} ${lastName}';
|
|
94
|
+
const expected = 'My name is Jon Dough';
|
|
95
|
+
const templatVars = {
|
|
96
|
+
firstName: 'Jon',
|
|
97
|
+
lastName: 'Dough'
|
|
98
|
+
};
|
|
99
|
+
const actual = fillTemplate(templateString, templatVars);
|
|
100
|
+
expect(actual).toEqual(expected);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
test('text pluralize', () => {
|
|
104
|
+
expect(pluralize(1, 'dog')).toEqual('1 dog');
|
|
105
|
+
expect(pluralize(2, 'dog')).toEqual('2 dogs');
|
|
106
|
+
expect(pluralize(2, 'finch', 'finches')).toEqual('2 finches');
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
test('formatBreakpointMods', () => {
|
|
110
|
+
expect(formatBreakpointMods({ default: 'spacerNone' }, styles)).toEqual('pf-m-spacer-none');
|
|
111
|
+
expect(formatBreakpointMods({ md: 'spacerNone' }, styles)).toEqual('pf-m-spacer-none-on-md');
|
|
112
|
+
expect(formatBreakpointMods({ default: 'column', lg: 'row' }, styles)).toEqual('pf-m-column pf-m-row-on-lg');
|
|
113
|
+
});
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
4
|
+
import '@testing-library/jest-dom';
|
|
5
|
+
|
|
2
6
|
import { Bullseye } from '../Bullseye';
|
|
3
|
-
import { render } from '@testing-library/react';
|
|
4
|
-
import { shallow } from 'enzyme';
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
describe('Bullseye', () => {
|
|
9
|
+
test('renders with PatternFly Core styles', () => {
|
|
10
|
+
const { asFragment } = render(<Bullseye />);
|
|
11
|
+
expect(asFragment()).toMatchSnapshot();
|
|
12
|
+
});
|
|
10
13
|
|
|
11
|
-
test('className is added to the root element', () => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
});
|
|
14
|
+
test('className is added to the root element', () => {
|
|
15
|
+
render(<Bullseye className="extra-class" data-testid='test-id' />);
|
|
16
|
+
expect(screen.getByTestId('test-id')).toHaveClass('extra-class');
|
|
17
|
+
});
|
|
15
18
|
|
|
16
|
-
test('
|
|
17
|
-
|
|
18
|
-
const view = shallow(<Bullseye data-testid={testId} />);
|
|
19
|
-
expect(view.prop('data-testid')).toBe(testId);
|
|
20
|
-
});
|
|
19
|
+
test('allows passing in a string as the component', () => {
|
|
20
|
+
const component = 'button';
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
render(<Bullseye component={component} />);
|
|
23
|
+
expect(screen.getByRole('button')).toBeInTheDocument();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test('allows passing in a React Component as the component', () => {
|
|
27
|
+
const Component: React.FunctionComponent = () => <div>Some text</div>;
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
expect(view.type()).toBe(Component);
|
|
29
|
+
render(<Bullseye component={(Component as unknown) as keyof JSX.IntrinsicElements} />);
|
|
30
|
+
expect(screen.getByText('Some text')).toBeInTheDocument();
|
|
31
|
+
});
|
|
32
32
|
});
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`
|
|
4
|
-
|
|
5
|
-
exports[`renders with PatternFly Core styles 1`] = `
|
|
6
|
-
<div>
|
|
3
|
+
exports[`Bullseye renders with PatternFly Core styles 1`] = `
|
|
4
|
+
<DocumentFragment>
|
|
7
5
|
<div
|
|
8
6
|
class="pf-l-bullseye"
|
|
9
7
|
/>
|
|
10
|
-
</
|
|
8
|
+
</DocumentFragment>
|
|
11
9
|
`;
|
|
@@ -1,110 +1,173 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
4
|
+
import '@testing-library/jest-dom';
|
|
5
|
+
|
|
2
6
|
import { Flex } from '../Flex';
|
|
3
7
|
import { FlexItem } from '../FlexItem';
|
|
4
|
-
import { render } from '@testing-library/react';
|
|
5
|
-
import { mount } from 'enzyme';
|
|
6
|
-
|
|
7
|
-
test('Simple flex with single item', () => {
|
|
8
|
-
const view = render(
|
|
9
|
-
<Flex>
|
|
10
|
-
<FlexItem>Test</FlexItem>
|
|
11
|
-
</Flex>
|
|
12
|
-
);
|
|
13
|
-
expect(view.container).toMatchSnapshot();
|
|
14
|
-
});
|
|
15
8
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
describe('Flex', () => {
|
|
10
|
+
test('Simple flex with single item', () => {
|
|
11
|
+
const { asFragment } = render(
|
|
19
12
|
<Flex>
|
|
20
13
|
<FlexItem>Test</FlexItem>
|
|
21
14
|
</Flex>
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
});
|
|
15
|
+
);
|
|
16
|
+
expect(asFragment()).toMatchSnapshot();
|
|
17
|
+
});
|
|
26
18
|
|
|
27
|
-
test('
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
19
|
+
test('Nested flex', () => {
|
|
20
|
+
const { asFragment } = render(
|
|
21
|
+
<Flex>
|
|
22
|
+
<Flex>
|
|
23
|
+
<FlexItem>Test</FlexItem>
|
|
24
|
+
</Flex>
|
|
25
|
+
</Flex>
|
|
26
|
+
);
|
|
27
|
+
expect(asFragment()).toMatchSnapshot();
|
|
28
|
+
});
|
|
31
29
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
shrink: ['shrink'],
|
|
37
|
-
flex: ['flexDefault', 'flexNone', 'flex_1', 'flex_2', 'flex_3', 'flex_4'],
|
|
38
|
-
direction: ['column', 'columnReverse', 'row', 'rowReverse'],
|
|
39
|
-
alignItems: ['alignItemsFlexStart', 'alignItemsFlexEnd', 'alignItemsCenter', 'alignItemsStretch', 'alignItemsBaseline'],
|
|
40
|
-
alignContent: ['alignContentFlexStart', 'alignContentFlexEnd', 'alignContentCenter', 'alignContentStretch', 'alignContentSpaceBetween', 'alignContentSpaceAround'],
|
|
41
|
-
alignSelf: ['alignSelfFlexStart', 'alignSelfFlexEnd', 'alignSelfCenter', 'alignSelfStretch', 'alignSelfBaseline'],
|
|
42
|
-
align: ['alignLeft', 'alignRight'],
|
|
43
|
-
justifyContent: ['justifyContentFlexStart', 'justifyContentFlexEnd', 'justifyContentCenter', 'justifyContentSpaceBetween', 'justifyContentSpaceAround', 'justifyContentSpaceEvenly'],
|
|
44
|
-
display: ['inlineFlex'],
|
|
45
|
-
fullWidth: ['fullWidth'],
|
|
46
|
-
flexWrap: ['wrap', 'wrapReverse', 'nowrap']
|
|
47
|
-
};
|
|
30
|
+
test('className is added to the root element', () => {
|
|
31
|
+
render(<Flex className="extra-class" data-testid="test-id" />);
|
|
32
|
+
expect(screen.getByTestId('test-id')).toHaveClass('extra-class');
|
|
33
|
+
});
|
|
48
34
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
35
|
+
const flexModifiers = {
|
|
36
|
+
spacer: [
|
|
37
|
+
'spacerNone',
|
|
38
|
+
'spacerXs',
|
|
39
|
+
'spacerSm',
|
|
40
|
+
'spacerMd',
|
|
41
|
+
'spacerLg',
|
|
42
|
+
'spacerXl',
|
|
43
|
+
'spacer2xl',
|
|
44
|
+
'spacer3xl',
|
|
45
|
+
'spacer4xl'
|
|
46
|
+
],
|
|
47
|
+
spaceItems: [
|
|
48
|
+
'spaceItemsNone',
|
|
49
|
+
'spaceItemsXs',
|
|
50
|
+
'spaceItemsSm',
|
|
51
|
+
'spaceItemsMd',
|
|
52
|
+
'spaceItemsLg',
|
|
53
|
+
'spaceItemsXl',
|
|
54
|
+
'spaceItems2xl',
|
|
55
|
+
'spaceItems3xl',
|
|
56
|
+
'spaceItems4xl'
|
|
57
|
+
],
|
|
58
|
+
grow: ['grow'],
|
|
59
|
+
shrink: ['shrink'],
|
|
60
|
+
flex: ['flexDefault', 'flexNone', 'flex_1', 'flex_2', 'flex_3', 'flex_4'],
|
|
61
|
+
direction: ['column', 'columnReverse', 'row', 'rowReverse'],
|
|
62
|
+
alignItems: [
|
|
63
|
+
'alignItemsFlexStart',
|
|
64
|
+
'alignItemsFlexEnd',
|
|
65
|
+
'alignItemsCenter',
|
|
66
|
+
'alignItemsStretch',
|
|
67
|
+
'alignItemsBaseline'
|
|
68
|
+
],
|
|
69
|
+
alignContent: [
|
|
70
|
+
'alignContentFlexStart',
|
|
71
|
+
'alignContentFlexEnd',
|
|
72
|
+
'alignContentCenter',
|
|
73
|
+
'alignContentStretch',
|
|
74
|
+
'alignContentSpaceBetween',
|
|
75
|
+
'alignContentSpaceAround'
|
|
76
|
+
],
|
|
77
|
+
alignSelf: ['alignSelfFlexStart', 'alignSelfFlexEnd', 'alignSelfCenter', 'alignSelfStretch', 'alignSelfBaseline'],
|
|
78
|
+
align: ['alignLeft', 'alignRight'],
|
|
79
|
+
justifyContent: [
|
|
80
|
+
'justifyContentFlexStart',
|
|
81
|
+
'justifyContentFlexEnd',
|
|
82
|
+
'justifyContentCenter',
|
|
83
|
+
'justifyContentSpaceBetween',
|
|
84
|
+
'justifyContentSpaceAround',
|
|
85
|
+
'justifyContentSpaceEvenly'
|
|
86
|
+
],
|
|
87
|
+
display: ['inlineFlex'],
|
|
88
|
+
fullWidth: ['fullWidth'],
|
|
89
|
+
flexWrap: ['wrap', 'wrapReverse', 'nowrap']
|
|
90
|
+
};
|
|
70
91
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
92
|
+
describe('flex modifiers', () => {
|
|
93
|
+
Object.entries(flexModifiers)
|
|
94
|
+
.map(([mod, values]) =>
|
|
95
|
+
values.map(value => ({
|
|
96
|
+
[mod]: {
|
|
97
|
+
default: value,
|
|
98
|
+
sm: value,
|
|
99
|
+
lg: value,
|
|
100
|
+
xl: value,
|
|
101
|
+
'2xl': value
|
|
102
|
+
}
|
|
103
|
+
}))
|
|
104
|
+
)
|
|
105
|
+
.reduce((acc, val) => acc.concat(val), [])
|
|
106
|
+
.forEach(props =>
|
|
107
|
+
test(`${JSON.stringify(props)} add valid classes to Flex`, () => {
|
|
108
|
+
render(
|
|
109
|
+
<Flex {...props} data-testid="test-id">
|
|
110
|
+
{JSON.stringify(props)}
|
|
111
|
+
</Flex>
|
|
112
|
+
);
|
|
80
113
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
.
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
});
|
|
114
|
+
const className = screen
|
|
115
|
+
.getByTestId('test-id')
|
|
116
|
+
.className.replace('pf-l-flex', '')
|
|
117
|
+
.trim();
|
|
118
|
+
|
|
119
|
+
expect(className).not.toBe("''");
|
|
120
|
+
expect(className).not.toBe('');
|
|
121
|
+
})
|
|
122
|
+
);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
const flexItemModifiers = {
|
|
126
|
+
spacer: flexModifiers.spacer,
|
|
127
|
+
grow: flexModifiers.grow,
|
|
128
|
+
shrink: flexModifiers.shrink,
|
|
129
|
+
flex: flexModifiers.flex,
|
|
130
|
+
alignSelf: flexModifiers.alignSelf,
|
|
131
|
+
align: flexModifiers.align,
|
|
132
|
+
fullWidth: flexModifiers.fullWidth
|
|
133
|
+
};
|
|
102
134
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
135
|
+
describe('flexItem modifiers', () => {
|
|
136
|
+
Object.entries(flexItemModifiers)
|
|
137
|
+
.map(([mod, values]) =>
|
|
138
|
+
values.map(value => ({
|
|
139
|
+
[mod]: {
|
|
140
|
+
default: value,
|
|
141
|
+
sm: value,
|
|
142
|
+
lg: value,
|
|
143
|
+
xl: value,
|
|
144
|
+
'2xl': value
|
|
145
|
+
}
|
|
146
|
+
}))
|
|
147
|
+
)
|
|
148
|
+
.reduce((acc, val) => acc.concat(val), [])
|
|
149
|
+
.forEach(props =>
|
|
150
|
+
test(`${JSON.stringify(props)} add valid classes to FlexItem`, () => {
|
|
151
|
+
render(
|
|
152
|
+
<FlexItem {...props} data-testid="test-id">
|
|
153
|
+
{JSON.stringify(props)}
|
|
154
|
+
</FlexItem>
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
const className = screen.getByTestId('test-id').className.trim();
|
|
158
|
+
|
|
159
|
+
expect(className).not.toBe("''");
|
|
160
|
+
expect(className).not.toBe('');
|
|
161
|
+
})
|
|
162
|
+
);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
test('alternative component', () => {
|
|
166
|
+
const { asFragment } = render(
|
|
167
|
+
<Flex component="ul">
|
|
168
|
+
<FlexItem component="li">Test</FlexItem>
|
|
169
|
+
</Flex>
|
|
170
|
+
);
|
|
171
|
+
expect(asFragment()).toMatchSnapshot();
|
|
172
|
+
});
|
|
110
173
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`Nested flex 1`] = `
|
|
4
|
-
<
|
|
3
|
+
exports[`Flex Nested flex 1`] = `
|
|
4
|
+
<DocumentFragment>
|
|
5
5
|
<div
|
|
6
6
|
class="pf-l-flex"
|
|
7
7
|
>
|
|
@@ -15,11 +15,11 @@ exports[`Nested flex 1`] = `
|
|
|
15
15
|
</div>
|
|
16
16
|
</div>
|
|
17
17
|
</div>
|
|
18
|
-
</
|
|
18
|
+
</DocumentFragment>
|
|
19
19
|
`;
|
|
20
20
|
|
|
21
|
-
exports[`Simple flex with single item 1`] = `
|
|
22
|
-
<
|
|
21
|
+
exports[`Flex Simple flex with single item 1`] = `
|
|
22
|
+
<DocumentFragment>
|
|
23
23
|
<div
|
|
24
24
|
class="pf-l-flex"
|
|
25
25
|
>
|
|
@@ -29,11 +29,11 @@ exports[`Simple flex with single item 1`] = `
|
|
|
29
29
|
Test
|
|
30
30
|
</div>
|
|
31
31
|
</div>
|
|
32
|
-
</
|
|
32
|
+
</DocumentFragment>
|
|
33
33
|
`;
|
|
34
34
|
|
|
35
|
-
exports[`alternative component 1`] = `
|
|
36
|
-
<
|
|
35
|
+
exports[`Flex alternative component 1`] = `
|
|
36
|
+
<DocumentFragment>
|
|
37
37
|
<ul
|
|
38
38
|
class="pf-l-flex"
|
|
39
39
|
>
|
|
@@ -43,13 +43,5 @@ exports[`alternative component 1`] = `
|
|
|
43
43
|
Test
|
|
44
44
|
</li>
|
|
45
45
|
</ul>
|
|
46
|
-
</
|
|
47
|
-
`;
|
|
48
|
-
|
|
49
|
-
exports[`className is added to the root element 1`] = `
|
|
50
|
-
<div>
|
|
51
|
-
<div
|
|
52
|
-
class="pf-l-flex extra-class"
|
|
53
|
-
/>
|
|
54
|
-
</div>
|
|
46
|
+
</DocumentFragment>
|
|
55
47
|
`;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This test was generated
|
|
3
|
-
*/
|
|
4
|
-
import * as React from 'react';
|
|
5
|
-
import { render } from '@testing-library/react';
|
|
6
|
-
import { Page } from '../../Page';
|
|
7
|
-
// any missing imports can usually be resolved by adding them here
|
|
8
|
-
import {} from '../..';
|
|
9
|
-
|
|
10
|
-
it('Page should match snapshot (auto-generated)', () => {
|
|
11
|
-
const view = render(
|
|
12
|
-
<Page
|
|
13
|
-
children={<>ReactNode</>}
|
|
14
|
-
className={"''"}
|
|
15
|
-
header={null}
|
|
16
|
-
sidebar={null}
|
|
17
|
-
skipToContent={null}
|
|
18
|
-
role={'string'}
|
|
19
|
-
mainContainerId={'null'}
|
|
20
|
-
isManagedSidebar={false}
|
|
21
|
-
defaultManagedSidebarIsOpen={true}
|
|
22
|
-
onPageResize={(): void => null}
|
|
23
|
-
breadcrumb={null}
|
|
24
|
-
mainAriaLabel={'string'}
|
|
25
|
-
/>
|
|
26
|
-
);
|
|
27
|
-
expect(view.container).toMatchSnapshot();
|
|
28
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`Page should match snapshot (auto-generated) 1`] = `
|
|
4
|
-
<div>
|
|
5
|
-
<div
|
|
6
|
-
class="pf-c-page pf-m-resize-observer pf-m-breakpoint-default ''"
|
|
7
|
-
>
|
|
8
|
-
<main
|
|
9
|
-
aria-label="string"
|
|
10
|
-
class="pf-c-page__main"
|
|
11
|
-
id="null"
|
|
12
|
-
role="string"
|
|
13
|
-
tabindex="-1"
|
|
14
|
-
>
|
|
15
|
-
ReactNode
|
|
16
|
-
</main>
|
|
17
|
-
</div>
|
|
18
|
-
</div>
|
|
19
|
-
`;
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This test was generated
|
|
3
|
-
*/
|
|
4
|
-
import * as React from 'react';
|
|
5
|
-
import { render } from '@testing-library/react';
|
|
6
|
-
import { Pagination } from '../../Pagination';
|
|
7
|
-
// any missing imports can usually be resolved by adding them here
|
|
8
|
-
import {} from '../..';
|
|
9
|
-
|
|
10
|
-
it('Pagination should match snapshot (auto-generated)', () => {
|
|
11
|
-
const view = render(
|
|
12
|
-
<Pagination
|
|
13
|
-
children={<>ReactNode</>}
|
|
14
|
-
className={"''"}
|
|
15
|
-
itemCount={42}
|
|
16
|
-
variant={'top'}
|
|
17
|
-
isDisabled={false}
|
|
18
|
-
isCompact={false}
|
|
19
|
-
perPage={42}
|
|
20
|
-
perPageOptions={[
|
|
21
|
-
{
|
|
22
|
-
title: '10',
|
|
23
|
-
value: 10
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
title: '20',
|
|
27
|
-
value: 20
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
title: '50',
|
|
31
|
-
value: 50
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
title: '100',
|
|
35
|
-
value: 100
|
|
36
|
-
}
|
|
37
|
-
]}
|
|
38
|
-
defaultToFullPage={false}
|
|
39
|
-
firstPage={1}
|
|
40
|
-
page={0}
|
|
41
|
-
offset={0}
|
|
42
|
-
itemsStart={null}
|
|
43
|
-
itemsEnd={null}
|
|
44
|
-
widgetId={"'pagination-options-menu'"}
|
|
45
|
-
dropDirection={'up'}
|
|
46
|
-
titles={undefined}
|
|
47
|
-
toggleTemplate={'string'}
|
|
48
|
-
onSetPage={() => undefined}
|
|
49
|
-
onFirstClick={() => undefined}
|
|
50
|
-
onPreviousClick={() => undefined}
|
|
51
|
-
onNextClick={() => undefined}
|
|
52
|
-
onLastClick={() => undefined}
|
|
53
|
-
onPageInput={() => undefined}
|
|
54
|
-
onPerPageSelect={() => undefined}
|
|
55
|
-
/>
|
|
56
|
-
);
|
|
57
|
-
expect(view.container).toMatchSnapshot();
|
|
58
|
-
});
|