Skip to content

Commit 7a4ebd6

Browse files
committed
upgrade dependencies
1 parent 1853eda commit 7a4ebd6

File tree

31 files changed

+224
-214
lines changed

31 files changed

+224
-214
lines changed

.babelrc

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
{
22
"presets": [
33
"react",
4-
"es2015",
4+
[
5+
"env",
6+
{
7+
"targets": {
8+
"browsers": ["last 2 versions", "IE >= 8"],
9+
"node": "current"
10+
}
11+
}
12+
],
513
"stage-0"
614
],
715
"plugins": [
@@ -11,7 +19,9 @@
1119
],
1220
"env": {
1321
"development": {
14-
"plugins": []
22+
"plugins": [
23+
"transform-react-jsx-source"
24+
]
1525
}
1626
}
1727
}

.eslintrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,24 @@
1818
"no-console": "off",
1919
"no-param-reassign": "off",
2020
"no-underscore-dangle": "off",
21+
"prefer-promise-reject-errors": "warn",
2122
"prefer-template": "warn",
2223
"react/forbid-prop-types": "warn",
24+
"react/jsx-closing-tag-location": ["warn", "line-aligned"],
2325
"react/jsx-filename-extension": "off",
2426
"react/jsx-no-target-blank": "warn",
2527
"react/no-multi-comp": ["error", {"ignoreStateless": true}],
2628
"react/no-unescaped-entities": "off",
2729
"react/prefer-stateless-function": "warn",
30+
"jsx-a11y/label-has-for": ["error", {"allowChildren": true}],
31+
"jsx-a11y/anchor-is-valid": [
32+
"error",
33+
{
34+
"components": ["Link"],
35+
"specialLink": ["to"],
36+
"aspects": ["noHref", "invalidHref", "preferButton"]
37+
}
38+
],
2839
"import/default": "off",
2940
"import/extensions": "off",
3041
"import/no-extraneous-dependencies": "off",
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
import { expect } from 'chai';
2-
import timekeeper from 'timekeeper';
2+
import sinon from 'sinon';
33
import loadInfo from '../loadInfo';
44

5+
let clock;
6+
57
describe('loadInfo', () => {
68
it('loads the current date', () => {
79
const now = Date.now();
8-
timekeeper.freeze(now);
10+
clock = sinon.useFakeTimers({ now });
911

1012
expect(loadInfo()).to.deep.equal({ time: now, message: 'This came from the api server' });
13+
14+
clock.restore();
1115
});
1216
});

api/actions/__tests__/widget-load-test.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,22 @@ describe('widget load', () => {
1515
});
1616

1717
it('uses the widgets from the session', async () => {
18-
const widgets = await load({ session: { user: {}, widgets: ['a', 'b', 'c'] } }, undefined);
18+
const clock = sinon.useFakeTimers();
19+
const [widgets] = await Promise.all([
20+
load({ session: { user: {}, widgets: ['a', 'b', 'c'] } }, undefined),
21+
clock.tick(1000),
22+
clock.restore()
23+
]);
1924
expect(widgets.length).to.equal(3);
2025
});
2126

2227
it('initializes the widgets ', async () => {
23-
const widgets = await load({ session: { user: {} } }, undefined);
28+
const clock = sinon.useFakeTimers();
29+
const [widgets] = await Promise.all([
30+
load({ session: { user: {} } }, undefined),
31+
clock.tick(1000),
32+
clock.restore()
33+
]);
2434
expect(widgets.length).to.equal(4);
2535
expect(widgets[0].color).to.equal('Red');
2636
});
@@ -32,8 +42,9 @@ describe('widget load', () => {
3242
});
3343

