[Ivan Diaz] - Add jest and demo page

This commit is contained in:
Ivan Diaz 2015-08-16 14:35:14 -03:00
parent d5cdf14e80
commit 1975ad6ccd
5 changed files with 91 additions and 0 deletions

View File

@ -7,6 +7,7 @@ import App from './App';
import HomePage from './pages/HomePage';
import SearchPage from './pages/SearchPage';
import NotFoundPage from './pages/NotFoundPage';
import DemoPage from './pages/component-demo-page';
export default (
<Route handler={App} path='/'>
@ -15,6 +16,7 @@ export default (
<Route name='Home' path='/' handler={HomePage} />
<Route name='Search' path='/search' handler={SearchPage} />
<Route name='Demo' path='/demo' handler={DemoPage} />
<NotFoundRoute handler={NotFoundPage} />

View File

@ -0,0 +1,17 @@
jest.dontMock('../Footer.js');
import React from 'react/addons';
import Footer from '../Footer.js';
var TestUtils = React.addons.TestUtils;
describe('Footer', () => {
it('should 2 equal 2', () => {
var footer = TestUtils.renderIntoDocument(
<Footer />
);
var label = TestUtils.findRenderedDOMComponentWithTag(
footer, 'footer');
expect(label.getDOMNode().textContent).toEqual('Footer');
});
});

View File

@ -0,0 +1,35 @@
'use strict';
import React from 'react/addons';
import {Link} from 'react-router';
import DocumentTitle from 'react-document-title';
import Footer from '../components/Footer.js';
var HomePage = React.createClass({
propTypes: {
currentUser: React.PropTypes.object.isRequired
},
render() {
return (
<DocumentTitle title="Demo Page">
<section className="home-page">
<div>
FooterDemo
</div>
<div>
<Footer />
</div>
</section>
</DocumentTitle>
);
}
});
export default HomePage;

View File

@ -19,7 +19,11 @@
"node": "^0.12.x",
"npm": "^2.1.x"
},
"scripts": {
"test": "jest"
},
"devDependencies": {
"babel-core": "^5.8.22",
"babelify": "^6.1.x",
"browser-sync": "^2.7.13",
"browserify": "^10.2.6",
@ -38,6 +42,7 @@
"gulp-uglify": "^1.2.0",
"gulp-util": "^3.0.6",
"humps": "^0.6.0",
"jest-cli": "^0.4.19",
"lodash": "^3.10.0",
"morgan": "^1.6.1",
"react": "^0.13.x",
@ -48,5 +53,20 @@
"superagent": "^1.2.0",
"vinyl-source-stream": "^1.1.0",
"watchify": "^3.2.x"
},
"jest": {
"scriptPreprocessor": "./preprocessor.js",
"testFileExtensions": [
"es6",
"js"
],
"moduleFileExtensions": [
"js",
"json",
"es6"
],
"unmockedModulePathPatterns": [
"react"
]
}
}

17
preprocessor.js Normal file
View File

@ -0,0 +1,17 @@
'use strict';
var babel = require('babel-core');
module.exports = {
process: function(src, filename) {
// Ignore files other than .js, .es, .jsx or .es6
if (!babel.canCompile(filename)) {
return '';
}
// Ignore all files within node_modules
if (filename.indexOf('node_modules') === -1) {
return babel.transform(src, {filename: filename}).code;
}
return src;
}
};