diff --git a/packages/installations/__tests__/installations.test.ts b/packages/installations/__tests__/installations.test.ts index ab8066a796..ee747d85a4 100644 --- a/packages/installations/__tests__/installations.test.ts +++ b/packages/installations/__tests__/installations.test.ts @@ -1,6 +1,13 @@ import { describe, expect, it } from '@jest/globals'; -import { firebase, getInstallations, onIdChange } from '../lib'; +import { + firebase, + getInstallations, + deleteInstallations, + getId, + getToken, + onIdChange, +} from '../lib'; describe('installations()', function () { describe('namespace', function () { @@ -22,23 +29,32 @@ describe('installations()', function () { }); describe('modular', function () { + it('`getInstallations` function is properly exposed to end user', function () { + expect(getInstallations).toBeDefined(); + }); + + it('`deleteInstallations` function is properly exposed to end user', function () { + expect(deleteInstallations).toBeDefined(); + }); + + it('`getId` function is properly exposed to end user', function () { + expect(getId).toBeDefined(); + }); + + it('`getToken` function is properly exposed to end user', function () { + expect(getToken).toBeDefined(); + }); + + it('`onIdChange` function is properly exposed to end user', function () { + expect(onIdChange).toBeDefined(); + }); + describe('getInstallations', function () { it('returns an instance of Installations', async function () { const installations = getInstallations(); expect(installations).toBeDefined(); // expect(installations.app).toBeDefined(); }); - - // it('supports multiple apps', async function () { - // const app = firebase.app(); - // const secondaryApp = firebase.app('secondaryFromNative'); - - // const installations = getInstallations(); - // const installationsForApp = getInstallations(secondaryApp); - - // expect(installations.app).toEqual(app); - // expect(installationsForApp.app).toEqual(secondaryApp); - // }); }); describe('onIdChange', function () { diff --git a/packages/installations/lib/modular/index.d.ts b/packages/installations/lib/modular/index.d.ts index b22f1f1f37..8e493590ac 100644 --- a/packages/installations/lib/modular/index.d.ts +++ b/packages/installations/lib/modular/index.d.ts @@ -1,30 +1,29 @@ import { ReactNativeFirebase } from '@react-native-firebase/app'; import { FirebaseInstallationsTypes } from '../index'; +import FirebaseInstallations = FirebaseInstallationsTypes.Module; /** * Returns an instance of Installations associated with the given FirebaseApp instance. */ export declare function getInstallations( app?: ReactNativeFirebase.FirebaseApp, -): FirebaseInstallationsTypes.Module; +): FirebaseInstallations; /** * Deletes the Firebase Installation and all associated data. */ -export declare function deleteInstallations( - installations?: FirebaseInstallationsTypes.Module, -): Promise; +export declare function deleteInstallations(installations?: FirebaseInstallations): Promise; /** * Creates a Firebase Installation if there isn't one for the app and returns the Installation ID. */ -export declare function getId(installations: FirebaseInstallationsTypes.Module): Promise; +export declare function getId(installations: FirebaseInstallations): Promise; /** * Returns a Firebase Installations auth token, identifying the current Firebase Installation. */ export declare function getToken( - installations: FirebaseInstallationsTypes.Module, + installations: FirebaseInstallations, forceRefresh?: boolean, ): Promise; @@ -37,6 +36,6 @@ declare type IdChangeUnsubscribeFn = () => void; * Sets a new callback that will get called when Installation ID changes. Returns an unsubscribe function that will remove the callback when called. */ export declare function onIdChange( - installations: FirebaseInstallationsTypes.Module, + installations: FirebaseInstallations, callback: IdChangeCallbackFn, ): IdChangeUnsubscribeFn; diff --git a/packages/installations/lib/modular/index.js b/packages/installations/lib/modular/index.js index 0c83c23c75..7285dbdd20 100644 --- a/packages/installations/lib/modular/index.js +++ b/packages/installations/lib/modular/index.js @@ -18,9 +18,9 @@ import { firebase } from '..'; /** - * @param {import("@react-native-firebase/app").ReactNativeFirebase.FirebaseApp} app - * @returns {import("..").FirebaseInstallationsTypes.Module} + * @typedef {import('..').FirebaseInstallationsTypes.Module} FirebaseInstallation */ + export function getInstallations(app) { if (app) { return firebase.app(app.name).installations(); @@ -29,7 +29,7 @@ export function getInstallations(app) { } /** - * @param {import("..").FirebaseInstallationsTypes.Module} installations + * @param {FirebaseInstallation} installations * @returns {Promise} */ export function deleteInstallations(installations) { @@ -37,7 +37,7 @@ export function deleteInstallations(installations) { } /** - * @param {import("..").FirebaseInstallationsTypes.Module} installations + * @param {FirebaseInstallation} installations * @returns {Promise} */ export function getId(installations) { @@ -45,7 +45,7 @@ export function getId(installations) { } /** - * @param {import("..").FirebaseInstallationsTypes.Module} installations + * @param {FirebaseInstallation} installations * @param {boolean | undefined} forceRefresh * @returns {Promise} */ @@ -54,7 +54,7 @@ export function getToken(installations, forceRefresh) { } /** - * @param {import("..").FirebaseInstallationsTypes.Module} installations + * @param {FirebaseInstallation} installations * @param {(string) => void} callback * @returns {() => void} */