* Remove mattermost-redux * Move mm-redux files into app/redux * Add @redux path to tsconfig.json * Fix imports * Install missing dependencies * Fix tsc errors * Fix i18n_utils test * Fix more imports * Remove redux websocket * Fix tests * Rename @redux * Apply changes from mattermost-redux PR 1103 * Remove mattermost-redux mention in template * Add missing imports * Rename app/redux/ to app/mm-redux/ * Remove test file * Fix fetching Sidebar GM profiles Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
50 lines
1.5 KiB
JavaScript
50 lines
1.5 KiB
JavaScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import configureStore from 'redux-mock-store';
|
|
import thunk from 'redux-thunk';
|
|
|
|
import {UserTypes} from '@mm-redux/action_types';
|
|
import {General} from '@mm-redux/constants';
|
|
|
|
import {setCurrentUserStatusOffline} from 'app/actions/views/user';
|
|
|
|
const mockStore = configureStore([thunk]);
|
|
|
|
jest.mock('@mm-redux/actions/users', () => ({
|
|
getStatus: (...args) => ({type: 'MOCK_GET_STATUS', args}),
|
|
getStatusesByIds: (...args) => ({type: 'MOCK_GET_STATUS_BY_IDS', args}),
|
|
startPeriodicStatusUpdates: () => ({type: 'MOCK_PERIODIC_STATUS_UPDATES'}),
|
|
}));
|
|
|
|
describe('Actions.Views.User', () => {
|
|
let store;
|
|
|
|
beforeEach(() => {
|
|
store = mockStore({
|
|
entities: {
|
|
users: {
|
|
currentUserId: 'current-user-id',
|
|
statuses: {
|
|
'current-user-id': 'online',
|
|
'another-user-id1': 'away',
|
|
'another-user-id2': 'dnd',
|
|
},
|
|
},
|
|
},
|
|
});
|
|
});
|
|
|
|
test('should set the current user as offline', async () => {
|
|
const action = {
|
|
type: UserTypes.RECEIVED_STATUS,
|
|
data: {
|
|
user_id: 'current-user-id',
|
|
status: General.OFFLINE,
|
|
},
|
|
};
|
|
|
|
await store.dispatch(setCurrentUserStatusOffline());
|
|
expect(store.getActions()).toEqual([action]);
|
|
});
|
|
});
|