Skip to content

Instantly share code, notes, and snippets.

@YonatanKra
Created September 30, 2023 04:14
Show Gist options
  • Save YonatanKra/36887e963228b60487b44cb9067dae57 to your computer and use it in GitHub Desktop.
Save YonatanKra/36887e963228b60487b44cb9067dae57 to your computer and use it in GitHub Desktop.
Tauri-demo: add onAuthStateChange callback call to login and signup emulators
function setLogin(firebaseAuth: any, successful: boolean) {
(firebaseAuth.signInWithEmailAndPassword as any).mockImplementation(async () => {
const user = {
uid: '123',
email: '[email protected]'
};
(firebaseAuth.getAuth as any).mockReturnValue({
currentUser: successful ? user : null
});
if (successful) firebaseAuth.authChangeCallback();
return {
user
};
});
}
function setSignUp(firebaseAuth: any, successful: boolean) {
(firebaseAuth.createUserWithEmailAndPassword as any).mockImplementation(async () => {
const user = {
uid: '123',
email: '[email protected]'
};
(firebaseAuth.getAuth as any).mockReturnValue({
currentUser: successful ? user : null
});
if (successful) firebaseAuth.authChangeCallback();
return {
user
};
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment