Created
March 31, 2016 06:01
-
-
Save fay-jai/b50e417221aeb6e74125ff41781173eb to your computer and use it in GitHub Desktop.
Getting Started on Testing with Typescript, ReactJS, and Webpack
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 * as ReactDOM from "react-dom"; | |
import * as TestUtils from "react-addons-test-utils"; | |
import Hello from "../src/Hello"; | |
describe("Hello", () => { | |
let renderer: React.ShallowRenderer; | |
beforeEach(() => { | |
renderer = TestUtils.createRenderer(); | |
renderer.render(<Hello name="Willson" />); | |
}); | |
it("should render correctly", () => { | |
const result = renderer.getRenderOutput(); | |
chai.assert.strictEqual(result.type, "div"); | |
}); | |
it("should have correct prop values", () => { | |
const result = renderer.getRenderOutput(); | |
const propValues = result.props.children.join(""); | |
chai.assert.strictEqual(propValues, "Hello, Willson"); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment