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', () => {
19
19
Object . keys ( AnimatedImplementation ) ,
20
20
) ;
21
21
} ) ;
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 ( ) ;
28
51
} ) ;
29
52
} ) ;
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ const DeprecatedViewStylePropTypes = require('DeprecatedViewStylePropTypes');
16
16
17
17
const invariant = require ( 'invariant' ) ;
18
18
19
- function createAnimatedComponent ( Component : any ) : any {
19
+ function createAnimatedComponent ( Component : any , defaultProps : any ) : any {
20
20
invariant (
21
21
typeof Component !== 'function' ||
22
22
( Component . prototype && Component . prototype . isReactComponent ) ,
@@ -149,6 +149,7 @@ function createAnimatedComponent(Component: any): any {
149
149
const props = this . _propsAnimated . __getValue ( ) ;
150
150
return (
151
151
< Component
152
+ { ...defaultProps }
152
153
{ ...props }
153
154
ref = { this . _setComponentRef }
154
155
// The native driver updates views directly through the UI thread so we
Original file line number Diff line number Diff line change 68
68
. mock ( 'AnimatedImplementation' , ( ) => {
69
69
const AnimatedImplementation = jest . requireActual ( 'AnimatedImplementation' ) ;
70
70
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 ) ;
73
76
Wrapped . __skipSetNativeProps_FOR_TESTS_ONLY = true ;
74
77
return Wrapped ;
75
78
} ;
You can’t perform that action at this time.
0 commit comments