2022-02-02 17:01:31 +00:00
|
|
|
import { setPermissions, updatePermission } from '../actions/permissions';
|
|
|
|
import { mockedStore } from './mockedStore';
|
2022-02-17 13:06:31 +00:00
|
|
|
import { initialState, IPermissionsState } from './permissions';
|
2022-02-02 17:01:31 +00:00
|
|
|
|
|
|
|
describe('test permissions reducer', () => {
|
|
|
|
it('should return initial state', () => {
|
|
|
|
const state = mockedStore.getState().permissions;
|
|
|
|
expect(state).toEqual(initialState);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should return modified store after setPermissions', () => {
|
2022-02-17 13:06:31 +00:00
|
|
|
const permissions: IPermissionsState = { 'add-user-to-any-c-room': ['admin'], 'add-team-channel': ['user'] };
|
2022-02-02 17:01:31 +00:00
|
|
|
mockedStore.dispatch(setPermissions(permissions));
|
|
|
|
const state = mockedStore.getState().permissions;
|
|
|
|
expect(state).toEqual(permissions);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should return empty store after remove user', () => {
|
2022-02-17 13:06:31 +00:00
|
|
|
mockedStore.dispatch(updatePermission('add-team-channel', ['owner']));
|
2022-02-02 17:01:31 +00:00
|
|
|
const state = mockedStore.getState().permissions;
|
2022-02-17 13:06:31 +00:00
|
|
|
expect(state['add-team-channel']).toEqual(['owner']);
|
2022-02-02 17:01:31 +00:00
|
|
|
});
|
|
|
|
});
|