Skip to content

Commit

Permalink
add test for ProfileLink
Browse files Browse the repository at this point in the history
  • Loading branch information
echenley committed Sep 17, 2015
1 parent eb9c29d commit f248921
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 2 deletions.
2 changes: 0 additions & 2 deletions test/components/LoginLinks-test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
'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;
Expand Down
52 changes: 52 additions & 0 deletions test/components/ProfileLink-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
'use strict';

import setupDOM from '../util/setup';
import chai, { expect } from 'chai';
import sinonChai from 'sinon-chai';

var React;
var ProfileLink;
var TestUtils;

chai.use(sinonChai);

const userData = {
username: 'echenley',
md5hash: '7da6a19ef0b1a9b9794cf5c7cc7439f1'
};

describe('ProfileLink Component', () => {
let profileLink;

beforeEach(() => {
setupDOM();
React = require('react/addons');
ProfileLink = require('../../src/js/components/ProfileLink');
TestUtils = React.addons.TestUtils;
});

afterEach(() => {
// React caches required modules
for (var i in require.cache) {
delete require.cache[i];
}
});

describe('DOM', function() {
beforeEach(() => {
profileLink = TestUtils.renderIntoDocument(<ProfileLink user={ userData } />);
});

it('should render a link with className "login-links"', () => {
expect(profileLink.getDOMNode().className).to.equal('profile-link');
});

it('should render username and gravatar', () => {
let childNodes = profileLink.getDOMNode().childNodes;

expect(childNodes.length).to.equal(2);
expect(childNodes[0].textContent).to.equal('echenley');
expect(childNodes[1].src).to.contain('7da6a19ef0b1a9b9794cf5c7cc7439f1');
});
});
});

0 comments on commit f248921

Please sign in to comment.