2022-03-21 16:25:08 +00:00
|
|
|
import { render, screen } from "@testing-library/react";
|
2017-01-05 18:08:19 +00:00
|
|
|
|
2021-04-12 13:32:25 +00:00
|
|
|
import helpers from "test/helpers";
|
|
|
|
|
import { userStub } from "test/stubs";
|
|
|
|
|
import CoreLayout from "./CoreLayout";
|
2017-01-05 18:08:19 +00:00
|
|
|
|
2021-04-12 13:32:25 +00:00
|
|
|
const { connectedComponent, reduxMockStore } = helpers;
|
2017-01-05 18:08:19 +00:00
|
|
|
|
2021-04-12 13:32:25 +00:00
|
|
|
describe("CoreLayout - layouts", () => {
|
2017-02-10 03:16:51 +00:00
|
|
|
const store = {
|
|
|
|
|
app: { config: {} },
|
|
|
|
|
auth: { user: userStub },
|
|
|
|
|
notifications: {},
|
|
|
|
|
persistentFlash: {
|
|
|
|
|
showFlash: false,
|
2021-04-12 13:32:25 +00:00
|
|
|
message: "",
|
2017-02-10 03:16:51 +00:00
|
|
|
},
|
|
|
|
|
};
|
2017-01-05 18:08:19 +00:00
|
|
|
const mockStore = reduxMockStore(store);
|
|
|
|
|
|
2021-04-12 13:32:25 +00:00
|
|
|
it("renders the FlashMessage component when notifications are present", () => {
|
|
|
|
|
const storeWithNotifications = {
|
|
|
|
|
app: { config: {} },
|
|
|
|
|
auth: {
|
|
|
|
|
user: userStub,
|
|
|
|
|
},
|
|
|
|
|
notifications: {
|
|
|
|
|
alertType: "success",
|
|
|
|
|
isVisible: true,
|
|
|
|
|
message: "nice jerb!",
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
const mockStoreWithNotifications = reduxMockStore(storeWithNotifications);
|
|
|
|
|
const componentWithFlash = connectedComponent(CoreLayout, {
|
|
|
|
|
mockStore: mockStoreWithNotifications,
|
|
|
|
|
});
|
|
|
|
|
const componentWithoutFlash = connectedComponent(CoreLayout, {
|
|
|
|
|
mockStore,
|
|
|
|
|
});
|
2017-01-05 18:08:19 +00:00
|
|
|
|
2022-03-21 16:25:08 +00:00
|
|
|
const { container, rerender } = render(componentWithFlash);
|
2017-01-05 18:08:19 +00:00
|
|
|
|
2022-03-21 16:25:08 +00:00
|
|
|
expect(container.querySelector(".flash-message")).toBeInTheDocument();
|
2017-01-05 18:08:19 +00:00
|
|
|
|
2022-03-21 16:25:08 +00:00
|
|
|
rerender(componentWithoutFlash);
|
|
|
|
|
|
|
|
|
|
expect(container.querySelector(".flash-message")).not.toBeInTheDocument();
|
2021-04-12 13:32:25 +00:00
|
|
|
});
|
2017-01-05 18:08:19 +00:00
|
|
|
});
|