mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 17:05:18 +00:00
c07702330d
* Moving entityGetter to utility folder * Import whitespace and if statement braces * newlines between multi-line if's
38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
import expect from 'expect';
|
|
import { mount } from 'enzyme';
|
|
|
|
import ConnectedAdminRoutes from './AuthenticatedAdminRoutes';
|
|
import { connectedComponent, reduxMockStore } from '../../test/helpers';
|
|
|
|
describe('AuthenticatedAdminRoutes - layout', () => {
|
|
const redirectToHomeAction = {
|
|
type: '@@router/CALL_HISTORY_METHOD',
|
|
payload: {
|
|
method: 'push',
|
|
args: ['/'],
|
|
},
|
|
};
|
|
|
|
it('redirects to the homepage if the user is not an admin', () => {
|
|
const user = { id: 1, admin: false };
|
|
const storeWithoutAdminUser = { auth: { user } };
|
|
const mockStore = reduxMockStore(storeWithoutAdminUser);
|
|
mount(
|
|
connectedComponent(ConnectedAdminRoutes, { mockStore })
|
|
);
|
|
|
|
expect(mockStore.getActions()).toInclude(redirectToHomeAction);
|
|
});
|
|
|
|
it('does not redirect if the user is an admin', () => {
|
|
const user = { id: 1, admin: true };
|
|
const storeWithAdminUser = { auth: { user } };
|
|
const mockStore = reduxMockStore(storeWithAdminUser);
|
|
mount(
|
|
connectedComponent(ConnectedAdminRoutes, { mockStore })
|
|
);
|
|
|
|
expect(mockStore.getActions()).toNotInclude(redirectToHomeAction);
|
|
});
|
|
});
|