|
@@ -14,7 +14,7 @@ describe("<App /> shallow rendering", () => {
|
|
|
|
|
|
it("should find its elements", () => {
|
|
|
|
|
|
- expect(wrapper.find("p").length).toBe(1);
|
|
|
+ expect(wrapper.find("p").length).toBe(2);
|
|
|
expect(wrapper.find("p.App-intro").exists()).toBe(true);
|
|
|
expect(wrapper.find("ul").hasClass("tyler")).toBe(true);
|
|
|
expect(wrapper.find("ul").children().length).toBe(3);
|
|
@@ -46,6 +46,25 @@ describe("<App /> shallow rendering", () => {
|
|
|
const tree = shallow(<App />);
|
|
|
expect(toJson(tree)).toMatchSnapshot();
|
|
|
});
|
|
|
+
|
|
|
+ it("should change p text on button click", () => {
|
|
|
+ const button = wrapper.find("button");
|
|
|
+ expect(wrapper.find(".button-state").text()).toBe("No!");
|
|
|
+
|
|
|
+
|
|
|
+ button.simulate("click");
|
|
|
+ expect(wrapper.find(".button-state").text()).toBe("Yes!");
|
|
|
+ });
|
|
|
+
|
|
|
+ it("should change title text on input change", () => {
|
|
|
+ const input = wrapper.find("input");
|
|
|
+ const expected = "Tyler";
|
|
|
+
|
|
|
+ expect(wrapper.find("h2").text()).toBe("");
|
|
|
+
|
|
|
+ input.simulate("change", { currentTarget: { value: expected } });
|
|
|
+ expect(wrapper.find("h2").text()).toBe(expected);
|
|
|
+ });
|
|
|
});
|
|
|
|
|
|
describe("<App /> mount rendering", () => {
|