I am creating a SignUp Page for which used fetch to get data from an api. For which I want to test it with dummy data within the code itself.
const Signup: FC<AuthNavigationProps<'Signup'>> = () => {
const {control, handleSubmit} = useForm();
const {setUser} = useUser();
const toast = useToast();
const signup: SubmitHandler<ISignupValues> = async ({email, password}) => {
try {
const res = await fetch(`${config.apiUrl}/api/signup`, {
method: 'POST',
body: JSON.stringify({
email,
password,
}),
});
if (res.ok) {
await setGenericPassword(email, password, CREDENTIALS_STORAGE_OPTIONS);
setUser({isLoggedIn: true, hasSessionExpired: false});
toast.setToast({message: 'Signup has succeeded', visible: true});
}
} catch (error) {
toast.setToast({message: 'Signup failed', visible: true});
}
};
return (
<View style={styles.container}>
<Text style={styles.helloText}>Welcome Tayze User!</Text>
<TextInput
placeholder="Email"
// inputProps={{keyboardType: 'email-address', autoCorrect: false}}
autoCorrect
style={styles.textInput}
/>
<TextInput
placeholder="Password"
// inputProps={{secureTextEntry: true}}
secureTextEntry
style={styles.textInput}
/>
<Button label="Sign up" onPress={() => handleSubmit(signup)()} />
</View>
);
};
export default Signup;
I want to create one mock data here and call it to check the login and signup pages.