3444
it('rejects the call', async () => {
45+
const clock = sinon.useFakeTimers();
3546
try {
36-
await load({ session: { user: {} } }, undefined);
47+
await Promise.all([load({ session: { user: {} } }, undefined), clock.tick(1000), clock.restore()]);
3748
} catch (err) {
3849
expect(err).to.equal('Widget load fails 33% of the time. You were unlucky.');
3950
}

api/actions/__tests__/widget-update-test.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,29 @@ describe('widget update', () => {
2525

2626
it('does not accept green widgets', async () => {
2727
sinon.stub(load, 'default').resolves(widgets);
28+
const clock = sinon.useFakeTimers();
2829
try {
29-
await update({ session: {}, body: { color: 'Green' } });
30+
await Promise.all([update({ session: {}, body: { color: 'Green' } }), clock.tick(1500), clock.restore()]);
3031
} catch (err) {
3132
expect(err.color).to.equal('We do not accept green widgets');
3233
}
3334
});
3435

3536
it('fails to load widgets', async () => {
3637
sinon.stub(load, 'default').rejects(new Error('Widget fail to load.'));
38+
const clock = sinon.useFakeTimers();
3739
try {
38-
await update({ session: {}, body: { color: 'Blue' } });
40+
await Promise.all([update({ session: {}, body: { color: 'Blue' } }), clock.tick(1500), clock.restore()]);
3941
} catch (err) {
4042
expect(err.message).to.equal('Widget fail to load.');
4143
}
4244
});
4345

4446
it('updates a widget', async () => {
4547
sinon.stub(load, 'default').resolves(widgets);
48+
const clock = sinon.useFakeTimers();
4649
const widget = { id: 2, color: 'Blue' };
47-
const res = await update({ session: {}, body: widget });
50+
const [res] = await Promise.all([update({ session: {}, body: widget }), clock.tick(1500), clock.restore()]);
4851
expect(res).to.deep.equal(widget);
4952
expect(widgets[1]).to.deep.equal(widget);
5053
});

api/actions/widget/load.js

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,32 @@
11
const initialWidgets = [
2-
{ id: 1, color: 'Red', sprocketCount: 7, owner: 'John' },
3-
{ id: 2, color: 'Taupe', sprocketCount: 1, owner: 'George' },
4-
{ id: 3, color: 'Green', sprocketCount: 8, owner: 'Ringo' },
5-
{ id: 4, color: 'Blue', sprocketCount: 2, owner: 'Paul' }
2+
{
3+
id: 1,
4+
color: 'Red',
5+
sprocketCount: 7,
6+
owner: 'John'
7+
},
8+
{
9+
id: 2,
10+
color: 'Taupe',
11+
sprocketCount: 1,
12+
owner: 'George'
13+
},
14+
{
15+
id: 3,
16+
color: 'Green',
17+
sprocketCount: 8,
18+
owner: 'Ringo'
19+
},
20+
{
21+
id: 4,
22+
color: 'Blue',
23+
sprocketCount: 2,
24+
owner: 'Paul'
25+
}
626
];
727

828
export function getWidgets(req) {
9-
let widgets = req.session.widgets;
29+
let { widgets } = req.session;
1030
if (!widgets) {
1131
widgets = initialWidgets;
1232
req.session.widgets = widgets;

api/api.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import middleware from './middleware';
1212
import services from './services';
1313
import * as actions from './actions';
1414
import mapUrl from './utils/url.js';
15-
import auth, { socketAuth } from './services/authentication';
15+
import auth from './services/authentication';
1616

1717
process.on('unhandledRejection', error => console.error(error));
1818

@@ -23,14 +23,12 @@ app
2323
.set('config', config)
2424
.use(morgan('dev'))
2525
.use(cookieParser())
26-
.use(
27-
session({
28-
secret: 'react and redux rule!!!!',
29-
resave: false,
30-
saveUninitialized: false,
31-
cookie: { maxAge: 60000 }
32-
})
33-
)
26+
.use(session({
27+
secret: 'react and redux rule!!!!',
28+
resave: false,
29+
saveUninitialized: false,
30+
cookie: { maxAge: 60000 }
31+
}))
3432
.use(bodyParser.urlencoded({ extended: true }))
3533
.use(bodyParser.json());
3634

@@ -96,8 +94,6 @@ const bufferSize = 100;
9694
const messageBuffer = new Array(bufferSize);
9795
let messageIndex = 0;
9896

99-
app.io.use(socketAuth(app));
100-
10197
app.io.on('connection', socket => {
10298
const user = socket.feathers.user ? { ...socket.feathers.user, password: undefined } : undefined;
10399
socket.emit('news', { msg: "'Hello World!' from server", user });

api/middleware/index.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,14 @@ export default function middleware() {
77

88
app.use(notFound());
99
app.use(logger(app));
10-
app.use(
11-
errorHandler({
12-
json: (error, req, res) => {
13-
res.json(error);
14-
},
15-
html: (error, req, res) => {
16-
res.json(error);
17-
// render your error view with the error object
18-
// res.render('error', error); // set view engine of express if you want to use res.render
19-
}
20-
})
21-
);
10+
app.use(errorHandler({
11+
json: (error, req, res) => {
12+
res.json(error);
13+
},
14+
html: (error, req, res) => {
15+
res.json(error);
16+
// render your error view with the error object
17+
// res.render('error', error); // set view engine of express if you want to use res.render
18+
}
19+
}));
2220
}

api/services/authentication/index.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import oauth2 from 'feathers-authentication-oauth2';
66
import FacebookTokenStrategy from 'passport-facebook-token';
77
import { discard } from 'feathers-hooks-common';
88

9-
export socketAuth from './socketAuth';
10-
119
function populateUser(authConfig) {
1210
return async hook => {
1311
const payload = await hook.app.passport.verifyJWT(hook.result.accessToken, authConfig);
@@ -44,12 +42,10 @@ export default function authenticationService() {
4442
.configure(auth(config))
4543
.configure(jwt())
4644
.configure(local()) // .configure(oauth1()) // TODO twitter example
47-
.configure(
48-
oauth2({
49-
name: 'facebook', // if the name differs from your config key you need to pass your config options explicitly
50-
Strategy: FacebookTokenStrategy
51-
})
52-
);
45+
.configure(oauth2({
46+
name: 'facebook', // if the name differs from your config key you need to pass your config options explicitly
47+
Strategy: FacebookTokenStrategy
48+
}));
5349

5450
app.service('authentication').hooks({
5551
before: {

api/services/authentication/socketAuth.js

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

0 commit comments

Comments
 (0)