Skip to content

Commit

Permalink
test(messaging): ensure modular API are exported properly (#7928)
Browse files Browse the repository at this point in the history
  • Loading branch information
russellwheatley authored Jul 29, 2024
1 parent ab1e2f6 commit c6b67c5
Show file tree
Hide file tree
Showing 5 changed files with 530 additions and 96 deletions.
153 changes: 153 additions & 0 deletions packages/messaging/__tests__/messaging.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
import { describe, expect, it } from '@jest/globals';

import {
getMessaging,
deleteToken,
getToken,
onMessage,
onNotificationOpenedApp,
onTokenRefresh,
requestPermission,
isAutoInitEnabled,
setAutoInitEnabled,
getInitialNotification,
getDidOpenSettingsForNotification,
getIsHeadless,
registerDeviceForRemoteMessages,
isDeviceRegisteredForRemoteMessages,
unregisterDeviceForRemoteMessages,
getAPNSToken,
setAPNSToken,
hasPermission,
onDeletedMessages,
onMessageSent,
onSendError,
setBackgroundMessageHandler,
setOpenSettingsForNotificationsHandler,
sendMessage,
subscribeToTopic,
unsubscribeFromTopic,
isDeliveryMetricsExportToBigQueryEnabled,
isSupported,
experimentalSetDeliveryMetricsExportedToBigQueryEnabled,
} from '../lib';

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

it('`experimentalSetDeliveryMetricsExportedToBigQueryEnabled` function is properly exposed to end user', function () {
expect(experimentalSetDeliveryMetricsExportedToBigQueryEnabled).toBeDefined();
});
});
});
2 changes: 2 additions & 0 deletions packages/messaging/lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1156,3 +1156,5 @@ declare module '@react-native-firebase/app' {
}
}
}

export * from './modular';
34 changes: 2 additions & 32 deletions packages/messaging/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,38 +34,6 @@ import { AppRegistry, Platform } from 'react-native';
import remoteMessageOptions from './remoteMessageOptions';
import version from './version';

export {
getMessaging,
deleteToken,
getToken,
onMessage,
onNotificationOpenedApp,
onTokenRefresh,
requestPermission,
isAutoInitEnabled,
setAutoInitEnabled,
getInitialNotification,
getDidOpenSettingsForNotification,
getIsHeadless,
registerDeviceForRemoteMessages,
isDeviceRegisteredForRemoteMessages,
unregisterDeviceForRemoteMessages,
getAPNSToken,
setAPNSToken,
hasPermission,
onDeletedMessages,
onMessageSent,
onSendError,
setBackgroundMessageHandler,
setOpenSettingsForNotificationsHandler,
sendMessage,
subscribeToTopic,
unsubscribeFromTopic,
experimentalSetDeliveryMetricsExportedToBigQueryEnabled,
isDeliveryMetricsExportToBigQueryEnabled,
isSupported,
} from '../modular/index';

const statics = {
AuthorizationStatus: {
NOT_DETERMINED: -1,
Expand Down Expand Up @@ -538,6 +506,8 @@ export default createModuleNamespace({
ModuleClass: FirebaseMessagingModule,
});

export * from './modular';

// import messaging, { firebase } from '@react-native-firebase/messaging';
// messaging().X(...);
// firebase.messaging().X(...);
Expand Down
Loading

0 comments on commit c6b67c5

Please sign in to comment.