Skip to content

Instantly share code, notes, and snippets.

@YonatanKra
Last active September 30, 2023 04:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YonatanKra/f50d6bdf30fb75b937f9abc69993f0e8 to your computer and use it in GitHub Desktop.
Save YonatanKra/f50d6bdf30fb75b937f9abc69993f0e8 to your computer and use it in GitHub Desktop.
Tauri-demo: refactor login and signup mocks
function setUserCreds(firebaseAuth: any, successful: boolean, user = {
uid: '123',
email: 'test@test.com'
}) {
return async () => {
(firebaseAuth.getAuth as any).mockReturnValue({
currentUser: successful ? user : null
});
if (successful) firebaseAuth.authChangeCallback();
return {
user
};
}
}
function setLogin(firebaseAuth: any, successful: boolean) {
(firebaseAuth.signInWithEmailAndPassword as any).mockImplementation(setUserCreds(firebaseAuth, successful));
}
function setSignUp(firebaseAuth: any, successful: boolean) {
(firebaseAuth.createUserWithEmailAndPassword as any).mockImplementation(setUserCreds(firebaseAuth, successful));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment