Skip to content

Commit e3d7096

Browse files
dakahnjnm2377
andauthored
feat(Carbon-React): add prefix context refactor to class components (#9691)
* feat(Carbon-React): add prefix context refactor to class components * chore(test): fix broken tests * fix(Carbon-React): update various class component w/PR fixes Co-authored-by: Josefina Mancilla <32556167+jnm2377@users.noreply.github.com>
1 parent a1e11df commit e3d7096

25 files changed

+460
-246
lines changed

packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap

Lines changed: 200 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,24 @@ Map {
701701
"render": [Function],
702702
},
703703
"ComposedModal" => Object {
704+
"contextType": Object {
705+
"$$typeof": Symbol(react.context),
706+
"Consumer": Object {
707+
"$$typeof": Symbol(react.context),
708+
"_calculateChangedBits": null,
709+
"_context": [Circular],
710+
},
711+
"Provider": Object {
712+
"$$typeof": Symbol(react.provider),
713+
"_context": [Circular],
714+
},
715+
"_calculateChangedBits": null,
716+
"_currentRenderer": null,
717+
"_currentRenderer2": null,
718+
"_currentValue": "bx",
719+
"_currentValue2": "bx",
720+
"_threadCount": 0,
721+
},
704722
"defaultProps": Object {
705723
"onKeyDown": [Function],
706724
"selectorPrimaryFocus": "[data-modal-primary-focus]",
@@ -756,6 +774,24 @@ Map {
756774
},
757775
},
758776
"ModalHeader" => Object {
777+
"contextType": Object {
778+
"$$typeof": Symbol(react.context),
779+
"Consumer": Object {
780+
"$$typeof": Symbol(react.context),
781+
"_calculateChangedBits": null,
782+
"_context": [Circular],
783+
},
784+
"Provider": Object {
785+
"$$typeof": Symbol(react.provider),
786+
"_context": [Circular],
787+
},
788+
"_calculateChangedBits": null,
789+
"_currentRenderer": null,
790+
"_currentRenderer2": null,
791+
"_currentValue": "bx",
792+
"_currentValue2": "bx",
793+
"_threadCount": 0,
794+
},
759795
"defaultProps": Object {
760796
"buttonOnClick": [Function],
761797
"iconDescription": "Close",
@@ -814,6 +850,24 @@ Map {
814850
},
815851
},
816852
"ModalFooter" => Object {
853+
"contextType": Object {
854+
"$$typeof": Symbol(react.context),
855+
"Consumer": Object {
856+
"$$typeof": Symbol(react.context),
857+
"_calculateChangedBits": null,
858+
"_context": [Circular],
859+
},
860+
"Provider": Object {
861+
"$$typeof": Symbol(react.provider),
862+
"_context": [Circular],
863+
},
864+
"_calculateChangedBits": null,
865+
"_currentRenderer": null,
866+
"_currentRenderer2": null,
867+
"_currentValue": "bx",
868+
"_currentValue2": "bx",
869+
"_threadCount": 0,
870+
},
817871
"defaultProps": Object {
818872
"onRequestClose": [Function],
819873
"onRequestSubmit": [Function],
@@ -2168,22 +2222,8 @@ Map {
21682222
"_calculateChangedBits": null,
21692223
"_currentRenderer": null,
21702224
"_currentRenderer2": null,
2171-
"_currentValue": FeatureFlagScope {
2172-
"flags": Map {
2173-
"enable-css-custom-properties" => false,
2174-
"enable-use-controlled-state-with-value" => false,
2175-
"enable-css-grid" => false,
2176-
"enable-v11-release" => false,
2177-
},
2178-
},
2179-
"_currentValue2": FeatureFlagScope {
2180-
"flags": Map {
2181-
"enable-css-custom-properties" => false,
2182-
"enable-use-controlled-state-with-value" => false,
2183-
"enable-css-grid" => false,
2184-
"enable-v11-release" => false,
2185-
},
2186-
},
2225+
"_currentValue": "bx",
2226+
"_currentValue2": "bx",
21872227
"_threadCount": 0,
21882228
},
21892229
"defaultProps": Object {
@@ -2630,6 +2670,24 @@ Map {
26302670
"Provider": "React.Provider",
26312671
},
26322672
"FileUploader" => Object {
2673+
"contextType": Object {
2674+
"$$typeof": Symbol(react.context),
2675+
"Consumer": Object {
2676+
"$$typeof": Symbol(react.context),
2677+
"_calculateChangedBits": null,
2678+
"_context": [Circular],
2679+
},
2680+
"Provider": Object {
2681+
"$$typeof": Symbol(react.provider),
2682+
"_context": [Circular],
2683+
},
2684+
"_calculateChangedBits": null,
2685+
"_currentRenderer": null,
2686+
"_currentRenderer2": null,
2687+
"_currentValue": "bx",
2688+
"_currentValue2": "bx",
2689+
"_threadCount": 0,
2690+
},
26332691
"defaultProps": Object {
26342692
"accept": Array [],
26352693
"buttonKind": "primary",
@@ -4966,6 +5024,24 @@ Map {
49665024
},
49675025
"PrimaryButton" => Object {},
49685026
"ProgressIndicator" => Object {
5027+
"contextType": Object {
5028+
"$$typeof": Symbol(react.context),
5029+
"Consumer": Object {
5030+
"$$typeof": Symbol(react.context),
5031+
"_calculateChangedBits": null,
5032+
"_context": [Circular],
5033+
},
5034+
"Provider": Object {
5035+
"$$typeof": Symbol(react.provider),
5036+
"_context": [Circular],
5037+
},
5038+
"_calculateChangedBits": null,
5039+
"_currentRenderer": null,
5040+
"_currentRenderer2": null,
5041+
"_currentValue": "bx",
5042+
"_currentValue2": "bx",
5043+
"_threadCount": 0,
5044+
},
49695045
"defaultProps": Object {
49705046
"currentIndex": 0,
49715047
},
@@ -5819,6 +5895,24 @@ Map {
58195895
},
58205896
},
58215897
"Tabs" => Object {
5898+
"contextType": Object {
5899+
"$$typeof": Symbol(react.context),
5900+
"Consumer": Object {
5901+
"$$typeof": Symbol(react.context),
5902+
"_calculateChangedBits": null,
5903+
"_context": [Circular],
5904+
},
5905+
"Provider": Object {
5906+
"$$typeof": Symbol(react.provider),
5907+
"_context": [Circular],
5908+
},
5909+
"_calculateChangedBits": null,
5910+
"_currentRenderer": null,
5911+
"_currentRenderer2": null,
5912+
"_currentValue": "bx",
5913+
"_currentValue2": "bx",
5914+
"_threadCount": 0,
5915+
},
58225916
"defaultProps": Object {
58235917
"scrollIntoView": true,
58245918
"selected": 0,
@@ -6391,6 +6485,24 @@ Map {
63916485
"render": [Function],
63926486
},
63936487
"Tile" => Object {
6488+
"contextType": Object {
6489+
"$$typeof": Symbol(react.context),
6490+
"Consumer": Object {
6491+
"$$typeof": Symbol(react.context),
6492+
"_calculateChangedBits": null,
6493+
"_context": [Circular],
6494+
},
6495+
"Provider": Object {
6496+
"$$typeof": Symbol(react.provider),
6497+
"_context": [Circular],
6498+
},
6499+
"_calculateChangedBits": null,
6500+
"_currentRenderer": null,
6501+
"_currentRenderer2": null,
6502+
"_currentValue": "bx",
6503+
"_currentValue2": "bx",
6504+
"_threadCount": 0,
6505+
},
63946506
"defaultProps": Object {
63956507
"light": false,
63966508
},
@@ -6407,6 +6519,24 @@ Map {
64076519
},
64086520
},
64096521
"ClickableTile" => Object {
6522+
"contextType": Object {
6523+
"$$typeof": Symbol(react.context),
6524+
"Consumer": Object {
6525+
"$$typeof": Symbol(react.context),
6526+
"_calculateChangedBits": null,
6527+
"_context": [Circular],
6528+
},
6529+
"Provider": Object {
6530+
"$$typeof": Symbol(react.provider),
6531+
"_context": [Circular],
6532+
},
6533+
"_calculateChangedBits": null,
6534+
"_currentRenderer": null,
6535+
"_currentRenderer2": null,
6536+
"_currentValue": "bx",
6537+
"_currentValue2": "bx",
6538+
"_threadCount": 0,
6539+
},
64106540
"defaultProps": Object {
64116541
"clicked": false,
64126542
"light": false,
@@ -6507,6 +6637,24 @@ Map {
65076637
},
65086638
},
65096639
"ExpandableTile" => Object {
6640+
"contextType": Object {
6641+
"$$typeof": Symbol(react.context),
6642+
"Consumer": Object {
6643+
"$$typeof": Symbol(react.context),
6644+
"_calculateChangedBits": null,
6645+
"_context": [Circular],
6646+
},
6647+
"Provider": Object {
6648+
"$$typeof": Symbol(react.provider),
6649+
"_context": [Circular],
6650+
},
6651+
"_calculateChangedBits": null,
6652+
"_currentRenderer": null,
6653+
"_currentRenderer2": null,
6654+
"_currentValue": "bx",
6655+
"_currentValue2": "bx",
6656+
"_threadCount": 0,
6657+
},
65106658
"defaultProps": Object {
65116659
"expanded": false,
65126660
"light": false,
@@ -6562,13 +6710,49 @@ Map {
65626710
},
65636711
},
65646712
"TileAboveTheFoldContent" => Object {
6713+
"contextType": Object {
6714+
"$$typeof": Symbol(react.context),
6715+
"Consumer": Object {
6716+
"$$typeof": Symbol(react.context),
6717+
"_calculateChangedBits": null,
6718+
"_context": [Circular],
6719+
},
6720+
"Provider": Object {
6721+
"$$typeof": Symbol(react.provider),
6722+
"_context": [Circular],
6723+
},
6724+
"_calculateChangedBits": null,
6725+
"_currentRenderer": null,
6726+
"_currentRenderer2": null,
6727+
"_currentValue": "bx",
6728+
"_currentValue2": "bx",
6729+
"_threadCount": 0,
6730+
},
65656731
"propTypes": Object {
65666732
"children": Object {
65676733
"type": "node",
65686734
},
65696735
},
65706736
},
65716737
"TileBelowTheFoldContent" => Object {
6738+
"contextType": Object {
6739+
"$$typeof": Symbol(react.context),
6740+
"Consumer": Object {
6741+
"$$typeof": Symbol(react.context),
6742+
"_calculateChangedBits": null,
6743+
"_context": [Circular],
6744+
},
6745+
"Provider": Object {
6746+
"$$typeof": Symbol(react.provider),
6747+
"_context": [Circular],
6748+
},
6749+
"_calculateChangedBits": null,
6750+
"_currentRenderer": null,
6751+
"_currentRenderer2": null,
6752+
"_currentValue": "bx",
6753+
"_currentValue2": "bx",
6754+
"_threadCount": 0,
6755+
},
65726756
"propTypes": Object {
65736757
"children": Object {
65746758
"type": "node",

packages/react/src/components/ComposedModal/ComposedModal-test.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ const { prefix } = settings;
2020

2121
describe('<ModalHeader />', () => {
2222
describe('Renders as expected', () => {
23-
const titleWrapper = shallow(<ModalHeader title="Something" />);
24-
const labelWrapper = shallow(<ModalHeader label="Something" />);
23+
const titleWrapper = mount(<ModalHeader title="Something" />);
24+
const labelWrapper = mount(<ModalHeader label="Something" />);
2525

2626
it('does not render title if no title', () => {
2727
expect(
@@ -75,7 +75,7 @@ describe('<ModalBody />', () => {
7575

7676
describe('<ModalFooter />', () => {
7777
describe('Renders as expected', () => {
78-
const wrapper = shallow(
78+
const wrapper = mount(
7979
<ModalFooter className="extra-class">
8080
<p>Test</p>
8181
</ModalFooter>
@@ -89,10 +89,6 @@ describe('<ModalFooter />', () => {
8989
expect(wrapper.length).toBe(1);
9090
});
9191

92-
it('has the expected classes', () => {
93-
expect(wrapper.hasClass(`${prefix}--modal-footer`)).toEqual(true);
94-
});
95-
9692
it('renders extra classes passed in via className', () => {
9793
expect(wrapper.hasClass('extra-class')).toEqual(true);
9894
});
@@ -231,7 +227,7 @@ describe('<ComposedModal />', () => {
231227
});
232228

233229
it('avoids change the open state upon setting props, unless there the value actually changes', () => {
234-
const wrapper = shallow(<ComposedModal />);
230+
const wrapper = mount(<ComposedModal />);
235231
wrapper.setProps({ open: true });
236232
wrapper.setState({ open: false });
237233
wrapper.setProps({ open: true });

0 commit comments

Comments
 (0)