Skip to content

Instantly share code, notes, and snippets.

@alexmcpherson
Created June 12, 2015 17:46
Show Gist options
  • Save alexmcpherson/f66198609278cb99cdf2 to your computer and use it in GitHub Desktop.
Save alexmcpherson/f66198609278cb99cdf2 to your computer and use it in GitHub Desktop.
Testing examples
import React from "react/addons";
import jsdom from "mocha-jsdom";
import {expect} from "chai";
//See https://facebook.github.io/react/docs/test-utils.html for available methods
let {TestUtils} = React.addons;
import TitleBar from "js-app/components/titleBar";
describe("TitleBar", function() {
jsdom();
it("should have the title in its DOM", () => {
var titleBar = TestUtils.renderIntoDocument(
<TitleBar title="My Gallery" />
);
var titleTag = TestUtils.findRenderedDOMComponentWithClass(titleBar, "gallery-title");
expect(titleTag.getDOMNode().textContent).to.equal("My Gallery");
});
});
describe("#setFavorite", function() {
it("should set favorite status for content", function() {
var content = contentMock[2];
contentStore.setFavorite(content.id, true);
content.favorite.should.equal(true);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment