Last active
August 29, 2015 14:25
-
-
Save AdamBrodzinski/4fa8eab7c292ea4799aa to your computer and use it in GitHub Desktop.
Medium React Meteor Testing Tutorial
This file contains 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
describe("EvenOrOdd Component", function() { | |
var defProps, renderWithProps, component, el, $el; | |
beforeEach(function() { | |
defProps = { | |
number: 2 | |
}; | |
renderWithProps = function(props) { | |
component = renderComponent(EvenOrOdd, props); | |
el = React.findDOMNode(component); | |
$el = $(el); | |
}; | |
}); | |
it("should contain Hello World", function() { | |
renderWithProps(defProps); | |
expect($el.text()).toEqual('Hello World'); | |
}); | |
}); |
This file contains 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
describe(“EvenOrOdd Component”, function() { | |
it(“should pass test”, function() { | |
expect(1 + 1).toEqual(2); | |
}); | |
}); |
This file contains 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
TestUtils = React.addons.TestUtils; | |
Simulate = TestUtils.Simulate; | |
// returns rendered react component | |
renderComponent = function (comp, props) { | |
return TestUtils.renderIntoDocument( | |
React.createElement(comp, props) | |
); | |
}; | |
// more terse method of simulating events | |
simulateClickOn = function($el) { | |
React.addons.TestUtils.Simulate.click($el[0]); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment