Skip to content

Commit

Permalink
test(auth): ensure modular API are exported properly (#7927)
Browse files Browse the repository at this point in the history
  • Loading branch information
russellwheatley authored Jul 30, 2024
1 parent 10d8fca commit 9387ff9
Show file tree
Hide file tree
Showing 5 changed files with 1,278 additions and 235 deletions.
276 changes: 275 additions & 1 deletion packages/auth/__tests__/auth.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,62 @@
import { describe, expect, it } from '@jest/globals';

import auth, { firebase } from '../lib';
import auth, {
firebase,
getAuth,
initializeAuth,
applyActionCode,
beforeAuthStateChanged,
checkActionCode,
confirmPasswordReset,
connectAuthEmulator,
createUserWithEmailAndPassword,
fetchSignInMethodsForEmail,
getMultiFactorResolver,
getRedirectResult,
isSignInWithEmailLink,
onAuthStateChanged,
onIdTokenChanged,
sendPasswordResetEmail,
sendSignInLinkToEmail,
setPersistence,
signInAnonymously,
signInWithCredential,
signInWithCustomToken,
signInWithEmailAndPassword,
signInWithEmailLink,
signInWithPhoneNumber,
verifyPhoneNumber,
signInWithPopup,
signInWithRedirect,
signOut,
updateCurrentUser,
useDeviceLanguage,
useUserAccessGroup,
verifyPasswordResetCode,
parseActionCodeURL,
deleteUser,
getIdToken,
getIdTokenResult,
linkWithCredential,
linkWithPhoneNumber,
linkWithPopup,
linkWithRedirect,
multiFactor,
reauthenticateWithCredential,
reauthenticateWithPhoneNumber,
reauthenticateWithPopup,
reauthenticateWithRedirect,
reload,
sendEmailVerification,
unlink,
updateEmail,
updatePassword,
updatePhoneNumber,
updateProfile,
verifyBeforeUpdateEmail,
getAdditionalUserInfo,
getCustomAuthDomain,
} from '../lib';

// @ts-ignore - We don't mind missing types here
import { NativeFirebaseError } from '../../app/lib/internal';
Expand Down Expand Up @@ -118,4 +174,222 @@ describe('Auth', function () {
expect(actual._auth).not.toBeNull();
});
});

