Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion packages/app-distribution/__tests__/app-distribution.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ import {
signInTester,
checkForUpdate,
signOutTester,
type FirebaseAppDistribution,
type AppDistributionRelease,
type FirebaseApp,
} from '../lib';

import {
createCheckV9Deprecation,
CheckV9DeprecationFunction,
type CheckV9DeprecationFunction,
} from '../../app/lib/common/unitTestUtils';

// @ts-ignore test
Expand Down Expand Up @@ -64,6 +67,38 @@ describe('appDistribution()', function () {
it('`signOutTester` function is properly exposed to end user', function () {
expect(signOutTester).toBeDefined();
});

describe('types', function () {
it('`FirebaseAppDistribution` type is properly exposed to end user', function () {
const appDistribution: FirebaseAppDistribution = (
firebase.app() as unknown as FirebaseApp
).appDistribution();
expect(appDistribution).toBeDefined();
expect(appDistribution.isTesterSignedIn).toBeDefined();
expect(appDistribution.signInTester).toBeDefined();
expect(appDistribution.checkForUpdate).toBeDefined();
expect(appDistribution.signOutTester).toBeDefined();
});

it('`AppDistributionRelease` type is properly exposed to end user', function () {
// Type check - this will fail at compile time if type is not exported
const release: AppDistributionRelease = {
displayVersion: '1.0.0',
buildVersion: '123',
releaseNotes: 'Test release notes',
downloadURL: 'https://example.com/download',
isExpired: false,
};
expect(release).toBeDefined();
expect(release.displayVersion).toBe('1.0.0');
});

it('`FirebaseApp` type is properly exposed to end user', function () {
const app = firebase.app() as unknown as FirebaseApp;
expect(app).toBeDefined();
expect(app.appDistribution).toBeDefined();
});
});
});

describe('test `console.warn` is called for RNFB v8 API & not called for v9 API', function () {
Expand Down
166 changes: 0 additions & 166 deletions packages/app-distribution/lib/index.d.ts

This file was deleted.

31 changes: 31 additions & 0 deletions packages/app-distribution/lib/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (c) 2016-present Invertase Limited & Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this library except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

// Export types from types/app-distribution
export type {
AppDistributionRelease,
FirebaseAppDistribution,
FirebaseApp,
FirebaseAppDistributionTypes,
} from './types/app-distribution';

// Export modular API functions
export * from './modular';

// Export namespaced API
export * from './namespaced';
export { default } from './namespaced';
78 changes: 78 additions & 0 deletions packages/app-distribution/lib/modular.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* Copyright (c) 2016-present Invertase Limited & Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this library except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

import { getApp } from '@react-native-firebase/app';
import { MODULAR_DEPRECATION_ARG } from '@react-native-firebase/app/lib/common';
import type {
FirebaseAppDistribution,
AppDistributionRelease,
FirebaseApp,
} from './types/app-distribution';

/**
* Get an App Distribution instance for the specified app or current app.
* @param app - The FirebaseApp to use. Optional.
* @returns FirebaseAppDistribution instance for the given app.
*/
export function getAppDistribution(app?: FirebaseApp): FirebaseAppDistribution {
if (app) {
return (getApp(app.name) as any).appDistribution();
}
return (getApp() as any).appDistribution();
}

/**
* Returns true if the App Distribution tester is signed in.
* If not an iOS device, it always rejects, as neither false nor true seem like a sensible default.
* @param appDistribution - FirebaseAppDistribution instance.
* @returns Promise<boolean> - Whether the tester is signed in.
*/
export function isTesterSignedIn(appDistribution: FirebaseAppDistribution): Promise<boolean> {
return appDistribution.isTesterSignedIn.call(appDistribution, MODULAR_DEPRECATION_ARG);
}

/**
* Sign-in the App Distribution tester.
* If not an iOS device, it always rejects, as no defaults seem sensible.
* @param appDistribution - FirebaseAppDistribution instance.
* @returns Promise<void>
*/
export function signInTester(appDistribution: FirebaseAppDistribution): Promise<void> {
return appDistribution.signInTester.call(appDistribution, MODULAR_DEPRECATION_ARG);
}

/**
* Check to see whether a new distribution is available.
* If not an iOS device, it always rejects, as no default response seems sensible.
* @param appDistribution - FirebaseAppDistribution instance.
* @returns Promise<AppDistributionRelease> - Information about the available release.
*/
export function checkForUpdate(
appDistribution: FirebaseAppDistribution,
): Promise<AppDistributionRelease> {
return appDistribution.checkForUpdate.call(appDistribution, MODULAR_DEPRECATION_ARG);
}

/**
* Sign out App Distribution tester.
* If not an iOS device, it always rejects, as no default response seems sensible.
* @param appDistribution - FirebaseAppDistribution instance.
* @returns Promise<void>
*/
export function signOutTester(appDistribution: FirebaseAppDistribution): Promise<void> {
return appDistribution.signOutTester.call(appDistribution, MODULAR_DEPRECATION_ARG);
}
39 changes: 0 additions & 39 deletions packages/app-distribution/lib/modular/index.d.ts

This file was deleted.

Loading
Loading