Skip to content

Commit 17a224a

Browse files
committed
Run ReactFabric-test.internal.js in xplat variant
The explicit mock override in this test was causing it to always run as native-oss instead of also as xplat. This moves the test to use `// @gate persistent` instead to run it in all persistent configs.
1 parent 7baae65 commit 17a224a

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

packages/react-native-renderer/src/__tests__/ReactFabric-test.internal.js

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ const SEND_ACCESSIBILITY_EVENT_REQUIRES_HOST_COMPONENT =
2525
"sendAccessibilityEvent was called with a ref that isn't a " +
2626
'native component. Use React.forwardRef to get access to the underlying native component';
2727

28-
jest.mock('shared/ReactFeatureFlags', () =>
29-
require('shared/forks/ReactFeatureFlags.native-oss'),
30-
);
31-
3228
describe('ReactFabric', () => {
3329
beforeEach(() => {
3430
jest.resetModules();
@@ -45,6 +41,7 @@ describe('ReactFabric', () => {
4541
act = require('internal-test-utils').act;
4642
});
4743

44+
// @gate persistent
4845
it('should be able to create and render a native component', async () => {
4946
const View = createReactNativeComponentClass('RCTView', () => ({
5047
validAttributes: {foo: true},
@@ -59,6 +56,7 @@ describe('ReactFabric', () => {
5956
expect(nativeFabricUIManager.completeRoot).toBeCalled();
6057
});
6158

59+
// @gate persistent
6260
it('should be able to create and update a native component', async () => {
6361
const View = createReactNativeComponentClass('RCTView', () => ({
6462
validAttributes: {foo: true},
@@ -93,6 +91,7 @@ describe('ReactFabric', () => {
9391
});
9492
});
9593

94+
// @gate persistent
9695
it('should not call FabricUIManager.cloneNode after render for properties that have not changed', async () => {
9796
const Text = createReactNativeComponentClass('RCTText', () => ({
9897
validAttributes: {foo: true},
@@ -164,6 +163,7 @@ describe('ReactFabric', () => {
164163
).toHaveBeenCalledTimes(1);
165164
});
166165

166+
// @gate persistent
167167
it('should only pass props diffs to FabricUIManager.cloneNode', async () => {
168168
const Text = createReactNativeComponentClass('RCTText', () => ({
169169
validAttributes: {foo: true, bar: true},
@@ -225,6 +225,7 @@ describe('ReactFabric', () => {
225225
).toMatchSnapshot();
226226
});
227227

228+
// @gate persistent
228229
it('should not clone nodes without children when updating props', async () => {
229230
const View = createReactNativeComponentClass('RCTView', () => ({
230231
validAttributes: {foo: true},
@@ -273,6 +274,7 @@ describe('ReactFabric', () => {
273274
expect(nativeFabricUIManager.completeRoot).toBeCalled();
274275
});
275276

277+
// @gate persistent
276278
it('should call dispatchCommand for native refs', async () => {
277279
const View = createReactNativeComponentClass('RCTView', () => ({
278280
validAttributes: {foo: true},
@@ -303,6 +305,7 @@ describe('ReactFabric', () => {
303305
);
304306
});
305307

308+
// @gate persistent
306309
it('should warn and no-op if calling dispatchCommand on non native refs', async () => {
307310
class BasicClass extends React.Component {
308311
render() {
@@ -334,6 +337,7 @@ describe('ReactFabric', () => {
334337
expect(nativeFabricUIManager.dispatchCommand).not.toBeCalled();
335338
});
336339

340+
// @gate persistent
337341
it('should call sendAccessibilityEvent for native refs', async () => {
338342
const View = createReactNativeComponentClass('RCTView', () => ({
339343
validAttributes: {foo: true},
@@ -365,6 +369,7 @@ describe('ReactFabric', () => {
365369
);
366370
});
367371

372+
// @gate persistent
368373
it('should warn and no-op if calling sendAccessibilityEvent on non native refs', async () => {
369374
class BasicClass extends React.Component {
370375
render() {
@@ -396,6 +401,7 @@ describe('ReactFabric', () => {
396401
expect(nativeFabricUIManager.sendAccessibilityEvent).not.toBeCalled();
397402
});
398403

404+
// @gate persistent
399405
it('returns the correct instance and calls it in the callback', () => {
400406
const View = createReactNativeComponentClass('RCTView', () => ({
401407
validAttributes: {foo: true},
@@ -417,6 +423,7 @@ describe('ReactFabric', () => {
417423
expect(a).toBe(c);
418424
});
419425

426+
// @gate persistent
420427
it('renders and reorders children', async () => {
421428
const View = createReactNativeComponentClass('RCTView', () => ({
422429
validAttributes: {title: true},
@@ -425,6 +432,7 @@ describe('ReactFabric', () => {
425432

426433
class Component extends React.Component {
427434
render() {
435+
// @gate persistent
428436
const chars = this.props.chars.split('');
429437
return (
430438
<View>
@@ -455,6 +463,7 @@ describe('ReactFabric', () => {
455463
).toMatchSnapshot();
456464
});
457465

466+
// @gate persistent
458467
it('recreates host parents even if only children changed', async () => {
459468
const View = createReactNativeComponentClass('RCTView', () => ({
460469
validAttributes: {title: true},
@@ -469,6 +478,7 @@ describe('ReactFabric', () => {
469478
chars: before,
470479
};
471480
render() {
481+
// @gate persistent
472482
const chars = this.state.chars.split('');
473483
return (
474484
<View>
@@ -504,6 +514,7 @@ describe('ReactFabric', () => {
504514
).toMatchSnapshot();
505515
});
506516

517+
// @gate persistent
507518
it('calls setState with no arguments', async () => {
508519
let mockArgs;
509520
class Component extends React.Component {
@@ -521,6 +532,7 @@ describe('ReactFabric', () => {
521532
expect(mockArgs.length).toEqual(0);
522533
});
523534

535+
// @gate persistent
524536
it('should call complete after inserting children', async () => {
525537
const View = createReactNativeComponentClass('RCTView', () => ({
526538
validAttributes: {foo: true},
@@ -547,6 +559,7 @@ describe('ReactFabric', () => {
547559
expect(snapshots).toMatchSnapshot();
548560
});
549561

562+
// @gate persistent
550563
it('should not throw when <View> is used inside of a <Text> ancestor', async () => {
551564
const Image = createReactNativeComponentClass('RCTImage', () => ({
552565
validAttributes: {},
@@ -580,6 +593,7 @@ describe('ReactFabric', () => {
580593
});
581594
});
582595

596+
// @gate persistent
583597
it('should console error for text not inside of a <Text> ancestor', async () => {
584598
const ScrollView = createReactNativeComponentClass('RCTScrollView', () => ({
585599
validAttributes: {},
@@ -612,6 +626,7 @@ describe('ReactFabric', () => {
612626
}).toErrorDev(['Text strings must be rendered within a <Text> component.']);
613627
});
614628

629+
// @gate persistent
615630
it('should not throw for text inside of an indirect <Text> ancestor', async () => {
616631
const Text = createReactNativeComponentClass('RCTText', () => ({
617632
validAttributes: {},
@@ -630,6 +645,7 @@ describe('ReactFabric', () => {
630645
});
631646
});
632647

648+
// @gate persistent
633649
it('dispatches events to the last committed props', async () => {
634650
const View = createReactNativeComponentClass('RCTView', () => ({
635651
validAttributes: {},
@@ -684,6 +700,7 @@ describe('ReactFabric', () => {
684700
});
685701

686702
describe('skipBubbling', () => {
703+
// @gate persistent
687704
it('should skip bubbling to ancestor if specified', async () => {
688705
const View = createReactNativeComponentClass('RCTView', () => ({
689706
validAttributes: {},
@@ -777,6 +794,7 @@ describe('ReactFabric', () => {
777794
});
778795
});
779796

797+
// @gate persistent
780798
it('dispatches event with target as instance', async () => {
781799
const View = createReactNativeComponentClass('RCTView', () => ({
782800
validAttributes: {
@@ -868,6 +886,7 @@ describe('ReactFabric', () => {
868886
expect.assertions(6);
869887
});
870888

889+
// @gate persistent
871890
it('findHostInstance_DEPRECATED should warn if used to find a host component inside StrictMode', async () => {
872891
const View = createReactNativeComponentClass('RCTView', () => ({
873892
validAttributes: {foo: true},
@@ -909,6 +928,7 @@ describe('ReactFabric', () => {
909928
expect(match).toBe(child);
910929
});
911930

931+
// @gate persistent
912932
it('findHostInstance_DEPRECATED should warn if passed a component that is inside StrictMode', async () => {
913933
const View = createReactNativeComponentClass('RCTView', () => ({
914934
validAttributes: {foo: true},
@@ -948,6 +968,7 @@ describe('ReactFabric', () => {
948968
expect(match).toBe(child);
949969
});
950970

971+
// @gate persistent
951972
it('findNodeHandle should warn if used to find a host component inside StrictMode', async () => {
952973
const View = createReactNativeComponentClass('RCTView', () => ({
953974
validAttributes: {foo: true},
@@ -989,6 +1010,7 @@ describe('ReactFabric', () => {
9891010
);
9901011
});
9911012

1013+
// @gate persistent
9921014
it('findNodeHandle should warn if passed a component that is inside StrictMode', async () => {
9931015
const View = createReactNativeComponentClass('RCTView', () => ({
9941016
validAttributes: {foo: true},
@@ -1028,6 +1050,7 @@ describe('ReactFabric', () => {
10281050
);
10291051
});
10301052

1053+
// @gate persistent
10311054
it('should no-op if calling sendAccessibilityEvent on unmounted refs', async () => {
10321055
const View = createReactNativeComponentClass('RCTView', () => ({
10331056
validAttributes: {foo: true},
@@ -1060,6 +1083,7 @@ describe('ReactFabric', () => {
10601083
expect(nativeFabricUIManager.sendAccessibilityEvent).not.toBeCalled();
10611084
});
10621085

1086+
// @gate persistent
10631087
it('getNodeFromInternalInstanceHandle should return the correct shadow node', async () => {
10641088
const View = createReactNativeComponentClass('RCTView', () => ({
10651089
validAttributes: {foo: true},
@@ -1084,6 +1108,7 @@ describe('ReactFabric', () => {
10841108
expect(node).toBe(expectedShadowNode);
10851109
});
10861110

1111+
// @gate persistent
10871112
it('getPublicInstanceFromInternalInstanceHandle should provide public instances for HostComponent', async () => {
10881113
const View = createReactNativeComponentClass('RCTView', () => ({
10891114
validAttributes: {foo: true},
@@ -1124,6 +1149,7 @@ describe('ReactFabric', () => {
11241149
expect(publicInstanceAfterUnmount).toBe(null);
11251150
});
11261151

1152+
// @gate persistent
11271153
it('getPublicInstanceFromInternalInstanceHandle should provide public instances for HostText', async () => {
11281154
jest.spyOn(ReactNativePrivateInterface, 'createPublicTextInstance');
11291155

0 commit comments

Comments
 (0)