describe('modular', function () {
it('`getAuth` function is properly exposed to end user', function () {
expect(getAuth).toBeDefined();
});

it('`initializeAuth` function is properly exposed to end user', function () {
expect(initializeAuth).toBeDefined();
});

it('`applyActionCode` function is properly exposed to end user', function () {
expect(applyActionCode).toBeDefined();
});

it('`beforeAuthStateChanged` function is properly exposed to end user', function () {
expect(beforeAuthStateChanged).toBeDefined();
});

it('`checkActionCode` function is properly exposed to end user', function () {
expect(checkActionCode).toBeDefined();
});

it('`confirmPasswordReset` function is properly exposed to end user', function () {
expect(confirmPasswordReset).toBeDefined();
});

it('`connectAuthEmulator` function is properly exposed to end user', function () {
expect(connectAuthEmulator).toBeDefined();
});

it('`createUserWithEmailAndPassword` function is properly exposed to end user', function () {
expect(createUserWithEmailAndPassword).toBeDefined();
});

it('`fetchSignInMethodsForEmail` function is properly exposed to end user', function () {
expect(fetchSignInMethodsForEmail).toBeDefined();
});

it('`getMultiFactorResolver` function is properly exposed to end user', function () {
expect(getMultiFactorResolver).toBeDefined();
});

it('`getRedirectResult` function is properly exposed to end user', function () {
expect(getRedirectResult).toBeDefined();
});

it('`isSignInWithEmailLink` function is properly exposed to end user', function () {
expect(isSignInWithEmailLink).toBeDefined();
});

it('`onAuthStateChanged` function is properly exposed to end user', function () {
expect(onAuthStateChanged).toBeDefined();
});

it('`onIdTokenChanged` function is properly exposed to end user', function () {
expect(onIdTokenChanged).toBeDefined();
});

it('`sendPasswordResetEmail` function is properly exposed to end user', function () {
expect(sendPasswordResetEmail).toBeDefined();
});

it('`sendSignInLinkToEmail` function is properly exposed to end user', function () {
expect(sendSignInLinkToEmail).toBeDefined();
});

it('`setPersistence` function is properly exposed to end user', function () {
expect(setPersistence).toBeDefined();
});

it('`signInAnonymously` function is properly exposed to end user', function () {
expect(signInAnonymously).toBeDefined();
});

it('`signInWithCredential` function is properly exposed to end user', function () {
expect(signInWithCredential).toBeDefined();
});

it('`signInWithCustomToken` function is properly exposed to end user', function () {
expect(signInWithCustomToken).toBeDefined();
});

it('`signInWithEmailAndPassword` function is properly exposed to end user', function () {
expect(signInWithEmailAndPassword).toBeDefined();
});

it('`signInWithEmailLink` function is properly exposed to end user', function () {
expect(signInWithEmailLink).toBeDefined();
});

it('`signInWithPhoneNumber` function is properly exposed to end user', function () {
expect(signInWithPhoneNumber).toBeDefined();
});

it('`verifyPhoneNumber` function is properly exposed to end user', function () {
expect(verifyPhoneNumber).toBeDefined();
});

it('`signInWithPopup` function is properly exposed to end user', function () {
expect(signInWithPopup).toBeDefined();
});

it('`signInWithRedirect` function is properly exposed to end user', function () {
expect(signInWithRedirect).toBeDefined();
});

it('`signOut` function is properly exposed to end user', function () {
expect(signOut).toBeDefined();
});

it('`updateCurrentUser` function is properly exposed to end user', function () {
expect(updateCurrentUser).toBeDefined();
});

it('`useDeviceLanguage` function is properly exposed to end user', function () {
expect(useDeviceLanguage).toBeDefined();
});

it('`useUserAccessGroup` function is properly exposed to end user', function () {
expect(useUserAccessGroup).toBeDefined();
});

it('`verifyPasswordResetCode` function is properly exposed to end user', function () {
expect(verifyPasswordResetCode).toBeDefined();
});

it('`parseActionCodeURL` function is properly exposed to end user', function () {
expect(parseActionCodeURL).toBeDefined();
});

it('`deleteUser` function is properly exposed to end user', function () {
expect(deleteUser).toBeDefined();
});

it('`getIdToken` function is properly exposed to end user', function () {
expect(getIdToken).toBeDefined();
});

it('`getIdTokenResult` function is properly exposed to end user', function () {
expect(getIdTokenResult).toBeDefined();
});

it('`linkWithCredential` function is properly exposed to end user', function () {
expect(linkWithCredential).toBeDefined();
});

it('`linkWithPhoneNumber` function is properly exposed to end user', function () {
expect(linkWithPhoneNumber).toBeDefined();
});

it('`linkWithPopup` function is properly exposed to end user', function () {
expect(linkWithPopup).toBeDefined();
});

it('`linkWithRedirect` function is properly exposed to end user', function () {
expect(linkWithRedirect).toBeDefined();
});

it('`multiFactor` function is properly exposed to end user', function () {
expect(multiFactor).toBeDefined();
});

it('`reauthenticateWithCredential` function is properly exposed to end user', function () {
expect(reauthenticateWithCredential).toBeDefined();
});

it('`reauthenticateWithPhoneNumber` function is properly exposed to end user', function () {
expect(reauthenticateWithPhoneNumber).toBeDefined();
});

it('`reauthenticateWithPopup` function is properly exposed to end user', function () {
expect(reauthenticateWithPopup).toBeDefined();
});

it('`reauthenticateWithRedirect` function is properly exposed to end user', function () {
expect(reauthenticateWithRedirect).toBeDefined();
});

it('`reload` function is properly exposed to end user', function () {
expect(reload).toBeDefined();
});

it('`sendEmailVerification` function is properly exposed to end user', function () {
expect(sendEmailVerification).toBeDefined();
});

it('`unlink` function is properly exposed to end user', function () {
expect(unlink).toBeDefined();
});

it('`updateEmail` function is properly exposed to end user', function () {
expect(updateEmail).toBeDefined();
});

it('`updatePassword` function is properly exposed to end user', function () {
expect(updatePassword).toBeDefined();
});

it('`updatePhoneNumber` function is properly exposed to end user', function () {
expect(updatePhoneNumber).toBeDefined();
});

it('`updateProfile` function is properly exposed to end user', function () {
expect(updateProfile).toBeDefined();
});

it('`verifyBeforeUpdateEmail` function is properly exposed to end user', function () {
expect(verifyBeforeUpdateEmail).toBeDefined();
});

it('`getAdditionalUserInfo` function is properly exposed to end user', function () {
expect(getAdditionalUserInfo).toBeDefined();
});

it('`getCustomAuthDomain` function is properly exposed to end user', function () {
expect(getCustomAuthDomain).toBeDefined();
});
});
});
18 changes: 17 additions & 1 deletion packages/auth/lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2156,10 +2156,24 @@ export namespace FirebaseAuthTypes {
* @param user The user.
*/
multiFactor(user: User): MultiFactorUser;
/**
* Returns the custom auth domain for the auth instance.
*/
getCustomAuthDomain(): Promise<string>;
/**
* Sets the language code on the auth instance. This is to match Firebase JS SDK behavior.
* Please use the `setLanguageCode` method for setting the language code.
*/
set languageCode(code: string | null);
/**
* Gets the config used to initialize this auth instance. This is to match Firebase JS SDK behavior.
* It returns an empty map as the config is not available in the native SDK.
*/
get config(): Map<any, any>;
}
}

type CallbackOrObserver<T extends (...args: any[]) => any> = T | { next: T };
export type CallbackOrObserver<T extends (...args: any[]) => any> = T | { next: T };

declare const defaultExport: ReactNativeFirebase.FirebaseModuleWithStaticsAndApp<
FirebaseAuthTypes.Module,
Expand Down Expand Up @@ -2188,3 +2202,5 @@ declare module '@react-native-firebase/app' {
}
}
}

export * from './modular';
Loading

0 comments on commit 9387ff9

Please sign in to comment.