diff --git a/package-lock.json b/package-lock.json index 02288e3..eb16e8c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5084,6 +5084,19 @@ "semver": "^5.3.0" } }, + "eslint-loader": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/eslint-loader/-/eslint-loader-2.1.2.tgz", + "integrity": "sha512-rA9XiXEOilLYPOIInvVH5S/hYfyTPyxag6DZhoQOduM+3TkghAEQ3VcFO8VnX4J4qg/UIBzp72aOf/xvYmpmsg==", + "dev": true, + "requires": { + "loader-fs-cache": "^1.0.0", + "loader-utils": "^1.0.2", + "object-assign": "^4.0.1", + "object-hash": "^1.1.4", + "rimraf": "^2.6.1" + } + }, "eslint-module-utils": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.4.0.tgz", @@ -9550,6 +9563,57 @@ "strip-bom": "^2.0.0" } }, + "loader-fs-cache": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/loader-fs-cache/-/loader-fs-cache-1.0.2.tgz", + "integrity": "sha512-70IzT/0/L+M20jUlEqZhZyArTU6VKLRTYRDAYN26g4jfzpJqjipLL3/hgYpySqI9PwsVRHHFja0LfEmsx9X2Cw==", + "dev": true, + "requires": { + "find-cache-dir": "^0.1.1", + "mkdirp": "0.5.1" + }, + "dependencies": { + "find-cache-dir": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-0.1.1.tgz", + "integrity": "sha1-yN765XyKUqinhPnjHFfHQumToLk=", + "dev": true, + "requires": { + "commondir": "^1.0.1", + "mkdirp": "^0.5.1", + "pkg-dir": "^1.0.0" + } + }, + "find-up": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", + "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", + "dev": true, + "requires": { + "path-exists": "^2.0.0", + "pinkie-promise": "^2.0.0" + } + }, + "path-exists": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz", + "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", + "dev": true, + "requires": { + "pinkie-promise": "^2.0.0" + } + }, + "pkg-dir": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-1.0.0.tgz", + "integrity": "sha1-ektQio1bstYp1EcFb/TpyTFM89Q=", + "dev": true, + "requires": { + "find-up": "^1.0.0" + } + } + } + }, "loader-runner": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-2.4.0.tgz", @@ -10506,6 +10570,12 @@ } } }, + "object-hash": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/object-hash/-/object-hash-1.3.1.tgz", + "integrity": "sha512-OSuu/pU4ENM9kmREg0BdNrUDIl1heYa4mBZacJc+vVWz4GtAwu7jO8s4AIt2aGRUTqxykpWzI3Oqnsm13tTMDA==", + "dev": true + }, "object-inspect": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.6.0.tgz", diff --git a/package.json b/package.json index 0d9da92..146f983 100644 --- a/package.json +++ b/package.json @@ -87,6 +87,7 @@ "eslint": "5.16.0", "eslint-config-airbnb": "17.1.0", "eslint-import-resolver-webpack": "0.11.1", + "eslint-loader": "^2.1.2", "eslint-plugin-import": "2.17.3", "eslint-plugin-jsx-a11y": "6.2.1", "eslint-plugin-react": "7.13.0", diff --git a/src/components/__snapshots__/widget.test.js.snap b/src/components/__snapshots__/widget.test.js.snap index fa8038d..244c726 100644 --- a/src/components/__snapshots__/widget.test.js.snap +++ b/src/components/__snapshots__/widget.test.js.snap @@ -31,12 +31,14 @@ exports[` open/close 1`] = ` > Header - X - +
open/close 1`] = `
- ^ OPEN ^ - +
`; @@ -91,12 +95,14 @@ exports[` open/close 2`] = ` > Header - X - +
open/close 3`] = ` > Header
- X - +
open/close 3`] = `
- ^ OPEN ^ - +
`; diff --git a/src/components/widget.js b/src/components/widget.js index a02a411..9d379d3 100644 --- a/src/components/widget.js +++ b/src/components/widget.js @@ -1,5 +1,4 @@ import React, { Component } from 'react'; -import PropTypes from 'prop-types'; import { Transition } from 'react-transition-group'; import './widget.scss'; @@ -29,31 +28,43 @@ class Widget extends Component { } renderBody = () => { - if (this.state.showDock) { - return ( - - ^ OPEN ^ - - ); - } - return ''; + const { showDock } = this.state; + + if (!showDock) return ''; + + return ( + + ); } render() { + const { opened } = this.state; const body = this.renderBody(); return (
- + {status => (
Header
- +
Body @@ -70,6 +81,4 @@ class Widget extends Component { } } -Widget.propTypes = {}; - export default Widget; diff --git a/src/components/widget.test.js b/src/components/widget.test.js index f5075c8..890a641 100644 --- a/src/components/widget.test.js +++ b/src/components/widget.test.js @@ -9,7 +9,7 @@ describe('', () => { expect(widgetDom).toMatchSnapshot(); { - const dockAnchorEl = widgetDom.find('a.dock'); + const dockAnchorEl = widgetDom.find('button.dock'); expect(dockAnchorEl).toHaveLength(1); // open widget dockAnchorEl.simulate('click'); @@ -20,14 +20,14 @@ describe('', () => { // dock does not exist anymore expect(widgetDom.find('a.dock')).toHaveLength(0); - const closeAnchorEl = await waitForSelection(widgetDom, 'a.widget-header-icon'); + const closeAnchorEl = await waitForSelection(widgetDom, 'button.widget-header-icon'); expect(closeAnchorEl).toHaveLength(1); // close widget closeAnchorEl.simulate('click'); { - const dockAnchorEl = await waitForSelection(widgetDom, 'a.dock'); + const dockAnchorEl = await waitForSelection(widgetDom, 'button.dock'); expect(dockAnchorEl).toHaveLength(1); } diff --git a/webpack.config.js b/webpack.config.js index 762df62..ad8d670 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -36,6 +36,11 @@ const defaultConfig = { exclude: /node_modules/, use: ['babel-loader'], }, + { + test: /\.js$/, + exclude: /node_modules/, + use: ['eslint-loader'] + }, { test: /\.(scss|css)$/, use: [