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/46a6403129a716c0d22e to your computer and use it in GitHub Desktop.
Save AdamBrodzinski/46a6403129a716c0d22e to your computer and use it in GitHub Desktop.
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 determine if number is odd or even", function() {
// you can also just call the proto without rendering component
expect(EvenOrOdd.prototype.isEven(3)).toBe(false);
renderWithProps({});
expect(component.isEven(0)).toBe(true);
expect(component.isEven(4)).toBe(true);
});
it("should print out odd", function() {
renderWithProps({number: 5});
expect($el.text()).toBe("5 is Odd");
});
it("should print out even", function() {
renderWithProps({number: 4});
expect($el.text()).toBe("4 is Even");
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment