|
@@ -4,19 +4,23 @@ import App from "./App";
|
|
|
import { configure, shallow } from "enzyme";
|
|
|
import Adapter from "enzyme-adapter-react-16";
|
|
|
|
|
|
-// Configure Enzyme for the React version we're using.
|
|
|
+// Configure Enzyme for the React version we are using.
|
|
|
// Could be in a test setup file. Required for React 16, 15, 0.14, 0.13.
|
|
|
configure({ adapter: new Adapter() });
|
|
|
|
|
|
describe("<App />>", () => {
|
|
|
- it("should render App", () => {
|
|
|
- const wrapper = shallow(<App />, {
|
|
|
- // Pass a context to component.
|
|
|
- context: {},
|
|
|
- // Disable component mount lifecycle methods, as well as update after
|
|
|
- // setProps() and setContext().
|
|
|
- disableLifecycleMethods: true,
|
|
|
- });
|
|
|
- console.log(wrapper.debug());
|
|
|
+ const wrapper = shallow(<App />);
|
|
|
+
|
|
|
+ it("should contain 1 p element", () => {
|
|
|
+ // There is one <p> in <App />: only one shoud be present in shallow rendering.
|
|
|
+ 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");
|
|
|
});
|
|
|
});
|