@@ -45,6 +45,7 @@ describe('ReactNative', () => { |
45 | 45 | require('react-native/Libraries/ReactPrivate/ReactNativePrivateInterface').TextInputState; |
46 | 46 | }); |
47 | 47 |
|
| 48 | + // @gate !disableLegacyMode |
48 | 49 | it('should be able to create and render a native component', () => { |
49 | 50 | const View = createReactNativeComponentClass('RCTView', () => ({ |
50 | 51 | validAttributes: {foo: true}, |
@@ -58,6 +59,7 @@ describe('ReactNative', () => { |
58 | 59 | expect(UIManager.updateView).not.toBeCalled(); |
59 | 60 | }); |
60 | 61 |
|
| 62 | + // @gate !disableLegacyMode |
61 | 63 | it('should be able to create and update a native component', () => { |
62 | 64 | const View = createReactNativeComponentClass('RCTView', () => ({ |
63 | 65 | validAttributes: {foo: true}, |
@@ -79,6 +81,7 @@ describe('ReactNative', () => { |
79 | 81 | expect(UIManager.updateView).toBeCalledWith(3, 'RCTView', {foo: 'bar'}); |
80 | 82 | }); |
81 | 83 |
|
| 84 | + // @gate !disableLegacyMode |
82 | 85 | it('should not call UIManager.updateView after render for properties that have not changed', () => { |
83 | 86 | const Text = createReactNativeComponentClass('RCTText', () => ({ |
84 | 87 | validAttributes: {foo: true}, |
@@ -105,6 +108,7 @@ describe('ReactNative', () => { |
105 | 108 | expect(UIManager.updateView).toHaveBeenCalledTimes(4); |
106 | 109 | }); |
107 | 110 |
|
| 111 | + // @gate !disableLegacyMode |
108 | 112 | it('should call dispatchCommand for native refs', () => { |
109 | 113 | const View = createReactNativeComponentClass('RCTView', () => ({ |
110 | 114 | validAttributes: {foo: true}, |
@@ -133,6 +137,7 @@ describe('ReactNative', () => { |
133 | 137 | ); |
134 | 138 | }); |
135 | 139 |
|
| 140 | + // @gate !disableLegacyMode |
136 | 141 | it('should warn and no-op if calling dispatchCommand on non native refs', () => { |
137 | 142 | class BasicClass extends React.Component { |
138 | 143 | render() { |
@@ -162,6 +167,7 @@ describe('ReactNative', () => { |
162 | 167 | expect(UIManager.dispatchViewManagerCommand).not.toBeCalled(); |
163 | 168 | }); |
164 | 169 |
|
| 170 | + // @gate !disableLegacyMode |
165 | 171 | it('should call sendAccessibilityEvent for native refs', () => { |
166 | 172 | const View = createReactNativeComponentClass('RCTView', () => ({ |
167 | 173 | validAttributes: {foo: true}, |
@@ -192,6 +198,7 @@ describe('ReactNative', () => { |
192 | 198 | ).toHaveBeenCalledWith(expect.any(Number), 'focus'); |
193 | 199 | }); |
194 | 200 |
|
| 201 | + // @gate !disableLegacyMode |
195 | 202 | it('should warn and no-op if calling sendAccessibilityEvent on non native refs', () => { |
196 | 203 | class BasicClass extends React.Component { |
197 | 204 | render() { |
@@ -221,6 +228,7 @@ describe('ReactNative', () => { |
221 | 228 | expect(UIManager.sendAccessibilityEvent).not.toBeCalled(); |
222 | 229 | }); |
223 | 230 |
|
| 231 | + // @gate !disableLegacyMode |
224 | 232 | it('should not call UIManager.updateView from ref.setNativeProps for properties that have not changed', () => { |
225 | 233 | const View = createReactNativeComponentClass('RCTView', () => ({ |
226 | 234 | validAttributes: {foo: true}, |
@@ -254,6 +262,7 @@ describe('ReactNative', () => { |
254 | 262 | ); |
255 | 263 | }); |
256 | 264 |
|
| 265 | + // @gate !disableLegacyMode |
257 | 266 | it('should call UIManager.measure on ref.measure', () => { |
258 | 267 | const View = createReactNativeComponentClass('RCTView', () => ({ |
259 | 268 | validAttributes: {foo: true}, |
@@ -280,6 +289,7 @@ describe('ReactNative', () => { |
280 | 289 | expect(successCallback).toHaveBeenCalledWith(10, 10, 100, 100, 0, 0); |
281 | 290 | }); |
282 | 291 |
|
| 292 | + // @gate !disableLegacyMode |
283 | 293 | it('should call UIManager.measureInWindow on ref.measureInWindow', () => { |
284 | 294 | const View = createReactNativeComponentClass('RCTView', () => ({ |
285 | 295 | validAttributes: {foo: true}, |
@@ -306,6 +316,7 @@ describe('ReactNative', () => { |
306 | 316 | expect(successCallback).toHaveBeenCalledWith(10, 10, 100, 100); |
307 | 317 | }); |
308 | 318 |
|
| 319 | + // @gate !disableLegacyMode |
309 | 320 | it('should support reactTag in ref.measureLayout', () => { |
310 | 321 | const View = createReactNativeComponentClass('RCTView', () => ({ |
311 | 322 | validAttributes: {foo: true}, |
@@ -346,6 +357,7 @@ describe('ReactNative', () => { |
346 | 357 | expect(successCallback).toHaveBeenCalledWith(1, 1, 100, 100); |
347 | 358 | }); |
348 | 359 |
|
| 360 | + // @gate !disableLegacyMode |
349 | 361 | it('should support ref in ref.measureLayout of host components', () => { |
350 | 362 | const View = createReactNativeComponentClass('RCTView', () => ({ |
351 | 363 | validAttributes: {foo: true}, |
@@ -382,6 +394,7 @@ describe('ReactNative', () => { |
382 | 394 | expect(successCallback).toHaveBeenCalledWith(1, 1, 100, 100); |
383 | 395 | }); |
384 | 396 |
|
| 397 | + // @gate !disableLegacyMode |
385 | 398 | it('returns the correct instance and calls it in the callback', () => { |
386 | 399 | const View = createReactNativeComponentClass('RCTView', () => ({ |
387 | 400 | validAttributes: {foo: true}, |
@@ -403,6 +416,7 @@ describe('ReactNative', () => { |
403 | 416 | expect(a).toBe(c); |
404 | 417 | }); |
405 | 418 |
|
| 419 | + // @gate !disableLegacyMode |
406 | 420 | it('renders and reorders children', () => { |
407 | 421 | const View = createReactNativeComponentClass('RCTView', () => ({ |
408 | 422 | validAttributes: {title: true}, |
@@ -427,12 +441,59 @@ describe('ReactNative', () => { |
427 | 441 | const after = 'mxhpgwfralkeoivcstzy'; |
428 | 442 |
|
429 | 443 | ReactNative.render(<Component chars={before} />, 11); |
430 | | - expect(UIManager.__dumpHierarchyForJestTestsOnly()).toMatchSnapshot(); |
| 444 | + expect(UIManager.__dumpHierarchyForJestTestsOnly()).toMatchInlineSnapshot(` |
| 445 | + "<native root> {} |
| 446 | + RCTView null |
| 447 | + RCTView {"title":"a"} |
| 448 | + RCTView {"title":"b"} |
| 449 | + RCTView {"title":"c"} |
| 450 | + RCTView {"title":"d"} |
| 451 | + RCTView {"title":"e"} |
| 452 | + RCTView {"title":"f"} |
| 453 | + RCTView {"title":"g"} |
| 454 | + RCTView {"title":"h"} |
| 455 | + RCTView {"title":"i"} |
| 456 | + RCTView {"title":"j"} |
| 457 | + RCTView {"title":"k"} |
| 458 | + RCTView {"title":"l"} |
| 459 | + RCTView {"title":"m"} |
| 460 | + RCTView {"title":"n"} |
| 461 | + RCTView {"title":"o"} |
| 462 | + RCTView {"title":"p"} |
| 463 | + RCTView {"title":"q"} |
| 464 | + RCTView {"title":"r"} |
| 465 | + RCTView {"title":"s"} |
| 466 | + RCTView {"title":"t"}" |
| 467 | + `); |
431 | 468 |
|
432 | 469 | ReactNative.render(<Component chars={after} />, 11); |
433 | | - expect(UIManager.__dumpHierarchyForJestTestsOnly()).toMatchSnapshot(); |
| 470 | + expect(UIManager.__dumpHierarchyForJestTestsOnly()).toMatchInlineSnapshot(` |
| 471 | + "<native root> {} |
| 472 | + RCTView null |
| 473 | + RCTView {"title":"m"} |
| 474 | + RCTView {"title":"x"} |
| 475 | + RCTView {"title":"h"} |
| 476 | + RCTView {"title":"p"} |
| 477 | + RCTView {"title":"g"} |
| 478 | + RCTView {"title":"w"} |
| 479 | + RCTView {"title":"f"} |
| 480 | + RCTView {"title":"r"} |
| 481 | + RCTView {"title":"a"} |
| 482 | + RCTView {"title":"l"} |
| 483 | + RCTView {"title":"k"} |
| 484 | + RCTView {"title":"e"} |
| 485 | + RCTView {"title":"o"} |
| 486 | + RCTView {"title":"i"} |
| 487 | + RCTView {"title":"v"} |
| 488 | + RCTView {"title":"c"} |
| 489 | + RCTView {"title":"s"} |
| 490 | + RCTView {"title":"t"} |
| 491 | + RCTView {"title":"z"} |
| 492 | + RCTView {"title":"y"}" |
| 493 | + `); |
434 | 494 | }); |
435 | 495 |
|
| 496 | + // @gate !disableLegacyMode |
436 | 497 | it('calls setState with no arguments', () => { |
437 | 498 | let mockArgs; |
438 | 499 | class Component extends React.Component { |
@@ -448,6 +509,7 @@ describe('ReactNative', () => { |
448 | 509 | expect(mockArgs.length).toEqual(0); |
449 | 510 | }); |
450 | 511 |
|
| 512 | + // @gate !disableLegacyMode |
451 | 513 | it('should not throw when <View> is used inside of a <Text> ancestor', () => { |
452 | 514 | const Image = createReactNativeComponentClass('RCTImage', () => ({ |
453 | 515 | validAttributes: {}, |
@@ -478,6 +540,7 @@ describe('ReactNative', () => { |
478 | 540 | ); |
479 | 541 | }); |
480 | 542 |
|
| 543 | + // @gate !disableLegacyMode |
481 | 544 | it('should throw for text not inside of a <Text> ancestor', async () => { |
482 | 545 | const ScrollView = createReactNativeComponentClass('RCTScrollView', () => ({ |
483 | 546 | validAttributes: {}, |
@@ -512,6 +575,7 @@ describe('ReactNative', () => { |
512 | 575 | ); |
513 | 576 | }); |
514 | 577 |
|
| 578 | + // @gate !disableLegacyMode |
515 | 579 | it('should not throw for text inside of an indirect <Text> ancestor', () => { |
516 | 580 | const Text = createReactNativeComponentClass('RCTText', () => ({ |
517 | 581 | validAttributes: {}, |
@@ -528,6 +592,7 @@ describe('ReactNative', () => { |
528 | 592 | ); |
529 | 593 | }); |
530 | 594 |
|
| 595 | + // @gate !disableLegacyMode |
531 | 596 | it('findHostInstance_DEPRECATED should warn if used to find a host component inside StrictMode', () => { |
532 | 597 | const View = createReactNativeComponentClass('RCTView', () => ({ |
533 | 598 | validAttributes: {foo: true}, |
@@ -564,6 +629,7 @@ describe('ReactNative', () => { |
564 | 629 | expect(match).toBe(child); |
565 | 630 | }); |
566 | 631 |
|
| 632 | + // @gate !disableLegacyMode |
567 | 633 | it('findHostInstance_DEPRECATED should warn if passed a component that is inside StrictMode', () => { |
568 | 634 | const View = createReactNativeComponentClass('RCTView', () => ({ |
569 | 635 | validAttributes: {foo: true}, |
@@ -601,6 +667,7 @@ describe('ReactNative', () => { |
601 | 667 | expect(match).toBe(child); |
602 | 668 | }); |
603 | 669 |
|
| 670 | + // @gate !disableLegacyMode |
604 | 671 | it('findNodeHandle should warn if used to find a host component inside StrictMode', () => { |
605 | 672 | const View = createReactNativeComponentClass('RCTView', () => ({ |
606 | 673 | validAttributes: {foo: true}, |
@@ -635,6 +702,7 @@ describe('ReactNative', () => { |
635 | 702 | expect(match).toBe(child._nativeTag); |
636 | 703 | }); |
637 | 704 |
|
| 705 | + // @gate !disableLegacyMode |
638 | 706 | it('findNodeHandle should warn if passed a component that is inside StrictMode', () => { |
639 | 707 | const View = createReactNativeComponentClass('RCTView', () => ({ |
640 | 708 | validAttributes: {foo: true}, |
@@ -670,6 +738,7 @@ describe('ReactNative', () => { |
670 | 738 | expect(match).toBe(child._nativeTag); |
671 | 739 | }); |
672 | 740 |
|
| 741 | + // @gate !disableLegacyMode |
673 | 742 | it('blur on host component calls TextInputState', () => { |
674 | 743 | const View = createReactNativeComponentClass('RCTView', () => ({ |
675 | 744 | validAttributes: {foo: true}, |
@@ -687,6 +756,7 @@ describe('ReactNative', () => { |
687 | 756 | expect(TextInputState.blurTextInput).toHaveBeenCalledWith(viewRef.current); |
688 | 757 | }); |
689 | 758 |
|
| 759 | + // @gate !disableLegacyMode |
690 | 760 | it('focus on host component calls TextInputState', () => { |
691 | 761 | const View = createReactNativeComponentClass('RCTView', () => ({ |
692 | 762 | validAttributes: {foo: true}, |
|