Rename registerRemoteNotificationOpened to registerNotificationOpened

This commit is contained in:
yogevbd
2020-01-17 15:25:25 +02:00
parent 8c50adb8f3
commit b54ba78b89
7 changed files with 19 additions and 19 deletions

View File

@@ -30,7 +30,7 @@ export class NativeEventsReceiver {
return this.emitter.addListener('pushKitNotificationReceived', callback);
}
public registerRemoteNotificationOpened(callback: (notification: Notification, completion: () => void, actionResponse?: NotificationActionResponse) => void): EmitterSubscription {
public registerNotificationOpened(callback: (notification: Notification, completion: () => void, actionResponse?: NotificationActionResponse) => void): EmitterSubscription {
return this.emitter.addListener('notificationOpened', (response, completion) => {
const action = response.action ? new NotificationActionResponse(response.action) : undefined
callback(this.notificationFactory.fromPayload(response.notification), completion, action);

View File

@@ -149,10 +149,10 @@ describe('EventsRegistry', () => {
it('delegates to nativeEventsReceiver', () => {
const cb = jest.fn();
uut.registerRemoteNotificationOpened(cb);
uut.registerNotificationOpened(cb);
expect(mockNativeEventsReceiver.registerRemoteNotificationOpened).toHaveBeenCalledTimes(1);
expect(mockNativeEventsReceiver.registerRemoteNotificationOpened).toHaveBeenCalledWith(expect.any(Function));
expect(mockNativeEventsReceiver.registerNotificationOpened).toHaveBeenCalledTimes(1);
expect(mockNativeEventsReceiver.registerNotificationOpened).toHaveBeenCalledWith(expect.any(Function));
});
it('should wrap callback with completion block', () => {
@@ -160,8 +160,8 @@ describe('EventsRegistry', () => {
const notification: Notification = new Notification({identifier: 'identifier'});
const response: NotificationResponse = {notification, identifier: 'responseId'};
uut.registerRemoteNotificationOpened(wrappedCallback);
const call = mockNativeEventsReceiver.registerRemoteNotificationOpened.mock.calls[0][0];
uut.registerNotificationOpened(wrappedCallback);
const call = mockNativeEventsReceiver.registerNotificationOpened.mock.calls[0][0];
call(response);
expect(wrappedCallback).toBeCalledWith(response, expect.any(Function));
@@ -172,23 +172,23 @@ describe('EventsRegistry', () => {
const notification: Notification = new Notification({identifier: 'identifier'});
const expectedResponse: NotificationResponse = {notification, identifier: 'responseId'}
uut.registerRemoteNotificationOpened((response) => {
uut.registerNotificationOpened((response) => {
expect(response).toEqual(expectedResponse);
});
const call = mockNativeEventsReceiver.registerRemoteNotificationOpened.mock.calls[0][0];
const call = mockNativeEventsReceiver.registerNotificationOpened.mock.calls[0][0];
call(expectedResponse);
});
it('calling completion should invoke finishHandlingAction', () => {
const expectedNotification: Notification = new Notification({identifier: 'notificationId'});
uut.registerRemoteNotificationOpened((notification, completion) => {
uut.registerNotificationOpened((notification, completion) => {
completion();
expect(expectedNotification).toEqual(notification);
expect(mockNativeCommandsSender.finishHandlingAction).toBeCalledWith(notification.identifier);
});
const call = mockNativeEventsReceiver.registerRemoteNotificationOpened.mock.calls[0][0];
const call = mockNativeEventsReceiver.registerNotificationOpened.mock.calls[0][0];
call(expectedNotification);
});
@@ -196,13 +196,13 @@ describe('EventsRegistry', () => {
Platform.OS = 'android';
const expectedNotification: Notification = new Notification({identifier: 'notificationId'});
uut.registerRemoteNotificationOpened((notification, completion) => {
uut.registerNotificationOpened((notification, completion) => {
completion();
expect(expectedNotification).toEqual(notification);
expect(mockNativeCommandsSender.finishHandlingAction).toBeCalledTimes(0);
});
const call = mockNativeEventsReceiver.registerRemoteNotificationOpened.mock.calls[0][0];
const call = mockNativeEventsReceiver.registerNotificationOpened.mock.calls[0][0];
call(expectedNotification);
});
});

View File

@@ -27,8 +27,8 @@ export class EventsRegistry {
return this.nativeEventsReceiver.registerRemoteNotificationReceived(this.completionCallbackWrapper.wrapReceivedBackgroundCallback(callback));
}
public registerRemoteNotificationOpened(callback: (response: NotificationResponse, completion: () => void) => void): EmitterSubscription {
return this.nativeEventsReceiver.registerRemoteNotificationOpened(this.completionCallbackWrapper.wrapOpenedCallback(callback));
public registerNotificationOpened(callback: (response: NotificationResponse, completion: () => void) => void): EmitterSubscription {
return this.nativeEventsReceiver.registerNotificationOpened(this.completionCallbackWrapper.wrapOpenedCallback(callback));
}
public registerRemoteNotificationsRegistrationFailed(callback: (event: RegistrationError) => void): EmitterSubscription {