Created
May 4, 2017 15:56
-
-
Save mikebridge/b9bb34e9a2f60c871ab7e38e812c7c12 to your computer and use it in GitHub Desktop.
Enzyme test for welcome.tsx
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
import * as React from "react"; | |
import {Welcome} from "./welcome"; | |
import {shallow} from "enzyme"; | |
const name = "Tester; | |
describe("<Welcome />", () => { | |
it("renders a greeting from the name", () => { | |
const wrapper = shallow(<Welcome name={name} onClick={() => null} />); | |
expect(wrapper.text()).toBe(`Welcome, ${name}!`); | |
}); | |
it("calls back when clicked", () => { | |
let clicked = false; | |
const onClick = () => clicked = true; | |
const wrapper = shallow(<Welcome name={name} onClick={onClick} />); | |
wrapper.find("div").simulate("click", { preventDefault: () => undefined }); | |
expect(clicked).toEqual(true); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment