2020-10-16 12:38:04 +00:00
|
|
|
import React from "react";
|
|
|
|
import { mount } from "enzyme";
|
|
|
|
import ErrorContainer from ".";
|
2019-09-07 10:46:04 +00:00
|
|
|
|
2020-10-16 12:38:04 +00:00
|
|
|
describe("<ErrorContainer />", () => {
|
|
|
|
it("renders without error", () => {
|
|
|
|
const wrapper = mount(<ErrorContainer />);
|
2019-09-07 10:46:04 +00:00
|
|
|
|
|
|
|
expect(wrapper).toExist();
|
|
|
|
});
|
2019-11-28 07:49:20 +00:00
|
|
|
|
2020-10-16 12:38:04 +00:00
|
|
|
it("renders with props", () => {
|
2020-01-24 13:54:41 +00:00
|
|
|
const wrapper = mount(
|
2020-10-16 12:38:04 +00:00
|
|
|
<ErrorContainer
|
2020-01-24 13:54:41 +00:00
|
|
|
headerText="Some error has happened"
|
|
|
|
bodyText="Try again later"
|
|
|
|
buttonText="Go back"
|
2020-10-16 12:38:04 +00:00
|
|
|
buttonUrl="/page"
|
|
|
|
/>
|
2020-01-24 13:54:41 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
expect(wrapper).toExist();
|
2020-10-16 12:38:04 +00:00
|
|
|
expect(wrapper.prop("headerText")).toEqual("Some error has happened");
|
|
|
|
expect(wrapper.prop("bodyText")).toEqual("Try again later");
|
|
|
|
expect(wrapper.prop("buttonText")).toEqual("Go back");
|
|
|
|
expect(wrapper.prop("buttonUrl")).toEqual("/page");
|
2020-01-24 13:54:41 +00:00
|
|
|
});
|
|
|
|
|
2020-10-16 12:38:04 +00:00
|
|
|
it("accepts id", () => {
|
|
|
|
const wrapper = mount(<ErrorContainer id="testId" />);
|
2019-11-28 07:49:20 +00:00
|
|
|
|
2020-10-16 12:38:04 +00:00
|
|
|
expect(wrapper.prop("id")).toEqual("testId");
|
2019-11-28 07:49:20 +00:00
|
|
|
});
|
|
|
|
|
2020-10-16 12:38:04 +00:00
|
|
|
it("accepts className", () => {
|
|
|
|
const wrapper = mount(<ErrorContainer className="test" />);
|
2019-11-28 07:49:20 +00:00
|
|
|
|
2020-10-16 12:38:04 +00:00
|
|
|
expect(wrapper.prop("className")).toEqual("test");
|
2019-11-28 07:49:20 +00:00
|
|
|
});
|
|
|
|
|
2020-10-16 12:38:04 +00:00
|
|
|
it("accepts style", () => {
|
|
|
|
const wrapper = mount(<ErrorContainer style={{ color: "red" }} />);
|
2019-11-28 07:49:20 +00:00
|
|
|
|
2020-10-16 12:38:04 +00:00
|
|
|
expect(wrapper.getDOMNode().style).toHaveProperty("color", "red");
|
2019-11-28 07:49:20 +00:00
|
|
|
});
|
2019-09-07 10:46:04 +00:00
|
|
|
});
|