Skip to content

Instantly share code, notes, and snippets.

@mhuggins
Created August 15, 2014 17:45
Show Gist options
  • Save mhuggins/d33bf7042d4b447bc22b to your computer and use it in GitHub Desktop.
Save mhuggins/d33bf7042d4b447bc22b to your computer and use it in GitHub Desktop.
How can I do this in Mocha?
/** @jsx React.DOM */
var React = require('react');
var Loader = require('../../lib/react-loader');
var expect = require('chai').expect;
var loader, loaded;
describe('Loader', function () {
beforeEach(function () {
loader = <Loader loaded={loaded}>Welcome</Loader>;
React.renderComponent(loader, document.body);
});
describe('before loaded', function () {
beforeEach(function () {
loaded = false;
});
it('renders the loader', function () {
expect(document.body.innerHTML).to.match(/<div class="loader"/);
});
it('does not render the content', function () {
expect(document.body.innerHTML).to.not.match(/Welcome/);
});
});
describe('after loaded', function () {
beforeEach(function () {
loaded = true;
});
it('does not render the loader', function () {
expect(document.body.innerHTML).to.not.match(/<div class="loader"/);
});
it('renders the content', function () {
expect(document.body.innerHTML).to.match(/Welcome/);
});
});
});
@mhuggins
Copy link
Author

Long live rspec :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment