Skip to content

Commit

Permalink
[chore] update dependencies, lint rules and refactor tests.
Browse files Browse the repository at this point in the history
- remove unused dependencies.
- changed from 'expect' to 'should'.
- update lint rules.
  • Loading branch information
diasbruno committed Sep 22, 2017
1 parent 13dfc4e commit 16c3dce
Show file tree
Hide file tree
Showing 10 changed files with 166 additions and 191 deletions.
19 changes: 13 additions & 6 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,26 @@
"es6": true,
"browser": true
},
"extends": "airbnb",
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 7,
"ecmaFeatures": {
"experimentalObjectRestSpread": true,
"jsx": true
},
"sourceType": "module"
},
"parser": "babel-eslint",
"settings": {
"react": {
"createClass": "createReactClass",
"pragma": "React",
"version": "15.0"
},
"propWrapperFunctions": [ "forbidExtraProps" ]
},
"extends": ["eslint:recommended", "plugin:react/recommended"],
"globals": {
"process": true
},
"rules": {
"quotes": [0],
"comma-dangle": [2, "only-multiline"],
Expand All @@ -23,12 +33,9 @@
"func-names": [0],
"arrow-parens": [0],
"space-before-function-paren": [0],
"import/no-extraneous-dependencies": [2, {"devDependencies": true}],
"jsx-a11y/no-static-element-interactions": [0],
"react/no-find-dom-node": [0],
"react/jsx-closing-bracket-location": [0],
"react/jsx-filename-extension": ["error", {"extensions": [".js"]}],
"react/forbid-prop-types": [1, {"forbid": ["any"]}],
"react/require-default-props": 0
}
}
31 changes: 15 additions & 16 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
const browsers = [process.env.CONTINUOUS_INTEGRATION ? 'Firefox' : 'Chrome'];
let browsers = ['Chrome'];
let coverageType = 'text';

if (process.env.CONTINUOUS_INTEGRATION) {
browsers = ['Firefox'];
coverageType = 'lcovonly';
}

module.exports = function(config) {
config.set({

basePath: '',

frameworks: ['mocha'],

files: [
'specs/spec_index.js'
],

preprocessors: {
'specs/spec_index.js': ['webpack', 'sourcemap']
'./src/*.js': ['coverage'],
'./src/**/*.js': ['coverage'],
'./specs/index.js': ['webpack', 'sourcemap']
},

files: ['./specs/index.js'],

webpack: require('./webpack.test.config'),

webpackMiddleware: {
stats: 'errors-only'
},
webpackMiddleware: { stats: 'errors-only' },

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

mochaReporter: {
showDiff: true
},
mochaReporter: { showDiff: true },

coverageReporter: {
type : 'lcov',
type : coverageType,
dir : 'coverage/',
subdir: '.'
},
Expand Down
37 changes: 15 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,51 +15,44 @@
"scripts": {
"start": "./node_modules/.bin/webpack-dev-server --inline --host 127.0.0.1 --content-base examples/",
"test": "cross-env NODE_ENV=test karma start",
"lint": "eslint src/"
"lint": "eslint src/ spec/"
},
"authors": [
"Ryan Florence"
],
"license": "MIT",
"devDependencies": {
"babel-cli": "^6.24.1",
"babel-core": "^6.25.0",
"babel-eslint": "^7.1.1",
"babel-loader": "^6.2.4",
"babel-eslint": "^8.0.0",
"babel-loader": "^7.1.2",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"codeclimate-test-reporter": "^0.4.0",
"coveralls": "^2.13.1",
"cross-env": "^5.0.1",
"envify": "^3.4.1",
"eslint": "^3.19.0",
"eslint-config-airbnb": "^15.0.1",
"eslint-plugin-import": "^2.3.0",
"eslint-plugin-jsx-a11y": "^5.0.3",
"eslint": "^4.7.1",
"eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-react": "^7.1.0",
"expect": "^1.20.2",
"gitbook-cli": "^2.3.0",
"istanbul-instrumenter-loader": "0.2.0",
"istanbul-instrumenter-loader": "^3.0.0",
"karma": "^1.3.0",
"karma-chrome-launcher": "2.0.0",
"karma-cli": "1.0.1",
"karma-chrome-launcher": "2.2.0",
"karma-coverage": "^1.1.1",
"karma-firefox-launcher": "1.0.0",
"karma-firefox-launcher": "1.0.1",
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.1",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^1.8.1",
"mocha": "3.2.0",
"npm-run-all": "^3.1.2",
"karma-webpack": "^2.0.4",
"mocha": "3.5.3",
"npm-run-all": "^4.1.1",
"react": "^15.6.1",
"react-dom": "^15.6.1",
"rf-release": "0.4.0",
"should": "^13.1.0",
"sinon": "next",
"uglify-js": "2.4.24",
"webpack": "^1.12.14",
"webpack-dev-server": "1.11.0"
"uglify-js": "3.1.1",
"webpack": "^3.6.0",
"webpack-dev-server": "2.8.2"
},
"dependencies": {
"exenv": "^1.2.0",
Expand Down
36 changes: 18 additions & 18 deletions specs/Modal.events.spec.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
/* eslint-env mocha */
import 'should';
import sinon from 'sinon';
import expect from 'expect';
import React from 'react';
import ReactDOM from 'react-dom';
import TestUtils from 'react-dom/test-utils';
import Modal from '../src/components/Modal';
import Modal from '../src/components/Modal.js';
import {
moverlay, mcontent,
clickAt, mouseDownAt, mouseUpAt, escKeyDown, tabKeyDown,
renderModal, emptyDOM
} from './helper';

describe('Events', () => {
export default () => {
afterEach('Unmount modal', emptyDOM);

it('should trigger the onAfterOpen callback', () => {
const afterOpenCallback = sinon.spy();
renderModal({ isOpen: true, onAfterOpen: afterOpenCallback });
expect(afterOpenCallback.called).toBeTruthy();
afterOpenCallback.called.should.be.ok();
});

it('keeps focus inside the modal when child has no tabbable elements', () => {
let tabPrevented = false;
const modal = renderModal({ isOpen: true }, 'hello');
const content = mcontent(modal);
expect(document.activeElement).toEqual(content);
document.activeElement.should.be.eql(content);
tabKeyDown(content, {
preventDefault() { tabPrevented = true; }
});
expect(tabPrevented).toEqual(true);
tabPrevented.should.be.eql(true);
});

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

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

describe('shouldCloseOnoverlayClick', () => {
Expand All @@ -61,7 +61,7 @@ describe('Events', () => {
});
const overlay = moverlay(modal);
clickAt(overlay);
expect(!requestCloseCallback.called).toBeTruthy();
requestCloseCallback.called.should.not.be.ok();
});

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

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

it('content mouse down and overlay mouse up, should not close', () => {
Expand All @@ -96,7 +96,7 @@ describe('Events', () => {
});
mouseDownAt(mcontent(modal));
mouseUpAt(moverlay(modal));
expect(!requestCloseCallback.called).toBeTruthy();
requestCloseCallback.called.should.not.be.ok();
});
});

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

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

0 comments on commit 16c3dce

Please sign in to comment.