Skip to content

Commit

Permalink
[chore] prettier all the things
Browse files Browse the repository at this point in the history
  • Loading branch information
Aditya Vohra authored and diasbruno committed Oct 11, 2017
1 parent c0620e0 commit 47d0d87
Show file tree
Hide file tree
Showing 17 changed files with 467 additions and 419 deletions.
13 changes: 11 additions & 2 deletions .eslintrc → .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
{
module.exports = {
"env": {
"es6": true,
"browser": true
},

"parser": "babel-eslint",

"parserOptions": {
"ecmaVersion": 7,
"ecmaFeatures": {
"jsx": true
},
"sourceType": "module"
},

"settings": {
"react": {
"createClass": "createReactClass",
Expand All @@ -19,10 +22,15 @@
},
"propWrapperFunctions": [ "forbidExtraProps" ]
},
"extends": ["eslint:recommended", "plugin:react/recommended"],

"extends": ["eslint:recommended", "plugin:react/recommended", "prettier"],

"plugins": ["prettier"],

"globals": {
"process": true
},

"rules": {
"quotes": [0],
"comma-dangle": [2, "only-multiline"],
Expand All @@ -34,6 +42,7 @@
"arrow-parens": [0],
"space-before-function-paren": [0],
"jsx-a11y/no-static-element-interactions": [0],
"prettier/prettier": "error",
"react/no-find-dom-node": [0],
"react/jsx-closing-bracket-location": [0],
"react/require-default-props": 0
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"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/ spec/"
"lint": "eslint src/ specs/"
},
"authors": [
"Ryan Florence"
Expand All @@ -33,7 +33,9 @@
"coveralls": "^2.13.1",
"cross-env": "^5.0.1",
"eslint": "^4.8.0",
"eslint-config-prettier": "^2.6.0",
"eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-prettier": "^2.3.1",
"eslint-plugin-react": "^7.4.0",
"gitbook-cli": "^2.3.0",
"istanbul-instrumenter-loader": "^3.0.0",
Expand All @@ -47,6 +49,7 @@
"karma-webpack": "^2.0.4",
"mocha": "3.5.3",
"npm-run-all": "^4.1.1",
"prettier": "^1.7.4",
"react": "^16.0.0",
"react-dom": "^16.0.0",
"react-router": "^4.2.0",
Expand Down
60 changes: 32 additions & 28 deletions specs/Modal.events.spec.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,48 @@
/* eslint-env mocha */
import 'should';
import sinon from 'sinon';
import React from 'react';
import ReactDOM from 'react-dom';
import TestUtils from 'react-dom/test-utils';
import Modal from '../src/components/Modal.js';
import "should";
import sinon from "sinon";
import {
moverlay, mcontent,
clickAt, mouseDownAt, mouseUpAt, escKeyDown, tabKeyDown,
renderModal, emptyDOM
} from './helper';
moverlay,
mcontent,
clickAt,
mouseDownAt,
mouseUpAt,
escKeyDown,
tabKeyDown,
renderModal,
emptyDOM
} from "./helper";

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

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

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

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

it('should close on Esc key event', () => {
it("should close on Esc key event", () => {
const requestCloseCallback = sinon.spy();
const modal = renderModal({
isOpen: true,
Expand All @@ -52,8 +56,8 @@ export default () => {
ev.should.be.ok();
});

describe('shouldCloseOnoverlayClick', () => {
it('when false, click on overlay should not close', () => {
describe("shouldCloseOnoverlayClick", () => {
it("when false, click on overlay should not close", () => {
const requestCloseCallback = sinon.spy();
const modal = renderModal({
isOpen: true,
Expand All @@ -64,7 +68,7 @@ export default () => {
requestCloseCallback.called.should.not.be.ok();
});

it('when true, click on overlay must close', () => {
it("when true, click on overlay must close", () => {
const requestCloseCallback = sinon.spy();
const modal = renderModal({
isOpen: true,
Expand All @@ -75,7 +79,7 @@ export default () => {
requestCloseCallback.called.should.be.ok();
});

it('overlay mouse down and content mouse up, should not close', () => {
it("overlay mouse down and content mouse up, should not close", () => {
const requestCloseCallback = sinon.spy();
const modal = renderModal({
isOpen: true,
Expand All @@ -87,7 +91,7 @@ export default () => {
requestCloseCallback.called.should.not.be.ok();
});

it('content mouse down and overlay mouse up, should not close', () => {
it("content mouse down and overlay mouse up, should not close", () => {
const requestCloseCallback = sinon.spy();
const modal = renderModal({
isOpen: true,
Expand All @@ -100,20 +104,20 @@ export default () => {
});
});

it('should not stop event propagation', () => {
it("should not stop event propagation", () => {
let hasPropagated = false;
const modal = renderModal({
isOpen: true,
shouldCloseOnOverlayClick: true
});
window.addEventListener('click', () => {
window.addEventListener("click", () => {
hasPropagated = true;
});
moverlay(modal).dispatchEvent(new MouseEvent('click', { bubbles: true }));
moverlay(modal).dispatchEvent(new MouseEvent("click", { bubbles: true }));
hasPropagated.should.be.ok();
});

it('verify event passing on overlay click', () => {
it("verify event passing on overlay click", () => {
const requestCloseCallback = sinon.spy();
const modal = renderModal({
isOpen: true,
Expand All @@ -123,7 +127,7 @@ export default () => {
// click the overlay
clickAt(moverlay(modal), {
// Used to test that this was the event received
fakeData: 'ABC'
fakeData: "ABC"
});
requestCloseCallback.called.should.be.ok();
// Check if event is passed to onRequestClose callback.
Expand Down
Loading

0 comments on commit 47d0d87

Please sign in to comment.