mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 13:37:30 +00:00
* add prettier and have it format all js code except website: : * trying running prettier check in CI * fix runs on in CI * change CI job name * fix prettier erros and fix CI
32 lines
1.1 KiB
JavaScript
32 lines
1.1 KiB
JavaScript
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()).toContainEqual(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()).not.toContainEqual(redirectToHomeAction);
|
|
});
|
|
});
|