Fix tests (#3114)
This commit is contained in:
parent
32f329fca2
commit
1d37c81163
2 changed files with 20 additions and 4 deletions
|
|
@ -4,25 +4,35 @@
|
|||
import configureMockStore from 'redux-mock-store';
|
||||
import thunk from 'redux-thunk';
|
||||
|
||||
import intitialState from 'app/initial_state';
|
||||
import PushNotification from 'app/push_notifications';
|
||||
|
||||
import GlobalEventHandler from './global_event_handler';
|
||||
|
||||
jest.mock('app/init/credentials', () => ({
|
||||
getCurrentServerUrl: jest.fn().mockResolvedValue(''),
|
||||
getAppCredentials: jest.fn(),
|
||||
removeAppCredentials: jest.fn(),
|
||||
}));
|
||||
|
||||
jest.mock('react-native-notifications', () => ({
|
||||
addEventListener: jest.fn(),
|
||||
cancelAllLocalNotifications: jest.fn(),
|
||||
setBadgesCount: jest.fn(),
|
||||
NotificationAction: jest.fn(),
|
||||
NotificationCategory: jest.fn(),
|
||||
}));
|
||||
|
||||
const mockStore = configureMockStore([thunk]);
|
||||
const store = mockStore({});
|
||||
const store = mockStore(intitialState);
|
||||
GlobalEventHandler.store = store;
|
||||
|
||||
// TODO: Add Android test as part of https://mattermost.atlassian.net/browse/MM-17110
|
||||
describe('GlobalEventHandler', () => {
|
||||
it('should clear notifications on logout', () => {
|
||||
it('should clear notifications on logout', async () => {
|
||||
const clearNotifications = jest.spyOn(PushNotification, 'clearNotifications');
|
||||
|
||||
GlobalEventHandler.onLogout();
|
||||
await GlobalEventHandler.onLogout();
|
||||
expect(clearNotifications).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ configure({adapter: new Adapter()});
|
|||
|
||||
const mockImpl = new MockAsyncStorage();
|
||||
jest.mock('@react-native-community/async-storage', () => mockImpl);
|
||||
global.window = {};
|
||||
|
||||
/* eslint-disable no-console */
|
||||
|
||||
|
|
@ -38,6 +39,10 @@ jest.mock('NativeModules', () => {
|
|||
SECURITY_LEVEL_SECURE_SOFTWARE: 'SOFTWARE',
|
||||
SECURITY_LEVEL_SECURE_HARDWARE: 'HARDWARE',
|
||||
},
|
||||
RNCNetInfo: {
|
||||
addEventListener: jest.fn(),
|
||||
getCurrentState: jest.fn().mockResolvedValue({isConnected: true}),
|
||||
},
|
||||
};
|
||||
});
|
||||
jest.mock('NativeEventEmitter');
|
||||
|
|
@ -48,6 +53,7 @@ jest.mock('react-native-device-info', () => {
|
|||
getBuildNumber: () => '0',
|
||||
getModel: () => 'iPhone X',
|
||||
isTablet: () => false,
|
||||
getDeviceLocale: () => 'en-US',
|
||||
};
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue