Skip to content

Commit 741df73

Browse files
committed
merge master
2 parents 821a83d + e05b81f commit 741df73

File tree

20 files changed

+201
-284
lines changed

20 files changed

+201
-284
lines changed

.eslintignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
11
webpack/*
2-
karma.conf.js
3-
tests.webpack.js

.travis.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ dist: trusty
33
language: node_js
44

55
node_js:
6-
- "4"
7-
- "5"
86
- "6"
97
- "stable"
108

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,10 @@ After this modification to both loaders you will be able to use scss and less fi
241241
242242
#### Unit Tests
243243
244-
The project uses [Jest](https://facebook.github.io/jest/) and [Mocha](https://mochajs.org/) to run your unit tests, it uses [Karma](http://karma-runner.github.io/0.13/index.html) as the test runner, it enables the feature that you are able to render your tests to the browser (e.g: Firefox, Chrome etc.), which means you are able to use the [Test Utilities](http://facebook.github.io/react/docs/test-utils.html) from Facebook api like `renderIntoDocument()`.
244+
The project uses [Jest](https://facebook.github.io/jest/) with [Mocha](https://mochajs.org/) to run your unit tests.
245245
246246
To run the tests in the project, just simply run `npm test` if you have `Chrome` installed, it will be automatically launched as a test service for you.
247247
248-
To keep watching your test suites that you are working on, just set `singleRun: false` in the `karma.conf.js` file. Please be sure set it to `true` if you are running `npm test` on a continuous integration server (travis-ci, etc).
249-
250248
## Deployment on Heroku
251249
252250
To get this project to work on Heroku, you need to:

api/__tests__/api-test.js

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ describe('mapUrl', () => {
1111

1212
it('extracts nothing if the url is empty', () => {
1313
const url = '';
14-
const splittedUrlPath = url.split('?')[0].split('/').slice(1);
14+
const splittedUrlPath = url
15+
.split('?')[0]
16+
.split('/')
17+
.slice(1);
1518
const availableActions = { a: 1, widget: { c: 1, load: () => 'baz' } };
1619

1720
expect(mapUrl(availableActions, splittedUrlPath)).to.deep.equal({
@@ -22,7 +25,10 @@ describe('mapUrl', () => {
2225

2326
it('extracts nothing if nothing was found', () => {
2427
const url = '/widget/load/?foo=bar';
25-
const splittedUrlPath = url.split('?')[0].split('/').slice(1);
28+
const splittedUrlPath = url
29+
.split('?')[0]
30+
.split('/')
31+
.slice(1);
2632
const availableActions = { a: 1, info: { c: 1, load: () => 'baz' } };
2733

2834
expect(mapUrl(availableActions, splittedUrlPath)).to.deep.equal({
@@ -33,7 +39,10 @@ describe('mapUrl', () => {
3339

3440
it('extracts the available actions and the params from an relative url string with GET params', () => {
3541
const url = '/widget/load/param1/xzy?foo=bar';
36-
const splittedUrlPath = url.split('?')[0].split('/').slice(1);
42+
const splittedUrlPath = url
43+
.split('?')[0]
44+
.split('/')
45+
.slice(1);
3746
const availableActions = { a: 1, widget: { c: 1, load: () => 'baz' } };
3847

3948
expect(mapUrl(availableActions, splittedUrlPath)).to.deep.equal({
@@ -44,7 +53,10 @@ describe('mapUrl', () => {
4453

4554
it('extracts the available actions from an url string without GET params', () => {
4655
const url = '/widget/load/?foo=bar';
47-
const splittedUrlPath = url.split('?')[0].split('/').slice(1);
56+
const splittedUrlPath = url
57+
.split('?')[0]
58+
.split('/')
59+
.slice(1);
4860
const availableActions = { a: 1, widget: { c: 1, load: () => 'baz' } };
4961

5062
expect(mapUrl(availableActions, splittedUrlPath)).to.deep.equal({
@@ -55,7 +67,10 @@ describe('mapUrl', () => {
5567

5668
it('does not find the avaialble action if deeper nesting is required', () => {
5769
const url = '/widget';
58-
const splittedUrlPath = url.split('?')[0].split('/').slice(1);
70+
const splittedUrlPath = url
71+
.split('?')[0]
72+
.split('/')
73+
.slice(1);
5974
const availableActions = { a: 1, widget: { c: 1, load: () => 'baz' } };
6075

6176
expect(mapUrl(availableActions, splittedUrlPath)).to.deep.equal({

jest.config.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module.exports = {
2+
moduleDirectories: [
3+
process.env.NODE_PATH,
4+
'node_modules'
5+
],
6+
moduleNameMapper: {
7+
'\\.(jpg|jpeg|png|gif|eot|otf|svg|ttf|woff|woff2)$': '<rootDir>/__mocks__/fileMock.js',
8+
'\\.(css|less|scss)$': 'identity-obj-proxy'
9+
},
10+
globals: {
11+
__CLIENT__: process.env.NODE_PATH === 'src',
12+
__SERVER__: process.env.NODE_PATH === 'api',
13+
__DEVELOPMENT__: true,
14+
__DEVTOOLS__: false, // <-------- DISABLE redux-devtools HERE
15+
__DLLS__: false
16+
}
17+
};

karma.conf.js

Lines changed: 0 additions & 98 deletions
This file was deleted.

package.json

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,31 +24,29 @@
2424
],
2525
"main": "bin/server.js",
2626
"scripts": {
27-
"precommit": "lint-staged",
28-
"precommit-prettier": "eslint --print-config .eslintrc.js | prettier-eslint --write",
2927
"start": "concurrently --kill-others \"npm run start-prod\" \"npm run start-prod-api\"",
30-
"start-prod": "better-npm-run start-prod",
31-
"start-prod-api": "better-npm-run start-prod-api",
28+
"start-prod": "bnr start-prod",
29+
"start-prod-api": "bnr start-prod-api",
3230
"dev": "concurrently --kill-others \"npm run watch-client\" \"npm run start-dev\" \"npm run start-dev-api\"",
33-
"start-dev": "better-npm-run start-dev",
34-
"start-dev-api": "better-npm-run start-dev-api",
35-
"watch-client": "better-npm-run watch-client",
36-
"build": "better-npm-run build",
31+
"start-dev": "bnr start-dev",
32+
"start-dev-api": "bnr start-dev-api",
33+
"watch-client": "bnr watch-client",
34+
"build": "bnr build",
3735
"build-dlls": "webpack --colors --display-error-details --config webpack/vendor.config.js",
3836
"postinstall": "concurrently \"npm run build\" \"npm run build-dlls\"",
39-
"prettier": "npm run precommit-prettier -- \"./+(src|api)/**/*.js\"",
37+
"precommit": "lint-staged",
38+
"prettier": "prettier-eslint --write --eslint-config-path .eslintrc './+(src|api)/**/*.js'",
4039
"lint": "eslint -c .eslintrc api src",
41-
"test": "karma start",
42-
"test-node": "jest $(find api -name '*-test.js')",
43-
"test-node-watch": "jest $(find api -name '*-test.js') --watch",
40+
"test": "bnr test",
41+
"test-node": "bnr test-node",
42+
"lighthouse-report": "lighthouse http://localhost:8080 --view",
4443
"docker-build": ". ./docker/build.sh",
4544
"docker-dev": ". ./docker/run.dev.sh",
46-
"docker-prod": ". ./docker/run.prod.sh",
47-
"lighthouse-report": "LIGHTHOUSE_CHROMIUM_PATH=$(which google-chrome) lighthouse http://localhost:8080"
45+
"docker-prod": ". ./docker/run.prod.sh"
4846
},
4947
"lint-staged": {
5048
"+(src|api)/**/*.js": [
51-
"npm run precommit-prettier",
49+
"prettier-eslint --write --eslint-config-path .eslintrc",
5250
"eslint -c .eslintrc",
5351
"git add"
5452
]
@@ -105,6 +103,18 @@
105103
"env": {
106104
"NODE_ENV": "production"
107105
}
106+
},
107+
"test": {
108+
"command": "jest src",
109+
"env": {
110+
"NODE_PATH": "src"
111+
}
112+
},
113+
"test-node": {
114+
"command": "jest api",
115+
"env": {
116+
"NODE_PATH": "api"
117+
}
108118
}
109119
},
110120
"dependencies": {
@@ -171,7 +181,7 @@
171181
},
172182
"devDependencies": {
173183
"babel-eslint": "^7.1.1",
174-
"babel-jest": "^20.0.1",
184+
"babel-jest": "^21.0.2",
175185
"babel-loader": "^7.0.0",
176186
"better-npm-run": "^0.1.0",
177187
"bootstrap-loader": "^2.1.0",
@@ -180,6 +190,7 @@
180190
"clean-webpack-plugin": "^0.1.15",
181191
"concurrently": "^3.3.0",
182192
"css-loader": "^0.28.5",
193+
"enzyme": "^2.9.1",
183194
"eslint": "^4.4.1",
184195
"eslint-config-airbnb": "^15.1.0",
185196
"eslint-loader": "^1.6.1",
@@ -192,23 +203,15 @@
192203
"happypack": "^3.0.2",
193204
"html-webpack-plugin": "^2.30.1",
194205
"husky": "^0.14.3",
195-
"jest": "^20.0.1",
196-
"jest-cli": "^20.0.1",
197-
"karma": "^1.4.1",
198-
"karma-cli": "^1.0.1",
199-
"karma-mocha": "^1.3.0",
200-
"karma-mocha-reporter": "^2.2.2",
201-
"karma-phantomjs-launcher": "^1.0.2",
202-
"karma-sourcemap-loader": "^0.3.7",
203-
"karma-webpack": "^2.0.2",
206+
"identity-obj-proxy": "^3.0.0",
207+
"jest": "^21.1.0",
208+
"jest-cli": "^21.1.0",
204209
"less": "^2.7.2",
205210
"less-loader": "^4.0.3",
206211
"lighthouse": "^2.4.0",
207212
"lint-staged": "^4.0.3",
208213
"mocha": "^3.5.0",
209214
"node-sass": "^4.5.0",
210-
"phantomjs-polyfill": "^0.0.2",
211-
"phantomjs-prebuilt": "^2.1.15",
212215
"piping": "^1.0.0-rc.4",
213216
"postcss": "^6.0.9",
214217
"postcss-browser-reporter": "^0.5.0",
@@ -217,7 +220,7 @@
217220
"postcss-loader": "^2.0.5",
218221
"postcss-reporter": "^5.0.0",
219222
"postcss-url": "^7.1.2",
220-
"prettier-eslint": "^6.4.2",
223+
"prettier-eslint-cli": "^4.3.2",
221224
"react-a11y": "^0.3.3",
222225
"react-addons-test-utils": "^15.4.2",
223226
"react-hot-loader": "^3.0.0-beta.3",

src/app.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ const storage = __SERVER__ ? null : require('localforage');
1414
const host = clientUrl => (__SERVER__ ? `http://${config.apiHost}:${config.apiPort}` : clientUrl);
1515

1616
const configureApp = transport =>
17-
feathers().configure(transport).configure(hooks()).configure(authentication({ storage }));
17+
feathers()
18+
.configure(transport)
19+
.configure(hooks())
20+
.configure(authentication({ storage }));
1821

1922
export const socket = io('', { path: host('/ws'), autoConnect: false });
2023

src/components/LoginForm/LoginForm.js

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,23 @@ import { reduxForm, Field, propTypes } from 'redux-form';
33
import loginValidation from './loginValidation';
44

55
// eslint-disable-next-line react/prop-types
6-
const Input = ({ input, label, type, meta: { touched, error } }) =>
7-
(<div className={`form-group ${error && touched ? 'has-error' : ''}`}>
6+
const Input = ({ input, label, type, meta: { touched, error } }) => (
7+
<div className={`form-group ${error && touched ? 'has-error' : ''}`}>
88
<label htmlFor={input.name} className="col-sm-2">
99
{label}
1010
</label>
1111
<div className="col-sm-10">
1212
<input {...input} type={type} className="form-control" />
1313
{error && touched && <span className="glyphicon glyphicon-remove form-control-feedback" />}
1414
{error &&
15-
touched &&
16-
<div className="text-danger">
17-
<strong>
18-
{error}
19-
</strong>
20-
</div>}
15+
touched && (
16+
<div className="text-danger">
17+
<strong>{error}</strong>
18+
</div>
19+
)}
2120
</div>
22-
</div>);
21+
</div>
22+
);
2323

2424
@reduxForm({
2525
form: 'login',
@@ -37,12 +37,11 @@ export default class LoginForm extends Component {
3737
<form className="form-horizontal" onSubmit={handleSubmit}>
3838
<Field name="email" type="text" component={Input} label="Email" />
3939
<Field name="password" type="password" component={Input} label="Password" />
40-
{error &&
40+
{error && (
4141
<p className="text-danger">
42-
<strong>
43-
{error}
44-
</strong>
45-
</p>}
42+
<strong>{error}</strong>
43+
</p>
44+
)}
4645
<button className="btn btn-success" type="submit">
4746
<i className="fa fa-sign-in" /> Log In
4847
</button>

0 commit comments

Comments
 (0)