diff --git a/packages/dynamic-links/__tests__/dynamic-links.test.ts b/packages/dynamic-links/__tests__/dynamic-links.test.ts new file mode 100644 index 0000000000..5a4d92a55e --- /dev/null +++ b/packages/dynamic-links/__tests__/dynamic-links.test.ts @@ -0,0 +1,48 @@ +import { describe, expect, it } from '@jest/globals'; + +import { + ShortLinkType, + getDynamicLinks, + buildLink, + buildShortLink, + getInitialLink, + onLink, + performDiagnostics, + resolveLink, +} from '../lib'; + +describe('Dynamic Links', function () { + describe('modular', function () { + it('`ShortLinkType` constant is properly exposed to end user', function () { + expect(ShortLinkType).toBeDefined(); + }); + + it('`getDynamicLinks` function is properly exposed to end user', function () { + expect(getDynamicLinks).toBeDefined(); + }); + + it('`buildLink` function is properly exposed to end user', function () { + expect(buildLink).toBeDefined(); + }); + + it('`buildShortLink` function is properly exposed to end user', function () { + expect(buildShortLink).toBeDefined(); + }); + + it('`getInitialLink` function is properly exposed to end user', function () { + expect(getInitialLink).toBeDefined(); + }); + + it('`onLink` function is properly exposed to end user', function () { + expect(onLink).toBeDefined(); + }); + + it('`performDiagnostics` function is properly exposed to end user', function () { + expect(performDiagnostics).toBeDefined(); + }); + + it('`resolveLink` function is properly exposed to end user', function () { + expect(resolveLink).toBeDefined(); + }); + }); +}); diff --git a/packages/dynamic-links/lib/index.d.ts b/packages/dynamic-links/lib/index.d.ts index c900925a83..691ab32286 100644 --- a/packages/dynamic-links/lib/index.d.ts +++ b/packages/dynamic-links/lib/index.d.ts @@ -625,6 +625,8 @@ export const firebase: ReactNativeFirebase.Module & { ): ReactNativeFirebase.FirebaseApp & { dynamicLinks(): FirebaseDynamicLinksTypes.Module }; }; +export * from './modular'; + export default defaultExport; /** diff --git a/packages/dynamic-links/lib/index.js b/packages/dynamic-links/lib/index.js index d8b510ce13..c4274f7529 100644 --- a/packages/dynamic-links/lib/index.js +++ b/packages/dynamic-links/lib/index.js @@ -24,12 +24,14 @@ import { isIOS } from '@react-native-firebase/app/lib/common'; import builder from './builder'; import version from './version'; +export const ShortLinkType = { + SHORT: 'SHORT', + UNGUESSABLE: 'UNGUESSABLE', + DEFAULT: 'DEFAULT', +}; + const statics = { - ShortLinkType: { - SHORT: 'SHORT', - UNGUESSABLE: 'UNGUESSABLE', - DEFAULT: 'DEFAULT', - }, + ShortLinkType, }; const namespace = 'dynamicLinks'; diff --git a/packages/dynamic-links/lib/modular/index.d.ts b/packages/dynamic-links/lib/modular/index.d.ts index 5ee31076c9..ea6ea04e36 100644 --- a/packages/dynamic-links/lib/modular/index.d.ts +++ b/packages/dynamic-links/lib/modular/index.d.ts @@ -1,7 +1,7 @@ import { ReactNativeFirebase } from '@react-native-firebase/app'; import { FirebaseDynamicLinksTypes } from '..'; -type DynamicLinks = FirebaseDynamicLinksTypes.Module; +type FirebaseDynamicLinks = FirebaseDynamicLinksTypes.Module; export declare const ShortLinkType = FirebaseDynamicLinksTypes.ShortLinkType; @@ -141,6 +141,6 @@ export declare function performDiagnostics(dynamicLinks: FirebaseDynamicLinks): * Can throw error with code 'resolve-link-error' if there is a processing error */ export declare function resolveLink( - dynmaicLinks: FirebaseDynamicLinks, + dynamicLinks: FirebaseDynamicLinks, link: string, ): Promise; diff --git a/packages/dynamic-links/lib/modular/index.js b/packages/dynamic-links/lib/modular/index.js index 9b87e60233..f5ad97615f 100644 --- a/packages/dynamic-links/lib/modular/index.js +++ b/packages/dynamic-links/lib/modular/index.js @@ -19,16 +19,14 @@ import { firebase } from '..'; /** * @typedef {import("..").FirebaseApp} FirebaseApp - * @typedef {import("..").FirebaseDynamicLinksTypes} FirebaseDynamicLinksTypes + * @typedef {import("..").FirebaseDynamicLinksTypes.ShortLinkType} ShortLinkType + * @typedef {import("..").FirebaseDynamicLinksTypes.DynamicLink} DynamicLink + * @typedef {import("..").FirebaseDynamicLinksTypes.DynamicLinkParameters} DynamicLinkParameters * @typedef {import("..").FirebaseDynamicLinksTypes.Module} FirebaseDynamicLinks */ // FIXME these are duplicated from the non-modular types and should be by reference -export const ShortLinkType = { - SHORT: 'SHORT', - UNGUESSABLE: 'UNGUESSABLE', - DEFAULT: 'DEFAULT', -}; +export { ShortLinkType } from '..'; /** * @returns {FirebaseDynamicLinks} @@ -40,7 +38,7 @@ export function getDynamicLinks() { /** * * @param {FirebaseDynamicLinks} dynamicLinks - * @param {FirebaseDynamicLinksTypes.DynamicLinkParameters} dynamicLinkParams + * @param {DynamicLinkParameters} dynamicLinkParams * @returns {Promise} */ export function buildLink(dynamicLinks, dynamicLinkParams) { @@ -50,8 +48,8 @@ export function buildLink(dynamicLinks, dynamicLinkParams) { /** * * @param {FirebaseDynamicLinks} dynamicLinks - * @param {FirebaseDynamicLinksTypes.DynamicLinkParameters} dynamicLinkParams - * @param {FirebaseDynamicLinksTypes.ShortLinkType | undefined} shortLinkType + * @param {DynamicLinkParameters} dynamicLinkParams + * @param {ShortLinkType | undefined} shortLinkType * @returns {Promise} */ export function buildShortLink(dynamicLinks, dynamicLinkParams, shortLinkType) { @@ -60,7 +58,7 @@ export function buildShortLink(dynamicLinks, dynamicLinkParams, shortLinkType) { /** * @param {FirebaseDynamicLinks} dynamicLinks - * @returns {Promise} + * @returns {Promise} */ export function getInitialLink(dynamicLinks) { return dynamicLinks.getInitialLink(); @@ -68,7 +66,7 @@ export function getInitialLink(dynamicLinks) { /** * @param {FirebaseDynamicLinks} dynamicLinks - * @param {(link: FirebaseDynamicLinksTypes.DynamicLink) => void} listener + * @param {(link: DynamicLink) => void} listener * @returns {() => void} */ export function onLink(dynamicLinks, listener) { @@ -86,10 +84,10 @@ export function performDiagnostics(dynamicLinks) { /** * - * @param {FirebaseDynamicLinks} dynmaicLinks + * @param {FirebaseDynamicLinks} dynamicLinks * @param {string} link - * @returns {Promise} + * @returns {Promise} */ -export function resolveLink(dynmaicLinks, link) { - return dynmaicLinks.resolveLink(link); +export function resolveLink(dynamicLinks, link) { + return dynamicLinks.resolveLink(link); }