Created
September 30, 2023 04:14
-
-
Save YonatanKra/36887e963228b60487b44cb9067dae57 to your computer and use it in GitHub Desktop.
Tauri-demo: add onAuthStateChange callback call to login and signup emulators
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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