1- import "../../src/register" ;
2-
31import { expect } from "@assertive-ts/core" ;
42import { render , waitFor , userEvent } from "@testing-library/react-native" ;
53import { ReactElement , useCallback , useRef , useState } from "react" ;
@@ -9,6 +7,7 @@ import { Rect, Svg } from "react-native-svg";
97function TestScreen ( ) : ReactElement {
108
119 const [ animated , setAnimated ] = useState ( false ) ;
10+ const [ greet , setGreet ] = useState ( "Hello!" ) ;
1211
1312 const enterLeft = useRef ( new Animated . Value ( 100 , { useNativeDriver : true } ) ) . current ;
1413 const movePoint = useRef ( new Animated . ValueXY ( { x : 0 , y : 0 } , { useNativeDriver : true } ) ) . current ;
@@ -32,6 +31,10 @@ function TestScreen(): ReactElement {
3231 } ) ;
3332 } , [ ] ) ;
3433
34+ const changeGreet = useCallback ( ( ) => {
35+ setGreet ( "I said hello!!!" ) ;
36+ } , [ ] ) ;
37+
3538 return (
3639 < ScrollView >
3740 < View >
@@ -59,6 +62,8 @@ function TestScreen(): ReactElement {
5962 < Animated . View style = { { marginLeft : enterLeft } } >
6063 < Text > { `Animated view: ${ animated } ` } </ Text >
6164 </ Animated . View >
65+ < Button title = "Long press me!" onPress = { changeGreet } />
66+ < Text > { greet } </ Text >
6267 </ ScrollView >
6368 ) ;
6469}
@@ -90,6 +95,14 @@ describe("[Unit] register.test.ts", () => {
9095 await userEvent . press ( clickMeButton ) ;
9196
9297 await waitFor ( ( ) => getByText ( "Animated view: true" ) ) ;
98+
99+ const longPressButton = await findByText ( "Long press me!" ) ;
100+
101+ expect ( getByText ( "Hello!" ) ) . toBePresent ( ) ;
102+
103+ await userEvent . longPress ( longPressButton ) ;
104+
105+ await waitFor ( ( ) => getByText ( "I said hello!!!" ) ) ;
93106 } ) ;
94107 } ) ;
95108} ) ;
0 commit comments