I have a component that gets a goBack function as a param
the component effector animation (with react-native-reanimated-2) when the user press on any button,
after the animation is finished I call to goBack function.
I track on isOpen
value with useDeriveValue
of ract-native-reanimated-2
I need to make a test on this component to check that the function is called,
code on my button onClick
useDerivedValue(() => {
if (isOpen === 0) {
runOnJS(toGoBack)();
}
}, [isOpen]);
const toCloseWiteAnim = () => {
isOpen.value = withTiming(0);
};
but with this code my test pass
const toCloseWiteAnim = () => {
isOpen.value = withTiming(0, {}, (isAnimFinished) => {
if (isAnimFinished) {
runOnJS(toGoBack)();
}
});
};
const element = await queryByTestId('test.x-icon');
expect(element).toBeTruthy();
fireEvent.press(element);
expect(mockedGoBack).toBeCalled();
How can do that?