|
@@ -9,7 +9,7 @@ import toJson from "enzyme-to-json";
|
|
|
// Could be in a test setup file. Required for React 16, 15, 0.14, 0.13.
|
|
|
configure({ adapter: new Adapter() });
|
|
|
|
|
|
-describe("<App />>", () => {
|
|
|
+describe("<App /> shallow rendering", () => {
|
|
|
const wrapper = shallow(<App />);
|
|
|
|
|
|
it("should find its elements", () => {
|
|
@@ -48,6 +48,28 @@ describe("<App />>", () => {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
+describe("<App /> mount rendering", () => {
|
|
|
+ it("h1 contains correct text", () => {
|
|
|
+ // Second parameter is optional.
|
|
|
+ const wrapper = mount(<App />, {
|
|
|
+ context: {},
|
|
|
+ attachTo: document.createElement("div"),
|
|
|
+ });
|
|
|
+
|
|
|
+ expect(wrapper.find("h1").text()).toBe("Welcome to React");
|
|
|
+ // Tests can affect each other if mounted components are not unmounted,
|
|
|
+ // since they will remain mounted in the same DOM.
|
|
|
+ // Unmount() can also be used to simulate an unmount/mount cycle in React.
|
|
|
+ wrapper.unmount();
|
|
|
+ });
|
|
|
+
|
|
|
+ it("matches the snapshot", () => {
|
|
|
+ const tree = mount(<App />);
|
|
|
+ expect(toJson(tree)).toMatchSnapshot();
|
|
|
+ tree.unmount();
|
|
|
+ });
|
|
|
+});
|
|
|
+
|
|
|
describe("<Link>", () => {
|
|
|
const expected = "www.google.com";
|
|
|
|