|
@@ -1,7 +1,7 @@
|
|
|
import "raf/polyfill";
|
|
|
import React from "react";
|
|
|
-import App from "./App";
|
|
|
-import { configure, shallow } from "enzyme";
|
|
|
+import { App, appName, titleName } from "./App";
|
|
|
+import { configure, shallow, mount } from "enzyme";
|
|
|
import Adapter from "enzyme-adapter-react-16";
|
|
|
|
|
|
|
|
@@ -11,16 +11,33 @@ configure({ adapter: new Adapter() });
|
|
|
describe("<App />>", () => {
|
|
|
const wrapper = shallow(<App />);
|
|
|
|
|
|
- it("should contain 1 p element", () => {
|
|
|
+ it("should find its elements", () => {
|
|
|
|
|
|
expect(wrapper.find("p").length).toBe(1);
|
|
|
-
|
|
|
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);
|
|
|
-
|
|
|
expect(wrapper.find("h1").text()).toBe("Welcome to React");
|
|
|
});
|
|
|
+
|
|
|
+ it("should find using props", () => {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ expect(wrapper.find("[text='Some title']").length).toBe(1);
|
|
|
+
|
|
|
+ expect(wrapper.find({ text: "Some title" }).length).toBe(1);
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ test.skip("should find using a constructor", () => {
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ it("should find using displayName", () => {
|
|
|
+ const w = mount(<App />);
|
|
|
+ expect(w.find(appName).length).toBe(1);
|
|
|
+ expect(w.find(titleName).length).toBe(1);
|
|
|
+ });
|
|
|
});
|