Skip to content

Instantly share code, notes, and snippets.

@AdamBrodzinski
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AdamBrodzinski/4fa8eab7c292ea4799aa to your computer and use it in GitHub Desktop.
Save AdamBrodzinski/4fa8eab7c292ea4799aa to your computer and use it in GitHub Desktop.
Medium React Meteor Testing Tutorial
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');
});
});
describe(“EvenOrOdd Component”, function() {
it(“should pass test”, function() {
expect(1 + 1).toEqual(2);
});
});
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