Skip to content

Commit

Permalink
update to react 0.14, add test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
echenley committed Oct 17, 2015
1 parent 0f7a72b commit 0988aa2
Show file tree
Hide file tree
Showing 31 changed files with 70 additions and 55 deletions.
12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
"firebase": "^2.2.9",
"md5": "^2.0.0",
"moment": "^2.10.6",
"react": "^0.13.3",
"react-inlinesvg": "^0.4.2",
"react-router": "1.0.0-rc1",
"reflux": "^0.2.12"
"react": "^0.14.0",
"react-addons-update": "^0.14.0",
"react-dom": "^0.14.0",
"react-router": "1.0.0-rc3",
"reflux": "^0.3.0"
},
"devDependencies": {
"autoprefixer": "^6.0.2",
Expand All @@ -28,10 +29,12 @@
"eslint-loader": "^1.0.0",
"eslint-plugin-react": "^3.4.1",
"html-webpack-plugin": "^1.6.1",
"istanbul-instrumenter-loader": "^0.1.3",
"jsdom": "^6.5.0",
"karma": "^0.13.9",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^0.2.0",
"karma-coverage": "^0.5.2",
"karma-mocha": "^0.2.0",
"karma-mocha-reporter": "^1.1.1",
"karma-phantomjs-launcher": "^0.2.1",
Expand All @@ -45,6 +48,7 @@
"null-loader": "^0.1.1",
"phantomjs": "^1.9.18",
"postcss-loader": "^0.6.0",
"react-addons-test-utils": "^0.14.0",
"react-hot-loader": "^1.3.0",
"sass-loader": "^3.0.0",
"sinon": "^1.16.1",
Expand Down
2 changes: 1 addition & 1 deletion src/js/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Author URI: http://henleyedition.com/

'use strict';

import React from 'react/addons';
import React from 'react';
import Reflux from 'reflux';
import { Link } from 'react-router';

Expand Down
2 changes: 1 addition & 1 deletion src/js/components/Comment.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import React, { PropTypes } from 'react/addons';
import React, { PropTypes } from 'react';
import Actions from '../actions/Actions';

import { Link } from 'react-router';
Expand Down
2 changes: 1 addition & 1 deletion src/js/components/CommentForm.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import React, { PropTypes } from 'react/addons';
import React, { PropTypes } from 'react';
import Reflux from 'reflux';

import Actions from '../actions/Actions';
Expand Down
2 changes: 1 addition & 1 deletion src/js/components/Icon.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import React, { PropTypes } from 'react/addons';
import React, { PropTypes } from 'react';

const Icon = React.createClass({
propTypes: {
Expand Down
2 changes: 1 addition & 1 deletion src/js/components/Login.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import React, { PropTypes } from 'react/addons';
import React, { PropTypes } from 'react';
import Actions from '../actions/Actions';
import Spinner from '../components/Spinner';

Expand Down
2 changes: 1 addition & 1 deletion src/js/components/LoginLinks.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import React from 'react/addons';
import React from 'react';
import Actions from '../actions/Actions';

const LoginLinks = React.createClass({
Expand Down
2 changes: 1 addition & 1 deletion src/js/components/Modal.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import React, { PropTypes } from 'react/addons';
import React, { PropTypes } from 'react';
import Icon from './Icon';

const Modal = React.createClass({
Expand Down
2 changes: 1 addition & 1 deletion src/js/components/NewPost.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import React from 'react/addons';
import React from 'react';
import { History } from 'react-router';
import cx from 'classnames';

Expand Down
2 changes: 1 addition & 1 deletion src/js/components/Post.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import React, { PropTypes } from 'react/addons';
import React, { PropTypes } from 'react';
import PostLink from './PostLink';
import PostInfo from './PostInfo';

Expand Down
2 changes: 1 addition & 1 deletion src/js/components/PostInfo.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import React, { PropTypes } from 'react/addons';
import React, { PropTypes } from 'react';
import { Link } from 'react-router';

import Actions from '../actions/Actions';
Expand Down
2 changes: 1 addition & 1 deletion src/js/components/PostLink.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import React, { PropTypes } from 'react/addons';
import React, { PropTypes } from 'react';
import hostNameFromUrl from '../util/hostNameFromUrl';

const PostLink = React.createClass({
Expand Down
2 changes: 1 addition & 1 deletion src/js/components/ProfileLink.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import React, { PropTypes } from 'react/addons';
import React, { PropTypes } from 'react';
import Link from 'react-router/lib/Link';

const ProfileLink = React.createClass({
Expand Down
2 changes: 1 addition & 1 deletion src/js/components/Register.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import React, { PropTypes } from 'react/addons';
import React, { PropTypes } from 'react';
import Actions from '../actions/Actions';
import Spinner from '../components/Spinner';

Expand Down
2 changes: 1 addition & 1 deletion src/js/components/Spinner.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import React from 'react/addons';
import React from 'react';

const Spinner = React.createClass({
render() {
Expand Down
2 changes: 1 addition & 1 deletion src/js/components/Upvote.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import React, { PropTypes } from 'react/addons';
import React, { PropTypes } from 'react';
import cx from 'classnames';

import Actions from '../actions/Actions';
Expand Down
4 changes: 2 additions & 2 deletions src/js/render.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

import '../scss/main.scss';
import React from 'react/addons';
import ReactDOM from 'react-dom';
import routes from './routes';

React.render(routes, document.getElementById('app'));
ReactDOM.render(routes, document.getElementById('app'));
2 changes: 1 addition & 1 deletion src/js/routes.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import React from 'react/addons';
import React from 'react';
import { Router, Route, Redirect } from 'react-router';

import App from './App';
Expand Down
3 changes: 1 addition & 2 deletions src/js/stores/UserStore.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
'use strict';

import React from 'react/addons';
import Reflux from 'reflux';
import { update } from 'react-addons-update';
import Actions from '../actions/Actions';
import { firebaseUrl } from '../util/constants';

import Firebase from 'firebase';
const baseRef = new Firebase(firebaseUrl);
const usersRef = baseRef.child('users');

const update = React.addons.update;

const defaultUser = {
uid: '',
Expand Down
2 changes: 1 addition & 1 deletion src/js/views/404.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import React from 'react/addons';
import React from 'react';

// components
const Link = require('react-router').Link;
Expand Down
2 changes: 1 addition & 1 deletion src/js/views/Posts.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import React from 'react/addons';
import React from 'react';
import Reflux from 'reflux';
import Actions from '../actions/Actions';
import { History } from 'react-router';
Expand Down
2 changes: 1 addition & 1 deletion src/js/views/Profile.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import React from 'react/addons';
import React from 'react';
import Reflux from 'reflux';
import { History } from 'react-router';

Expand Down
2 changes: 1 addition & 1 deletion src/js/views/Single.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import React from 'react/addons';
import React from 'react';
import Reflux from 'reflux';
import { History } from 'react-router';

Expand Down
11 changes: 6 additions & 5 deletions test/components/Login-test.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

import createParent from '../util/createParent';
import { findDOMNode } from 'react-dom';

var React;
var Login;
Expand All @@ -10,9 +11,9 @@ describe('Login Component', () => {
let login;

beforeEach(() => {
React = require('react/addons');
React = require('react');
Login = require('../../src/js/components/Login');
TestUtils = React.addons.TestUtils;
TestUtils = require('react-addons-test-utils');
});

describe('DOM', () => {
Expand All @@ -22,7 +23,7 @@ describe('Login Component', () => {
});

it('should render a div with className "login"', () => {
expect(login.getDOMNode().className).to.equal('login');
expect(findDOMNode(login).className).to.equal('login');
});

it('should render an error message only when passed as prop', () => {
Expand All @@ -35,7 +36,7 @@ describe('Login Component', () => {
login = TestUtils.renderIntoDocument(<Login errorMessage="uh oh" />);
error = TestUtils.findRenderedDOMComponentWithClass(login, 'error');

expect(error.getDOMNode().textContent).to.equal('uh oh');
expect(findDOMNode(error).textContent).to.equal('uh oh');
});
});

Expand All @@ -54,7 +55,7 @@ describe('Login Component', () => {
});

it('should disable submit button until props update', () => {
let submitButton = TestUtils.findRenderedDOMComponentWithTag(login, 'button').getDOMNode();
let submitButton = findDOMNode(TestUtils.findRenderedDOMComponentWithTag(login, 'button'));

login.setState({ submitted: true });
expect(submitButton.disabled).to.equal(true);
Expand Down
10 changes: 6 additions & 4 deletions test/components/LoginLinks-test.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

import { findDOMNode } from 'react-dom';

var React;
var LoginLinks;
var TestUtils;
Expand All @@ -8,9 +10,9 @@ describe('LoginLinks Component', () => {
let loginLinks;

beforeEach(() => {
React = require('react/addons');
React = require('react');
LoginLinks = require('../../src/js/components/LoginLinks');
TestUtils = React.addons.TestUtils;
TestUtils = require('react-addons-test-utils');
});

describe('DOM', function() {
Expand All @@ -19,12 +21,12 @@ describe('LoginLinks Component', () => {
});

it('should render a span with className "login-links"', () => {
expect(loginLinks.getDOMNode().className).to.equal('login-links');
expect(findDOMNode(loginLinks).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);
let linkText = links.map((link) => findDOMNode(link).textContent);

expect(links.length).to.equal(2);
expect(linkText[0]).to.equal('Sign In');
Expand Down
11 changes: 6 additions & 5 deletions test/components/Modal-test.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

import createParent from '../util/createParent';
import { findDOMNode } from 'react-dom';

var React;
var Modal;
Expand All @@ -9,9 +10,9 @@ var TestUtils;
describe('Modal Component', () => {

beforeEach(() => {
React = require('react/addons');
React = require('react');
Modal = require('../../src/js/components/Modal');
TestUtils = React.addons.TestUtils;
TestUtils = require('react-addons-test-utils');
});

describe('DOM', () => {
Expand Down Expand Up @@ -65,14 +66,14 @@ describe('Modal Component', () => {

it('should call props.hideModal when .modal-overlay is clicked', () => {
expect(hideModalSpy).to.have.not.been.called;
TestUtils.Simulate.click(modal.getDOMNode());
TestUtils.Simulate.click(findDOMNode(modal));
expect(hideModalSpy).to.have.been.called;
});

it('should call props.hideModal when .modal-close is clicked', () => {
const modalClose = TestUtils.findRenderedDOMComponentWithClass(modal, 'modal-close');
expect(hideModalSpy).to.have.not.been.called;
TestUtils.Simulate.click(modalClose.getDOMNode());
TestUtils.Simulate.click(findDOMNode(modalClose));
expect(hideModalSpy).to.have.been.called;
});

Expand All @@ -86,7 +87,7 @@ describe('Modal Component', () => {
it('should not be removed when .modal-inner is clicked', () => {
const modalInner = TestUtils.findRenderedDOMComponentWithClass(modal, 'modal-inner');
expect(hideModalSpy).to.have.not.been.called;
TestUtils.Simulate.click(modalInner.getDOMNode());
TestUtils.Simulate.click(findDOMNode(modalInner));
expect(hideModalSpy).to.have.not.been.called;
});
});
Expand Down
4 changes: 2 additions & 2 deletions test/components/ProfileLink-test.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use strict';

import React from 'react/addons';
import React from 'react';
import { Link } from 'react-router';
import ProfileLink from '../../src/js/components/ProfileLink';

const TestUtils = React.addons.TestUtils;
import TestUtils from 'react-addons-test-utils';

const userData = {
username: 'echenley',
Expand Down
Loading

0 comments on commit 0988aa2

Please sign in to comment.