Don't subtract from badge count (#4135)
This commit is contained in:
parent
1486a55aeb
commit
514f6a68d7
2 changed files with 29 additions and 2 deletions
|
|
@ -214,7 +214,6 @@ class PushNotification {
|
|||
}
|
||||
|
||||
if (ids.length) {
|
||||
badgeCount -= ids.length;
|
||||
NotificationsIOS.removeDeliveredNotifications(ids);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,11 +2,14 @@
|
|||
// See LICENSE.txt for license information.
|
||||
|
||||
import NotificationsIOS from 'react-native-notifications';
|
||||
|
||||
import * as ViewSelectors from 'app/selectors/views';
|
||||
|
||||
import PushNotification from './push_notifications.ios';
|
||||
|
||||
jest.mock('react-native-notifications', () => {
|
||||
let badgesCount = 0;
|
||||
let deliveredNotifications = {};
|
||||
let deliveredNotifications = [];
|
||||
|
||||
return {
|
||||
getBadgesCount: jest.fn((callback) => callback(badgesCount)),
|
||||
|
|
@ -90,4 +93,29 @@ describe('PushNotification', () => {
|
|||
expect(cancelAllLocalNotifications).toHaveBeenCalled();
|
||||
expect(NotificationsIOS.cancelAllLocalNotifications).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('clearChannelNotifications should set app badge number from to delivered notification count when redux store is not set', () => {
|
||||
PushNotification.reduxStore = null;
|
||||
const setApplicationIconBadgeNumber = jest.spyOn(PushNotification, 'setApplicationIconBadgeNumber');
|
||||
const deliveredNotifications = [{identifier: 1}, {identifier: 2}];
|
||||
NotificationsIOS.setDeliveredNotifications(deliveredNotifications);
|
||||
|
||||
PushNotification.clearChannelNotifications();
|
||||
expect(setApplicationIconBadgeNumber).toHaveBeenCalledWith(deliveredNotifications.length);
|
||||
});
|
||||
|
||||
it('clearChannelNotifications should set app badge number from redux store when set', () => {
|
||||
PushNotification.reduxStore = {
|
||||
getState: jest.fn(),
|
||||
};
|
||||
const setApplicationIconBadgeNumber = jest.spyOn(PushNotification, 'setApplicationIconBadgeNumber');
|
||||
const deliveredNotifications = [{identifier: 1}, {identifier: 2}];
|
||||
NotificationsIOS.setDeliveredNotifications(deliveredNotifications);
|
||||
|
||||
const stateBadgeCount = 2 * deliveredNotifications.length;
|
||||
ViewSelectors.getBadgeCount = jest.fn().mockReturnValue(stateBadgeCount);
|
||||
|
||||
PushNotification.clearChannelNotifications();
|
||||
expect(setApplicationIconBadgeNumber).toHaveBeenCalledWith(stateBadgeCount);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue