mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-22 20:51:29 +10:00
Jest mocks: added @reach/router and stub for Firebase auth signOut method
This commit is contained in:
17
__mocks__/@reach/router.js
Normal file
17
__mocks__/@reach/router.js
Normal file
@ -0,0 +1,17 @@
|
||||
import { delay } from '../../src/utils/index';
|
||||
|
||||
const ReachRouter = jest.requireActual('@reach/router');
|
||||
|
||||
const defaultDelayInMilliseconds = 100;
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const navigate = async (to, options) => {
|
||||
await delay(defaultDelayInMilliseconds);
|
||||
|
||||
return Promise.resolve();
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
...ReachRouter,
|
||||
navigate: jest.fn(navigate),
|
||||
};
|
||||
@ -57,7 +57,7 @@ class Auth {
|
||||
user.email,
|
||||
user.isAnonymous,
|
||||
user.uid,
|
||||
async () => {},
|
||||
this.signOut,
|
||||
);
|
||||
|
||||
await delay(Constants.defaultDelayInMilliseconds);
|
||||
@ -68,6 +68,20 @@ class Auth {
|
||||
|
||||
return this._currentUser;
|
||||
}
|
||||
|
||||
async signOut() {
|
||||
if (this._currentUser === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._currentUser = null;
|
||||
|
||||
await delay(Constants.defaultDelayInMilliseconds);
|
||||
|
||||
this.onAuthStateChangedObservers.forEach((observer) =>
|
||||
observer(this._currentUser),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default Auth;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
const deleteUserFunctionName = 'deleteUser';
|
||||
|
||||
const defaultDelayInMilliseconds = 2000;
|
||||
const defaultDelayInMilliseconds = 100;
|
||||
|
||||
class Functions {
|
||||
static get deleteUserFunctionName() {
|
||||
|
||||
Reference in New Issue
Block a user