2021-04-12 13:32:25 +00:00
|
|
|
import { mount } from "enzyme";
|
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
|
|
|
|
2021-04-12 13:32:25 +00:00
|
|
|
const appWithFlash = mount(componentWithFlash);
|
|
|
|
|
const appWithoutFlash = mount(componentWithoutFlash);
|
2017-01-05 18:08:19 +00:00
|
|
|
|
2021-04-12 13:32:25 +00:00
|
|
|
expect(appWithFlash.length).toEqual(1);
|
|
|
|
|
expect(appWithoutFlash.length).toEqual(1);
|
2017-01-05 18:08:19 +00:00
|
|
|
|
2021-04-12 13:32:25 +00:00
|
|
|
expect(appWithFlash.find("FlashMessage").html()).toBeTruthy();
|
|
|
|
|
expect(appWithoutFlash.find("FlashMessage").html()).toBeFalsy();
|
|
|
|
|
});
|
2017-01-05 18:08:19 +00:00
|
|
|
});
|