@patternfly/react-core 4.202.33 → 4.202.36
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 +27 -0
- package/dist/esm/components/ApplicationLauncher/ApplicationLauncher.d.ts +9 -2
- package/dist/esm/components/ApplicationLauncher/ApplicationLauncher.d.ts.map +1 -1
- package/dist/esm/components/ApplicationLauncher/ApplicationLauncher.js.map +1 -1
- package/dist/esm/components/Brand/Brand.d.ts +23 -3
- package/dist/esm/components/Brand/Brand.d.ts.map +1 -1
- package/dist/esm/components/Brand/Brand.js +12 -2
- package/dist/esm/components/Brand/Brand.js.map +1 -1
- package/dist/esm/components/ContextSelector/ContextSelector.d.ts +10 -2
- package/dist/esm/components/ContextSelector/ContextSelector.d.ts.map +1 -1
- package/dist/esm/components/ContextSelector/ContextSelector.js +3 -2
- package/dist/esm/components/ContextSelector/ContextSelector.js.map +1 -1
- package/dist/esm/components/ContextSelector/ContextSelectorToggle.js +3 -3
- package/dist/esm/components/ContextSelector/ContextSelectorToggle.js.map +1 -1
- package/dist/esm/components/Dropdown/Dropdown.d.ts +9 -2
- package/dist/esm/components/Dropdown/Dropdown.d.ts.map +1 -1
- package/dist/esm/components/Dropdown/Dropdown.js +2 -2
- package/dist/esm/components/Dropdown/Dropdown.js.map +1 -1
- package/dist/esm/components/OptionsMenu/OptionsMenu.d.ts +9 -2
- package/dist/esm/components/OptionsMenu/OptionsMenu.d.ts.map +1 -1
- package/dist/esm/components/OptionsMenu/OptionsMenu.js.map +1 -1
- package/dist/esm/components/Select/Select.d.ts +9 -2
- package/dist/esm/components/Select/Select.d.ts.map +1 -1
- package/dist/esm/components/Select/Select.js.map +1 -1
- package/dist/esm/components/Tabs/Tabs.d.ts +2 -0
- package/dist/esm/components/Tabs/Tabs.d.ts.map +1 -1
- package/dist/esm/components/Tabs/Tabs.js +3 -2
- package/dist/esm/components/Tabs/Tabs.js.map +1 -1
- package/dist/esm/helpers/Popper/Popper.d.ts +0 -10
- package/dist/esm/helpers/Popper/Popper.d.ts.map +1 -1
- package/dist/esm/helpers/Popper/Popper.js.map +1 -1
- package/dist/js/components/ApplicationLauncher/ApplicationLauncher.d.ts +9 -2
- package/dist/js/components/ApplicationLauncher/ApplicationLauncher.d.ts.map +1 -1
- package/dist/js/components/ApplicationLauncher/ApplicationLauncher.js.map +1 -1
- package/dist/js/components/Brand/Brand.d.ts +23 -3
- package/dist/js/components/Brand/Brand.d.ts.map +1 -1
- package/dist/js/components/Brand/Brand.js +12 -2
- package/dist/js/components/Brand/Brand.js.map +1 -1
- package/dist/js/components/ContextSelector/ContextSelector.d.ts +10 -2
- package/dist/js/components/ContextSelector/ContextSelector.d.ts.map +1 -1
- package/dist/js/components/ContextSelector/ContextSelector.js +3 -2
- package/dist/js/components/ContextSelector/ContextSelector.js.map +1 -1
- package/dist/js/components/ContextSelector/ContextSelectorToggle.js +3 -3
- package/dist/js/components/ContextSelector/ContextSelectorToggle.js.map +1 -1
- package/dist/js/components/Dropdown/Dropdown.d.ts +9 -2
- package/dist/js/components/Dropdown/Dropdown.d.ts.map +1 -1
- package/dist/js/components/Dropdown/Dropdown.js +2 -2
- package/dist/js/components/Dropdown/Dropdown.js.map +1 -1
- package/dist/js/components/OptionsMenu/OptionsMenu.d.ts +9 -2
- package/dist/js/components/OptionsMenu/OptionsMenu.d.ts.map +1 -1
- package/dist/js/components/OptionsMenu/OptionsMenu.js.map +1 -1
- package/dist/js/components/Select/Select.d.ts +9 -2
- package/dist/js/components/Select/Select.d.ts.map +1 -1
- package/dist/js/components/Select/Select.js.map +1 -1
- package/dist/js/components/Tabs/Tabs.d.ts +2 -0
- package/dist/js/components/Tabs/Tabs.d.ts.map +1 -1
- package/dist/js/components/Tabs/Tabs.js +3 -2
- package/dist/js/components/Tabs/Tabs.js.map +1 -1
- package/dist/js/helpers/Popper/Popper.d.ts +0 -10
- package/dist/js/helpers/Popper/Popper.d.ts.map +1 -1
- package/dist/js/helpers/Popper/Popper.js.map +1 -1
- package/dist/umd/react-core.css +64 -0
- package/dist/umd/react-core.js +152 -130
- package/dist/umd/react-core.min.css +64 -0
- package/dist/umd/react-core.min.js +4 -4
- package/package.json +5 -5
- package/src/components/ApplicationLauncher/ApplicationLauncher.tsx +9 -2
- package/src/components/Brand/Brand.tsx +61 -8
- package/src/components/Brand/__tests__/Brand.test.tsx +15 -4
- package/src/components/Brand/__tests__/__snapshots__/Brand.test.tsx.snap +1 -1
- package/src/components/Brand/examples/Brand.md +13 -0
- package/src/components/Brand/examples/BrandResponsive.tsx +18 -0
- package/src/components/Brand/examples/pf-c-brand--logo-base.jpg +0 -0
- package/src/components/Brand/examples/pf-c-brand--logo-on-lg.svg +32 -0
- package/src/components/Brand/examples/pf-c-brand--logo-on-md.svg +42 -0
- package/src/components/Brand/examples/pf-c-brand--logo-on-sm.svg +17 -0
- package/src/components/Brand/examples/pf-c-brand--logo-on-xl.svg +39 -0
- package/src/components/Brand/examples/pf-c-brand--logo.svg +10 -0
- package/src/components/ContextSelector/ContextSelector.tsx +12 -4
- package/src/components/ContextSelector/ContextSelectorToggle.tsx +3 -3
- package/src/components/Dropdown/Dropdown.tsx +11 -3
- package/src/components/OptionsMenu/OptionsMenu.tsx +9 -2
- package/src/components/Select/Select.tsx +10 -3
- package/src/components/Tabs/Tabs.tsx +5 -0
- package/src/components/Tabs/__tests__/Tabs.test.tsx +17 -0
- package/src/components/Tabs/__tests__/__snapshots__/Tabs.test.tsx.snap +153 -0
- package/src/components/TextInputGroup/__tests__/TextInputGroup.test.tsx +47 -146
- package/src/components/TextInputGroup/__tests__/TextInputGroupMain.test.tsx +302 -0
- package/src/components/TextInputGroup/__tests__/TextInputGroupUtilities.test.tsx +34 -0
- package/src/components/TextInputGroup/__tests__/__snapshots__/TextInputGroup.test.tsx.snap +2 -203
- package/src/components/TextInputGroup/__tests__/__snapshots__/TextInputGroupMain.test.tsx.snap +21 -0
- package/src/components/TextInputGroup/__tests__/__snapshots__/TextInputGroupUtilities.test.tsx.snap +13 -0
- package/src/demos/Tabs.md +5 -0
- package/src/demos/examples/Tabs/TabsAndTablesAutoWidthTabs.tsx +442 -0
- package/src/helpers/Popper/Popper.tsx +0 -11
|
@@ -1543,6 +1543,159 @@ exports[`should render tabs with eventKey Strings 1`] = `
|
|
|
1543
1543
|
</div>
|
|
1544
1544
|
`;
|
|
1545
1545
|
|
|
1546
|
+
exports[`should render tabs with no bottom border 1`] = `
|
|
1547
|
+
<div>
|
|
1548
|
+
<div
|
|
1549
|
+
class="pf-c-tabs pf-m-no-border-bottom"
|
|
1550
|
+
data-ouia-component-id="OUIA-Generated-Tabs-14"
|
|
1551
|
+
data-ouia-component-type="PF4/Tabs"
|
|
1552
|
+
data-ouia-safe="true"
|
|
1553
|
+
id="noBottomBorderTabs"
|
|
1554
|
+
>
|
|
1555
|
+
<button
|
|
1556
|
+
aria-hidden="true"
|
|
1557
|
+
aria-label="Scroll left"
|
|
1558
|
+
class="pf-c-tabs__scroll-button"
|
|
1559
|
+
disabled=""
|
|
1560
|
+
>
|
|
1561
|
+
<svg
|
|
1562
|
+
aria-hidden="true"
|
|
1563
|
+
fill="currentColor"
|
|
1564
|
+
height="1em"
|
|
1565
|
+
role="img"
|
|
1566
|
+
style="vertical-align: -0.125em;"
|
|
1567
|
+
viewBox="0 0 256 512"
|
|
1568
|
+
width="1em"
|
|
1569
|
+
>
|
|
1570
|
+
<path
|
|
1571
|
+
d="M31.7 239l136-136c9.4-9.4 24.6-9.4 33.9 0l22.6 22.6c9.4 9.4 9.4 24.6 0 33.9L127.9 256l96.4 96.4c9.4 9.4 9.4 24.6 0 33.9L201.7 409c-9.4 9.4-24.6 9.4-33.9 0l-136-136c-9.5-9.4-9.5-24.6-.1-34z"
|
|
1572
|
+
/>
|
|
1573
|
+
</svg>
|
|
1574
|
+
</button>
|
|
1575
|
+
<ul
|
|
1576
|
+
class="pf-c-tabs__list"
|
|
1577
|
+
role="tablist"
|
|
1578
|
+
>
|
|
1579
|
+
<li
|
|
1580
|
+
class="pf-c-tabs__item pf-m-current"
|
|
1581
|
+
role="presentation"
|
|
1582
|
+
>
|
|
1583
|
+
<button
|
|
1584
|
+
aria-controls="pf-tab-section-0-tab1"
|
|
1585
|
+
aria-selected="true"
|
|
1586
|
+
class="pf-c-tabs__link"
|
|
1587
|
+
data-ouia-component-type="PF4/TabButton"
|
|
1588
|
+
data-ouia-safe="true"
|
|
1589
|
+
id="pf-tab-0-tab1"
|
|
1590
|
+
role="tab"
|
|
1591
|
+
>
|
|
1592
|
+
<span
|
|
1593
|
+
class="pf-c-tabs__item-text"
|
|
1594
|
+
>
|
|
1595
|
+
"Tab item 1"
|
|
1596
|
+
</span>
|
|
1597
|
+
</button>
|
|
1598
|
+
</li>
|
|
1599
|
+
<li
|
|
1600
|
+
class="pf-c-tabs__item"
|
|
1601
|
+
role="presentation"
|
|
1602
|
+
>
|
|
1603
|
+
<button
|
|
1604
|
+
aria-controls="pf-tab-section-1-tab2"
|
|
1605
|
+
aria-selected="false"
|
|
1606
|
+
class="pf-c-tabs__link"
|
|
1607
|
+
data-ouia-component-type="PF4/TabButton"
|
|
1608
|
+
data-ouia-safe="true"
|
|
1609
|
+
id="pf-tab-1-tab2"
|
|
1610
|
+
role="tab"
|
|
1611
|
+
>
|
|
1612
|
+
<span
|
|
1613
|
+
class="pf-c-tabs__item-text"
|
|
1614
|
+
>
|
|
1615
|
+
"Tab item 2"
|
|
1616
|
+
</span>
|
|
1617
|
+
</button>
|
|
1618
|
+
</li>
|
|
1619
|
+
<li
|
|
1620
|
+
class="pf-c-tabs__item"
|
|
1621
|
+
role="presentation"
|
|
1622
|
+
>
|
|
1623
|
+
<button
|
|
1624
|
+
aria-controls="pf-tab-section-2-tab3"
|
|
1625
|
+
aria-selected="false"
|
|
1626
|
+
class="pf-c-tabs__link"
|
|
1627
|
+
data-ouia-component-type="PF4/TabButton"
|
|
1628
|
+
data-ouia-safe="true"
|
|
1629
|
+
id="pf-tab-2-tab3"
|
|
1630
|
+
role="tab"
|
|
1631
|
+
>
|
|
1632
|
+
<span
|
|
1633
|
+
class="pf-c-tabs__item-text"
|
|
1634
|
+
>
|
|
1635
|
+
"Tab item 3"
|
|
1636
|
+
</span>
|
|
1637
|
+
</button>
|
|
1638
|
+
</li>
|
|
1639
|
+
</ul>
|
|
1640
|
+
<button
|
|
1641
|
+
aria-hidden="true"
|
|
1642
|
+
aria-label="Scroll right"
|
|
1643
|
+
class="pf-c-tabs__scroll-button"
|
|
1644
|
+
disabled=""
|
|
1645
|
+
>
|
|
1646
|
+
<svg
|
|
1647
|
+
aria-hidden="true"
|
|
1648
|
+
fill="currentColor"
|
|
1649
|
+
height="1em"
|
|
1650
|
+
role="img"
|
|
1651
|
+
style="vertical-align: -0.125em;"
|
|
1652
|
+
viewBox="0 0 256 512"
|
|
1653
|
+
width="1em"
|
|
1654
|
+
>
|
|
1655
|
+
<path
|
|
1656
|
+
d="M224.3 273l-136 136c-9.4 9.4-24.6 9.4-33.9 0l-22.6-22.6c-9.4-9.4-9.4-24.6 0-33.9l96.4-96.4-96.4-96.4c-9.4-9.4-9.4-24.6 0-33.9L54.3 103c9.4-9.4 24.6-9.4 33.9 0l136 136c9.5 9.4 9.5 24.6.1 34z"
|
|
1657
|
+
/>
|
|
1658
|
+
</svg>
|
|
1659
|
+
</button>
|
|
1660
|
+
</div>
|
|
1661
|
+
<section
|
|
1662
|
+
aria-labelledby="pf-tab-0-tab1"
|
|
1663
|
+
class="pf-c-tab-content"
|
|
1664
|
+
data-ouia-component-type="PF4/TabContent"
|
|
1665
|
+
data-ouia-safe="true"
|
|
1666
|
+
id="pf-tab-section-0-tab1"
|
|
1667
|
+
role="tabpanel"
|
|
1668
|
+
tabindex="0"
|
|
1669
|
+
>
|
|
1670
|
+
Tab 1 section
|
|
1671
|
+
</section>
|
|
1672
|
+
<section
|
|
1673
|
+
aria-labelledby="pf-tab-1-tab2"
|
|
1674
|
+
class="pf-c-tab-content"
|
|
1675
|
+
data-ouia-component-type="PF4/TabContent"
|
|
1676
|
+
data-ouia-safe="true"
|
|
1677
|
+
hidden=""
|
|
1678
|
+
id="pf-tab-section-1-tab2"
|
|
1679
|
+
role="tabpanel"
|
|
1680
|
+
tabindex="0"
|
|
1681
|
+
>
|
|
1682
|
+
Tab 2 section
|
|
1683
|
+
</section>
|
|
1684
|
+
<section
|
|
1685
|
+
aria-labelledby="pf-tab-2-tab3"
|
|
1686
|
+
class="pf-c-tab-content"
|
|
1687
|
+
data-ouia-component-type="PF4/TabContent"
|
|
1688
|
+
data-ouia-safe="true"
|
|
1689
|
+
hidden=""
|
|
1690
|
+
id="pf-tab-section-2-tab3"
|
|
1691
|
+
role="tabpanel"
|
|
1692
|
+
tabindex="0"
|
|
1693
|
+
>
|
|
1694
|
+
Tab 3 section
|
|
1695
|
+
</section>
|
|
1696
|
+
</div>
|
|
1697
|
+
`;
|
|
1698
|
+
|
|
1546
1699
|
exports[`should render tabs with separate content 1`] = `
|
|
1547
1700
|
<div>
|
|
1548
1701
|
<div
|
|
@@ -1,192 +1,93 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
2
|
import { render, screen } from '@testing-library/react';
|
|
4
|
-
import
|
|
3
|
+
import '@testing-library/jest-dom';
|
|
5
4
|
|
|
6
5
|
import { TextInputGroup, TextInputGroupContext } from '../TextInputGroup';
|
|
7
|
-
import { TextInputGroupMain } from '../TextInputGroupMain';
|
|
8
|
-
import { TextInputGroupUtilities } from '../TextInputGroupUtilities';
|
|
9
|
-
import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon';
|
|
10
6
|
|
|
11
7
|
describe('TextInputGroup', () => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
<TextInputGroup>
|
|
15
|
-
<TextInputGroupMain>Foo</TextInputGroupMain>
|
|
16
|
-
<TextInputGroupUtilities />
|
|
17
|
-
</TextInputGroup>
|
|
18
|
-
);
|
|
19
|
-
expect(asFragment()).toMatchSnapshot();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
test('gets custom class and id', () => {
|
|
23
|
-
const { asFragment } = render(
|
|
24
|
-
<TextInputGroup className="custom-class" id="test-id">
|
|
25
|
-
<TextInputGroupMain>Foo</TextInputGroupMain>
|
|
26
|
-
<TextInputGroupUtilities />
|
|
27
|
-
</TextInputGroup>
|
|
28
|
-
);
|
|
29
|
-
expect(asFragment()).toMatchSnapshot();
|
|
30
|
-
});
|
|
8
|
+
it('renders without children', () => {
|
|
9
|
+
render(<TextInputGroup data-testid="TextInputGroup" />);
|
|
31
10
|
|
|
32
|
-
|
|
33
|
-
const { asFragment } = render(
|
|
34
|
-
<TextInputGroup isDisabled>
|
|
35
|
-
<TextInputGroupMain>Foo</TextInputGroupMain>
|
|
36
|
-
<TextInputGroupUtilities />
|
|
37
|
-
</TextInputGroup>
|
|
38
|
-
);
|
|
39
|
-
expect(asFragment()).toMatchSnapshot();
|
|
11
|
+
expect(screen.getByTestId('TextInputGroup')).toBeVisible();
|
|
40
12
|
});
|
|
41
13
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const context = React.useContext(TextInputGroupContext);
|
|
14
|
+
it('renders children', () => {
|
|
15
|
+
render(<TextInputGroup>Test</TextInputGroup>);
|
|
45
16
|
|
|
46
|
-
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
render(
|
|
50
|
-
<TextInputGroup>
|
|
51
|
-
<TestComponent />
|
|
52
|
-
</TextInputGroup>
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
expect(screen.queryByText('is disabled')).toBeNull();
|
|
17
|
+
expect(screen.getByText('Test')).toBeVisible();
|
|
56
18
|
});
|
|
57
19
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const context = React.useContext(TextInputGroupContext);
|
|
20
|
+
it('renders with class pf-c-text-input-group', () => {
|
|
21
|
+
render(<TextInputGroup>Test</TextInputGroup>);
|
|
61
22
|
|
|
62
|
-
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
render(
|
|
66
|
-
<TextInputGroup isDisabled>
|
|
67
|
-
<TestComponent />
|
|
68
|
-
</TextInputGroup>
|
|
69
|
-
);
|
|
23
|
+
const inputGroup = screen.getByText('Test');
|
|
70
24
|
|
|
71
|
-
expect(
|
|
25
|
+
expect(inputGroup).toHaveClass('pf-c-text-input-group');
|
|
72
26
|
});
|
|
73
|
-
});
|
|
74
27
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const { asFragment } = render(<TextInputGroupMain>Foo</TextInputGroupMain>);
|
|
78
|
-
expect(asFragment()).toMatchSnapshot();
|
|
79
|
-
});
|
|
28
|
+
it('renders with custom class names provided via prop', () => {
|
|
29
|
+
render(<TextInputGroup className="custom-class">Test</TextInputGroup>);
|
|
80
30
|
|
|
81
|
-
|
|
82
|
-
const { asFragment } = render(<TextInputGroupMain icon={<SearchIcon />}>Foo</TextInputGroupMain>);
|
|
83
|
-
expect(asFragment()).toMatchSnapshot();
|
|
84
|
-
});
|
|
31
|
+
const inputGroup = screen.getByText('Test');
|
|
85
32
|
|
|
86
|
-
|
|
87
|
-
const { asFragment } = render(<TextInputGroupMain aria-label="Foo">Foo</TextInputGroupMain>);
|
|
88
|
-
expect(asFragment()).toMatchSnapshot();
|
|
33
|
+
expect(inputGroup).toHaveClass('custom-class');
|
|
89
34
|
});
|
|
90
35
|
|
|
91
|
-
|
|
92
|
-
|
|
36
|
+
it('does not render with the pf-m-disabled class when not disabled', () => {
|
|
37
|
+
render(<TextInputGroup>Test</TextInputGroup>);
|
|
93
38
|
|
|
94
|
-
|
|
95
|
-
expect(onChangeMock).not.toHaveBeenCalled();
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
test('calls the onChange callback when the input changes', () => {
|
|
99
|
-
const onChangeMock = jest.fn();
|
|
39
|
+
const inputGroup = screen.getByText('Test');
|
|
100
40
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
userEvent.type(screen.getByText('Foo').querySelector('input'), 'Foo');
|
|
104
|
-
expect(onChangeMock).toHaveBeenCalled();
|
|
41
|
+
expect(inputGroup).not.toHaveClass('pf-m-disabled');
|
|
105
42
|
});
|
|
106
43
|
|
|
107
|
-
|
|
108
|
-
|
|
44
|
+
it('renders with the pf-m-disabled class when disabled', () => {
|
|
45
|
+
render(<TextInputGroup isDisabled>Test</TextInputGroup>);
|
|
109
46
|
|
|
110
|
-
|
|
111
|
-
expect(onFocusMock).not.toHaveBeenCalled();
|
|
112
|
-
});
|
|
47
|
+
const inputGroup = screen.getByText('Test');
|
|
113
48
|
|
|
114
|
-
|
|
115
|
-
const onFocusMock = jest.fn();
|
|
116
|
-
|
|
117
|
-
render(<TextInputGroupMain onFocus={onFocusMock}>Foo</TextInputGroupMain>);
|
|
118
|
-
userEvent.click(screen.getByText('Foo').querySelector('input'));
|
|
119
|
-
expect(onFocusMock).toHaveBeenCalledTimes(1);
|
|
49
|
+
expect(inputGroup).toHaveClass('pf-m-disabled');
|
|
120
50
|
});
|
|
121
51
|
|
|
122
|
-
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
render(<TextInputGroupMain onBlur={onBlurMock}>Foo</TextInputGroupMain>);
|
|
126
|
-
|
|
127
|
-
userEvent.type(screen.getByText('Foo').querySelector('input'), 'Foo');
|
|
128
|
-
expect(onBlurMock).not.toHaveBeenCalled();
|
|
129
|
-
});
|
|
52
|
+
it('passes isDisabled=false to children via a context when isDisabled prop is not passed', () => {
|
|
53
|
+
const TestComponent: React.FunctionComponent = () => {
|
|
54
|
+
const context = React.useContext(TextInputGroupContext);
|
|
130
55
|
|
|
131
|
-
|
|
132
|
-
|
|
56
|
+
return <button disabled={context.isDisabled} />;
|
|
57
|
+
};
|
|
133
58
|
|
|
134
59
|
render(
|
|
135
|
-
|
|
136
|
-
<
|
|
137
|
-
|
|
138
|
-
</>
|
|
60
|
+
<TextInputGroup>
|
|
61
|
+
<TestComponent />
|
|
62
|
+
</TextInputGroup>
|
|
139
63
|
);
|
|
140
64
|
|
|
141
|
-
|
|
142
|
-
userEvent.click(screen.getByText('Other element'));
|
|
65
|
+
const testComponent = screen.getByRole('button');
|
|
143
66
|
|
|
144
|
-
expect(
|
|
67
|
+
expect(testComponent).not.toBeDisabled();
|
|
145
68
|
});
|
|
146
69
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
screen
|
|
151
|
-
.getByText('Foo')
|
|
152
|
-
.querySelector('input')
|
|
153
|
-
.getAttribute('type')
|
|
154
|
-
).toEqual('text');
|
|
155
|
-
});
|
|
70
|
+
it('passes isDisabled=true to children via a context when isDisabled prop is passed', () => {
|
|
71
|
+
const TestComponent: React.FunctionComponent = () => {
|
|
72
|
+
const context = React.useContext(TextInputGroupContext);
|
|
156
73
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
expect(
|
|
160
|
-
screen
|
|
161
|
-
.getByText('Foo')
|
|
162
|
-
.querySelector('input')
|
|
163
|
-
.getAttribute('type')
|
|
164
|
-
).toEqual('search');
|
|
165
|
-
});
|
|
74
|
+
return <button disabled={context.isDisabled} />;
|
|
75
|
+
};
|
|
166
76
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
</TextInputGroupContext.Provider>
|
|
77
|
+
render(
|
|
78
|
+
<TextInputGroup isDisabled>
|
|
79
|
+
<TestComponent />
|
|
80
|
+
</TextInputGroup>
|
|
172
81
|
);
|
|
173
82
|
|
|
174
|
-
|
|
175
|
-
});
|
|
83
|
+
const testComponent = screen.getByRole('button');
|
|
176
84
|
|
|
177
|
-
|
|
178
|
-
const { asFragment } = render(
|
|
179
|
-
<TextInputGroupContext.Provider value={{ isDisabled: true }}>
|
|
180
|
-
<TextInputGroupMain />
|
|
181
|
-
</TextInputGroupContext.Provider>
|
|
182
|
-
);
|
|
183
|
-
expect(asFragment()).toMatchSnapshot();
|
|
85
|
+
expect(testComponent).toBeDisabled();
|
|
184
86
|
});
|
|
185
|
-
});
|
|
186
87
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
88
|
+
it('matches the snapshot', () => {
|
|
89
|
+
const { asFragment } = render(<TextInputGroup>Test</TextInputGroup>);
|
|
90
|
+
|
|
190
91
|
expect(asFragment()).toMatchSnapshot();
|
|
191
92
|
});
|
|
192
93
|
});
|