diff --git a/src/js/components/LoginLinks.jsx b/src/js/components/LoginLinks.jsx index feea798..9b43579 100644 --- a/src/js/components/LoginLinks.jsx +++ b/src/js/components/LoginLinks.jsx @@ -6,7 +6,7 @@ import Actions from '../actions/Actions'; const LoginLinks = React.createClass({ render() { return ( - + Actions.showModal('login') }>Sign In Actions.showModal('register') } className="register-link">Register diff --git a/test/components/LoginLinks-test.js b/test/components/LoginLinks-test.js new file mode 100644 index 0000000..e9814d4 --- /dev/null +++ b/test/components/LoginLinks-test.js @@ -0,0 +1,50 @@ +'use strict'; + +import setupDOM from '../util/setup'; +import createParent from '../util/createParent'; +import chai, { expect } from 'chai'; +import sinon from 'sinon'; +import sinonChai from 'sinon-chai'; + +var React; +var LoginLinks; +var TestUtils; + +chai.use(sinonChai); + +describe('LoginLinks Component', () => { + let loginLinks; + + beforeEach(() => { + setupDOM(); + React = require('react/addons'); + LoginLinks = require('../../src/js/components/LoginLinks'); + TestUtils = React.addons.TestUtils; + }); + + afterEach(() => { + // React caches required modules + for (var i in require.cache) { + delete require.cache[i]; + } + }); + + describe('DOM', function() { + beforeEach(() => { + loginLinks = TestUtils.renderIntoDocument(); + }); + + it('should render a span with className "login-links"', () => { + expect(loginLinks.getDOMNode().className).to.equal('login-links'); + }); + + it('should render "Sign In" and "Register" links', () => { + let links = TestUtils.scryRenderedDOMComponentsWithTag(loginLinks, 'a'); + let linkText = links.map((link) => link.getDOMNode().textContent); + + expect(links.length).to.equal(2); + expect(linkText[0]).to.equal('Sign In'); + expect(linkText[1]).to.equal('Register'); + }); + }); +}); \ No newline at end of file