File tree Expand file tree Collapse file tree 3 files changed +36
-9
lines changed
Expand file tree Collapse file tree 3 files changed +36
-9
lines changed Original file line number Diff line number Diff line change @@ -19,11 +19,34 @@ describe('Animated Mock', () => {
1919 Object . keys ( AnimatedImplementation ) ,
2020 ) ;
2121 } ) ;
22- it ( 'matches implementation params' , ( ) => {
23- Object . keys ( AnimatedImplementation ) . forEach ( key =>
24- expect ( AnimatedImplementation [ key ] . length ) . toEqual (
25- AnimatedMock [ key ] . length ,
26- ) ,
27- ) ;
22+ it ( 'matches implementation params' , done => {
23+ Object . keys ( AnimatedImplementation ) . forEach ( key => {
24+ if ( AnimatedImplementation [ key ] . length !== AnimatedMock [ key ] . length ) {
25+ done (
26+ new Error (
27+ 'key ' +
28+ key +
29+ ' had different lengths: ' +
30+ JSON . stringify (
31+ {
32+ impl : {
33+ len : AnimatedImplementation [ key ] . length ,
34+ type : typeof AnimatedImplementation [ key ] ,
35+ val : AnimatedImplementation [ key ] . toString ( ) ,
36+ } ,
37+ mock : {
38+ len : AnimatedMock [ key ] . length ,
39+ type : typeof AnimatedMock [ key ] ,
40+ val : AnimatedMock [ key ] . toString ( ) ,
41+ } ,
42+ } ,
43+ null ,
44+ 2 ,
45+ ) ,
46+ ) ,
47+ ) ;
48+ }
49+ } ) ;
50+ done ( ) ;
2851 } ) ;
2952} ) ;
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ const DeprecatedViewStylePropTypes = require('DeprecatedViewStylePropTypes');
1616
1717const invariant = require ( 'invariant' ) ;
1818
19- function createAnimatedComponent ( Component : any ) : any {
19+ function createAnimatedComponent ( Component : any , defaultProps : any ) : any {
2020 invariant (
2121 typeof Component !== 'function' ||
2222 ( Component . prototype && Component . prototype . isReactComponent ) ,
@@ -149,6 +149,7 @@ function createAnimatedComponent(Component: any): any {
149149 const props = this . _propsAnimated . __getValue ( ) ;
150150 return (
151151 < Component
152+ { ...defaultProps }
152153 { ...props }
153154 ref = { this . _setComponentRef }
154155 // The native driver updates views directly through the UI thread so we
Original file line number Diff line number Diff line change 6868 . mock ( 'AnimatedImplementation' , ( ) => {
6969 const AnimatedImplementation = jest . requireActual ( 'AnimatedImplementation' ) ;
7070 const oldCreate = AnimatedImplementation . createAnimatedComponent ;
71- AnimatedImplementation . createAnimatedComponent = function ( Component ) {
72- const Wrapped = oldCreate ( Component ) ;
71+ AnimatedImplementation . createAnimatedComponent = function (
72+ Component ,
73+ defaultProps ,
74+ ) {
75+ const Wrapped = oldCreate ( Component , defaultProps ) ;
7376 Wrapped . __skipSetNativeProps_FOR_TESTS_ONLY = true ;
7477 return Wrapped ;
7578 } ;
You can’t perform that action at this time.
0 commit comments