Skip to content

Commit 16c3dce

Browse files
committed
[chore] update dependencies, lint rules and refactor tests.
- remove unused dependencies. - changed from 'expect' to 'should'. - update lint rules.
1 parent 13dfc4e commit 16c3dce

10 files changed

+166
-191
lines changed

.eslintrc

+13-6
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,26 @@
33
"es6": true,
44
"browser": true
55
},
6-
"extends": "airbnb",
6+
"parser": "babel-eslint",
77
"parserOptions": {
88
"ecmaVersion": 7,
99
"ecmaFeatures": {
10-
"experimentalObjectRestSpread": true,
1110
"jsx": true
1211
},
1312
"sourceType": "module"
1413
},
15-
"parser": "babel-eslint",
14+
"settings": {
15+
"react": {
16+
"createClass": "createReactClass",
17+
"pragma": "React",
18+
"version": "15.0"
19+
},
20+
"propWrapperFunctions": [ "forbidExtraProps" ]
21+
},
22+
"extends": ["eslint:recommended", "plugin:react/recommended"],
23+
"globals": {
24+
"process": true
25+
},
1626
"rules": {
1727
"quotes": [0],
1828
"comma-dangle": [2, "only-multiline"],
@@ -23,12 +33,9 @@
2333
"func-names": [0],
2434
"arrow-parens": [0],
2535
"space-before-function-paren": [0],
26-
"import/no-extraneous-dependencies": [2, {"devDependencies": true}],
2736
"jsx-a11y/no-static-element-interactions": [0],
2837
"react/no-find-dom-node": [0],
2938
"react/jsx-closing-bracket-location": [0],
30-
"react/jsx-filename-extension": ["error", {"extensions": [".js"]}],
31-
"react/forbid-prop-types": [1, {"forbid": ["any"]}],
3239
"react/require-default-props": 0
3340
}
3441
}

karma.conf.js

+15-16
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,33 @@
1-
const browsers = [process.env.CONTINUOUS_INTEGRATION ? 'Firefox' : 'Chrome'];
1+
let browsers = ['Chrome'];
2+
let coverageType = 'text';
3+
4+
if (process.env.CONTINUOUS_INTEGRATION) {
5+
browsers = ['Firefox'];
6+
coverageType = 'lcovonly';
7+
}
28

