function:
async function signInWithPhoneNumber(phone: string) {
setLoadingAuth(true);
const sendSmsToPhoneNumber = httpsCallable(functions, 'sendSms');
try {
await sendSmsToPhoneNumber({
phone_number: phone,
});
setActiveCredentialVerificationScreen(true);
} catch (error) {
throw error;
} finally {
setLoadingAuth(false);
}
}
this cloud function takes a phone number and returns an object:
{
"result": {
"success": true
}
}
test('signInWithPhoneNumber', () => {
const { result } = renderHook(() => useAuth(), {
wrapper: AuthProvider,
});
act(() => {
result.current.signInWithPhoneNumber('99999999999');
});
expect(result.current.user).toBe(null);
});