Last active
November 21, 2019 01:38
-
-
Save ridoansaleh/4986f68e600f209ea2637124553f0608 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. AppProvider.test.js | |
import React from "react"; | |
import { render, unmountComponentAtNode } from "react-dom"; | |
import { act } from "react-dom/test-utils"; | |
import AppProvider from "./AppProvider"; | |
describe("<AppProvider />", () => { | |
let container = null; | |
beforeEach(() => { | |
container = document.createElement("div"); | |
document.body.appendChild(container); | |
}); | |
afterEach(() => { | |
unmountComponentAtNode(container); | |
container.remove(); | |
container = null; | |
}); | |
it("contains props children", async () => { | |
await act(async () => { | |
render( | |
<AppProvider children={<p className="main">Hello World</p>} />, | |
container | |
); | |
}); | |
expect(container.querySelector(".main").textContent).toBe("Hello World"); | |
}); | |
}); | |
2. App.test.js | |
import React from "react"; | |
import { shallow } from "enzyme"; | |
import App from "./App"; | |
describe("<App/> ", () => { | |
it("renders", () => { | |
shallow(<App />); | |
}); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment