|
@@ -14,7 +14,7 @@ describe("<App /> shallow rendering", () => {
|
|
|
|
|
|
it("should find its elements", () => {
|
|
|
|
|
|
- expect(wrapper.find("p").length).toBe(2);
|
|
|
+ expect(wrapper.find("p").length).toBe(3);
|
|
|
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);
|
|
@@ -76,6 +76,29 @@ describe("<App /> shallow rendering", () => {
|
|
|
input.simulate("change", { currentTarget: { value: expected } });
|
|
|
expect(wrapper.find("h2").text()).toBe(expected);
|
|
|
});
|
|
|
+
|
|
|
+ it("should call componentDidMount, update p tag text", () => {
|
|
|
+ jest.spyOn(App.prototype, "componentDidMount");
|
|
|
+ const w = shallow(<App />);
|
|
|
+
|
|
|
+
|
|
|
+ expect(App.prototype.componentDidMount.mock.calls.length).toBe(1);
|
|
|
+ expect(w.find(".lifeCycle").text()).toBe("componentDidMount");
|
|
|
+ });
|
|
|
+
|
|
|
+ it("should call componentWillReceiveProps", () => {
|
|
|
+ jest.spyOn(App.prototype, "componentWillReceiveProps");
|
|
|
+ const w = shallow(<App />);
|
|
|
+
|
|
|
+ expect(w.find(".lifeCycle").text()).toBe("componentDidMount");
|
|
|
+
|
|
|
+
|
|
|
+ expect(App.prototype.componentWillReceiveProps.mock.calls.length).toBe(0);
|
|
|
+
|
|
|
+ w.setProps({ hide: true });
|
|
|
+ expect(App.prototype.componentWillReceiveProps.mock.calls.length).toBe(1);
|
|
|
+ expect(w.find(".lifeCycle").text()).toBe("componentWillReceiveProps");
|
|
|
+ });
|
|
|
});
|
|
|
|
|
|
describe("<App /> mount rendering", () => {
|