39
module.exports = function(config) {
410
config.set({
5-
6-
basePath: '',
7-
811
frameworks: ['mocha'],
912

10-
files: [
11-
'specs/spec_index.js'
12-
],
13-
1413
preprocessors: {
15-
'specs/spec_index.js': ['webpack', 'sourcemap']
14+
'./src/*.js': ['coverage'],
15+
'./src/**/*.js': ['coverage'],
16+
'./specs/index.js': ['webpack', 'sourcemap']
1617
},
1718

19+
files: ['./specs/index.js'],
20+
1821
webpack: require('./webpack.test.config'),
1922

20-
webpackMiddleware: {
21-
stats: 'errors-only'
22-
},
23+
webpackMiddleware: { stats: 'errors-only' },
2324

2425
reporters: ['mocha', 'coverage'],
2526

26-
mochaReporter: {
27-
showDiff: true
28-
},
27+
mochaReporter: { showDiff: true },
2928

3029
coverageReporter: {
31-
type : 'lcov',
30+
type : coverageType,
3231
dir : 'coverage/',
3332
subdir: '.'
3433
},

package.json

+15-22
Original file line numberDiff line numberDiff line change
@@ -15,51 +15,44 @@
1515
"scripts": {
1616
"start": "./node_modules/.bin/webpack-dev-server --inline --host 127.0.0.1 --content-base examples/",
1717
"test": "cross-env NODE_ENV=test karma start",
18-
"lint": "eslint src/"
18+
"lint": "eslint src/ spec/"
1919
},
2020
"authors": [
2121
"Ryan Florence"
2222
],
2323
"license": "MIT",
2424
"devDependencies": {
25-
"babel-cli": "^6.24.1",
2625
"babel-core": "^6.25.0",
27-
"babel-eslint": "^7.1.1",
28-
"babel-loader": "^6.2.4",
26+
"babel-eslint": "^8.0.0",
27+
"babel-loader": "^7.1.2",
2928
"babel-plugin-add-module-exports": "^0.2.1",
3029
"babel-preset-es2015": "^6.24.1",
3130
"babel-preset-react": "^6.24.1",
3231
"babel-preset-stage-2": "^6.24.1",
33-
"codeclimate-test-reporter": "^0.4.0",
3432
"coveralls": "^2.13.1",
3533
"cross-env": "^5.0.1",
36-
"envify": "^3.4.1",
37-
"eslint": "^3.19.0",
38-
"eslint-config-airbnb": "^15.0.1",
39-
"eslint-plugin-import": "^2.3.0",
40-
"eslint-plugin-jsx-a11y": "^5.0.3",
34+
"eslint": "^4.7.1",
35+
"eslint-plugin-jsx-a11y": "^6.0.2",
4136
"eslint-plugin-react": "^7.1.0",
42-
"expect": "^1.20.2",
4337
"gitbook-cli": "^2.3.0",
44-
"istanbul-instrumenter-loader": "0.2.0",
38+
"istanbul-instrumenter-loader": "^3.0.0",
4539
"karma": "^1.3.0",
46-
"karma-chrome-launcher": "2.0.0",
47-
"karma-cli": "1.0.1",
40+
"karma-chrome-launcher": "2.2.0",
4841
"karma-coverage": "^1.1.1",
49-
"karma-firefox-launcher": "1.0.0",
42+
"karma-firefox-launcher": "1.0.1",
5043
"karma-mocha": "^1.3.0",
5144
"karma-mocha-reporter": "^2.2.1",
5245
"karma-sourcemap-loader": "^0.3.7",
53-
"karma-webpack": "^1.8.1",
54-
"mocha": "3.2.0",
55-
"npm-run-all": "^3.1.2",
46+
"karma-webpack": "^2.0.4",
47+
"mocha": "3.5.3",
48+
"npm-run-all": "^4.1.1",
5649
"react": "^15.6.1",
5750
"react-dom": "^15.6.1",
58-
"rf-release": "0.4.0",
51+
"should": "^13.1.0",
5952
"sinon": "next",
60-
"uglify-js": "2.4.24",
61-
"webpack": "^1.12.14",
62-
"webpack-dev-server": "1.11.0"
53+
"uglify-js": "3.1.1",
54+
"webpack": "^3.6.0",
55+
"webpack-dev-server": "2.8.2"
6356
},
6457
"dependencies": {
6558
"exenv": "^1.2.0",

specs/Modal.events.spec.js

+18-18
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
11
/* eslint-env mocha */
2+
import 'should';
23
import sinon from 'sinon';
3-
import expect from 'expect';
44
import React from 'react';
55
import ReactDOM from 'react-dom';
66
import TestUtils from 'react-dom/test-utils';
7-
import Modal from '../src/components/Modal';
7+
import Modal from '../src/components/Modal.js';
88
import {
99
moverlay, mcontent,
1010
clickAt, mouseDownAt, mouseUpAt, escKeyDown, tabKeyDown,
1111
renderModal, emptyDOM
1212
} from './helper';
1313

14-
describe('Events', () => {
14+
export default () => {
1515
afterEach('Unmount modal', emptyDOM);
1616

1717
it('should trigger the onAfterOpen callback', () => {
1818
const afterOpenCallback = sinon.spy();
1919
renderModal({ isOpen: true, onAfterOpen: afterOpenCallback });
20-
expect(afterOpenCallback.called).toBeTruthy();
20+
afterOpenCallback.called.should.be.ok();
2121
});
2222

2323
it('keeps focus inside the modal when child has no tabbable elements', () => {
2424
let tabPrevented = false;
2525
const modal = renderModal({ isOpen: true }, 'hello');
2626
const content = mcontent(modal);
27-
expect(document.activeElement).toEqual(content);
27+
document.activeElement.should.be.eql(content);
2828
tabKeyDown(content, {
2929
preventDefault() { tabPrevented = true; }
3030
});
31-
expect(tabPrevented).toEqual(true);
31+
tabPrevented.should.be.eql(true);
3232
});
3333

3434
it('handles case when child has no tabbable elements', () => {
3535
const modal = renderModal({ isOpen: true }, 'hello');
3636
const content = mcontent(modal);
3737
tabKeyDown(content);
38-
expect(document.activeElement).toEqual(content);
38+
document.activeElement.should.be.eql(content);
3939
});
4040

4141
it('should close on Esc key event', () => {
@@ -46,10 +46,10 @@ describe('Events', () => {
4646
onRequestClose: requestCloseCallback
4747
});
4848
escKeyDown(mcontent(modal));
49-
expect(requestCloseCallback.called).toBeTruthy();
49+
requestCloseCallback.called.should.be.ok();
5050
// Check if event is passed to onRequestClose callback.
51-
const event = requestCloseCallback.getCall(0).args[0];
52-
expect(event).toExist();
51+
const ev = requestCloseCallback.getCall(0).args[0];
52+
ev.should.be.ok();
5353
});
5454

5555
describe('shouldCloseOnoverlayClick', () => {
@@ -61,7 +61,7 @@ describe('Events', () => {
6161
});
6262
const overlay = moverlay(modal);
6363
clickAt(overlay);
64-
expect(!requestCloseCallback.called).toBeTruthy();
64+
requestCloseCallback.called.should.not.be.ok();
6565
});
6666

6767
it('when true, click on overlay must close', () => {
@@ -72,7 +72,7 @@ describe('Events', () => {
7272
onRequestClose: requestCloseCallback
7373
});
7474
clickAt(moverlay(modal));
75-
expect(requestCloseCallback.called).toBeTruthy();
75+
requestCloseCallback.called.should.be.ok();
7676
});
7777

7878
it('overlay mouse down and content mouse up, should not close', () => {
@@ -84,7 +84,7 @@ describe('Events', () => {
8484
});
8585
mouseDownAt(moverlay(modal));
8686
mouseUpAt(mcontent(modal));
87-
expect(!requestCloseCallback.called).toBeTruthy();
87+
requestCloseCallback.called.should.not.be.ok();
8888
});
8989

9090
it('content mouse down and overlay mouse up, should not close', () => {
@@ -96,7 +96,7 @@ describe('Events', () => {
9696
});
9797
mouseDownAt(mcontent(modal));
9898
mouseUpAt(moverlay(modal));
99-
expect(!requestCloseCallback.called).toBeTruthy();
99+
requestCloseCallback.called.should.not.be.ok();
100100
});
101101
});
102102

@@ -110,7 +110,7 @@ describe('Events', () => {
110110
hasPropagated = true;
111111
});
112112
moverlay(modal).dispatchEvent(new MouseEvent('click', { bubbles: true }));
113-
expect(hasPropagated).toBeTruthy();
113+
hasPropagated.should.be.ok();
114114
});
115115

116116
it('verify event passing on overlay click', () => {
@@ -125,9 +125,9 @@ describe('Events', () => {
125125
// Used to test that this was the event received
126126
fakeData: 'ABC'
127127
});
128-
expect(requestCloseCallback.called).toBeTruthy();
128+
requestCloseCallback.called.should.be.ok();
129129
// Check if event is passed to onRequestClose callback.
130130
const event = requestCloseCallback.getCall(0).args[0];
131-
expect(event).toExist();
131+
event.should.be.ok();
132132
});
133-
});
133+
};

0 commit comments

Comments
 (0)