From cf39e7e9bd7e233527ba8b86504d30c02815776e Mon Sep 17 00:00:00 2001 From: abrahambotros Date: Thu, 15 Jun 2017 08:48:33 -0700 Subject: [PATCH] [react-navigation] Add test to navigate to next screen --- .../react-navigation-tests.tsx | 39 ++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/types/react-navigation/react-navigation-tests.tsx b/types/react-navigation/react-navigation-tests.tsx index 535a7a04af..3a4e02a16c 100644 --- a/types/react-navigation/react-navigation-tests.tsx +++ b/types/react-navigation/react-navigation-tests.tsx @@ -1,5 +1,8 @@ import * as React from 'react'; -import { View } from 'react-native'; +import { + TouchableOpacity, + View, +} from 'react-native'; import { addNavigationHelpers, NavigationScreenProps, @@ -28,6 +31,40 @@ class StartScreen extends React.Component { const id = this.props.navigation.state.params.id; const s = this.props.navigation.state.params.s; + return ( + + + + ); + } + private navigateToNextScreen = (): void => { + this.props.navigation.navigate( + ROUTE_NAME_NEXT_SCREEN, + { + id: this.props.navigation.state.params.id, + name: this.props.navigation.state.params.s, + } as NextScreenComponentProps, + ); + + } +} + +/** + * @class NextScreen @extends React.Component + */ +const ROUTE_NAME_NEXT_SCREEN = "NextScreen"; +interface NextScreenComponentProps { + id: number, + name: string, +} +interface NextScreenProps extends NavigationScreenProps { } +class NextScreen extends React.Component { + render() { + // Implicit type checks. + const navigationStateParams: NextScreenComponentProps = this.props.navigation.state.params; + const id = this.props.navigation.state.params.id; + const name = this.props.navigation.state.params.name; + return ( );