File tree Expand file tree Collapse file tree 5 files changed +28
-15
lines changed Expand file tree Collapse file tree 5 files changed +28
-15
lines changed Original file line number Diff line number Diff line change 81
81
"react" : " 16.6.0-alpha.8af6728" ,
82
82
"react-dom" : " 16.6.0-alpha.8af6728" ,
83
83
"react-native" : " ~0.57.4" ,
84
+ "react-native-testing-library" : " ^1.5.0" ,
84
85
"react-native-vector-icons" : " ~6.0.2" ,
85
86
"react-test-renderer" : " 16.6.0-alpha.8af6728" ,
86
87
"release-it" : " ^7.6.2" ,
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ type Props = {|
10
10
| } ;
11
11
12
12
export default class PortalConsumer extends React . Component < Props > {
13
- componentDidMount ( ) {
13
+ async componentDidMount ( ) {
14
14
if ( ! this . props . manager ) {
15
15
throw new Error (
16
16
'Looks like you forgot to wrap your root component with `Provider` component from `react-native-paper`.\n\n' +
@@ -19,6 +19,9 @@ export default class PortalConsumer extends React.Component<Props> {
19
19
) ;
20
20
}
21
21
22
+ // Delay updating to prevent React from going to infinite loop
23
+ await Promise . resolve ( ) ;
24
+
22
25
this . _key = this . props . manager . mount ( this . props . children ) ;
23
26
}
24
27
Original file line number Diff line number Diff line change 1
1
/* @flow */
2
2
3
3
import * as React from 'react' ;
4
- import renderer from 'react-test-renderer ' ;
4
+ import { render , waitForElement } from 'react-native-testing-library ' ;
5
5
import { Text } from 'react-native' ;
6
6
import Portal from '../Portal/Portal' ;
7
7
8
- it ( 'renders portal with siblings' , ( ) => {
9
- const tree = renderer
10
- . create (
11
- < Portal . Host >
12
- < Text > Outside content</ Text >
13
- < Portal >
14
- < Text > Portal content</ Text >
15
- </ Portal >
16
- </ Portal . Host >
17
- )
18
- . toJSON ( ) ;
8
+ it ( 'renders portal with siblings' , async ( ) => {
9
+ const { toJSON, getByTestId } = render (
10
+ < Portal . Host >
11
+ < Text > Outside content</ Text >
12
+ < Portal >
13
+ < Text testID = "content" > Portal content</ Text >
14
+ </ Portal >
15
+ </ Portal . Host >
16
+ ) ;
19
17
20
- expect ( tree ) . toMatchSnapshot ( ) ;
18
+ await waitForElement ( ( ) => getByTestId ( 'content' ) ) ;
19
+
20
+ expect ( toJSON ( ) ) . toMatchSnapshot ( ) ;
21
21
} ) ;
Original file line number Diff line number Diff line change @@ -27,7 +27,9 @@ Array [
27
27
}
28
28
}
29
29
>
30
- <Text >
30
+ <Text
31
+ testID = " content"
32
+ >
31
33
Portal content
32
34
</Text >
33
35
</View >,
Original file line number Diff line number Diff line change @@ -7402,6 +7402,13 @@ react-lifecycles-compat@^3.0.4:
7402
7402
resolved "https://registry.yarnpkg.com/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz#4f1a273afdfc8f3488a8c516bfda78f872352362"
7403
7403
integrity sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA==
7404
7404
7405
+ react-native-testing-library@^1.5.0 :
7406
+ version "1.5.0"
7407
+ resolved "https://registry.yarnpkg.com/react-native-testing-library/-/react-native-testing-library-1.5.0.tgz#02762bf8cb5c1295a220d5e5d40ffc2ebecf31da"
7408
+ integrity sha512-ivS0K0uu8PnAU1DPi2LobZMDcWqQFZUFFP2NiGA1wFKgsGuv2zIGuiBY8mJVAtU2FnPMyVDfg5rL6XoyyCj+jg==
7409
+ dependencies :
7410
+ pretty-format "^23.6.0"
7411
+
7405
7412
react-native-vector-icons@~6.0.2 :
7406
7413
version "6.0.2"
7407
7414
resolved "https://registry.yarnpkg.com/react-native-vector-icons/-/react-native-vector-icons-6.0.2.tgz#826252a72d648cf957d46ada8df890318dac53e1"
You can’t perform that action at this time.
0 commit comments