diff --git a/client/.eslintignore b/client/.eslintignore deleted file mode 100644 index a2e2b2a31..000000000 --- a/client/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -app/**/__tests__/*.js diff --git a/client/.eslintrc b/client/.eslintrc index 6ab748f15..2040a1074 100644 --- a/client/.eslintrc +++ b/client/.eslintrc @@ -3,6 +3,11 @@ "globals": { __WS_URL__: false }, + "env": { + "browser": true, + "jest": true, + "node": true + }, "rules": { "comma-dangle": 0, "func-names": 0, diff --git a/client/app/scripts/charts/__tests__/node-layout-test.js b/client/app/scripts/charts/__tests__/node-layout-test.js index d0a92c974..3a66950f6 100644 --- a/client/app/scripts/charts/__tests__/node-layout-test.js +++ b/client/app/scripts/charts/__tests__/node-layout-test.js @@ -3,6 +3,8 @@ jest.dontMock('../../constants/naming'); // edge naming: 'source-target' import { fromJS, Map } from 'immutable'; +const makeMap = Map; + describe('NodesLayout', () => { const NodesLayout = require('../nodes-layout'); @@ -72,8 +74,8 @@ describe('NodesLayout', () => { beforeEach(() => { options = { - nodeCache: Map(), - edgeCache: Map() + nodeCache: makeMap(), + edgeCache: makeMap() }; }); @@ -187,8 +189,8 @@ describe('NodesLayout', () => { nodes = result.nodes.toJS(); resultCoords = getNodeCoordinates(result.nodes); - expect(resultCoords.slice(0,2)).toEqual(coords.slice(0,2)); - expect(resultCoords.slice(2,6)).toEqual(coords.slice(4,8)); + expect(resultCoords.slice(0, 2)).toEqual(coords.slice(0, 2)); + expect(resultCoords.slice(2, 6)).toEqual(coords.slice(4, 8)); }); it('keeps nodes in rectangle after removed node reappears', () => { @@ -227,8 +229,7 @@ describe('NodesLayout', () => { // console.log('re-add 1 node', nodes); resultCoords = getNodeCoordinates(result.nodes); - expect(resultCoords.slice(0,2)).toEqual(coords.slice(0,2)); - expect(resultCoords.slice(2,6)).toEqual(coords.slice(4,8)); + expect(resultCoords.slice(0, 2)).toEqual(coords.slice(0, 2)); + expect(resultCoords.slice(2, 6)).toEqual(coords.slice(4, 8)); }); - }); diff --git a/client/app/scripts/components/__tests__/node-details-test.js b/client/app/scripts/components/__tests__/node-details-test.js index 6082964b0..852a5fd85 100644 --- a/client/app/scripts/components/__tests__/node-details-test.js +++ b/client/app/scripts/components/__tests__/node-details-test.js @@ -10,10 +10,11 @@ describe('NodeDetails', () => { const React = require('react'); const Immutable = require('immutable'); const TestUtils = require('react/lib/ReactTestUtils'); + const makeMap = Immutable.OrderedMap; beforeEach(() => { NodeDetails = require('../node-details.js'); - nodes = Immutable.OrderedMap(); + nodes = makeMap(); nodeId = 'n1'; }); @@ -32,5 +33,4 @@ describe('NodeDetails', () => { const title = TestUtils.findRenderedDOMComponentWithClass(c, 'node-details-header-label'); expect(title.textContent).toBe('Node 1'); }); - }); diff --git a/client/app/scripts/stores/__tests__/app-store-test.js b/client/app/scripts/stores/__tests__/app-store-test.js index 5e524e1ce..5deb0fef0 100644 --- a/client/app/scripts/stores/__tests__/app-store-test.js +++ b/client/app/scripts/stores/__tests__/app-store-test.js @@ -66,11 +66,6 @@ describe('AppStore', function() { topologyId: 'topo2' }; - const ClickGroupingAction = { - type: ActionTypes.CLICK_GROUPING, - grouping: 'grouped' - }; - const CloseWebsocketAction = { type: ActionTypes.CLOSE_WEBSOCKET }; @@ -200,9 +195,9 @@ describe('AppStore', function() { it('sets topology options from route', function() { RouteAction.state = { - "topologyId":"topo1", - "selectedNodeId": null, - "topologyOptions": {'topo1':{'option1': 'on'}}}; + 'topologyId': 'topo1', + 'selectedNodeId': null, + 'topologyOptions': {'topo1': {'option1': 'on'}}}; registeredCallback(RouteAction); expect(AppStore.getActiveTopologyOptions().get('option1')).toBe('on'); expect(AppStore.getAppState().topologyOptions.topo1.option1).toBe('on'); @@ -216,9 +211,9 @@ describe('AppStore', function() { it('uses default topology options from route', function() { RouteAction.state = { - "topologyId":"topo1", - "selectedNodeId": null, - "topologyOptions": null}; + 'topologyId': 'topo1', + 'selectedNodeId': null, + 'topologyOptions': null}; registeredCallback(RouteAction); registeredCallback(ReceiveTopologiesAction); registeredCallback(ClickTopologyAction); @@ -255,7 +250,7 @@ describe('AppStore', function() { expect(AppStore.getSelectedNodeId()).toBe('n1'); expect(AppStore.getNodes().toJS()).toEqual(NODE_SET); - registeredCallback(HitEscAction) + registeredCallback(HitEscAction); expect(AppStore.getSelectedNodeId()).toBe(null); expect(AppStore.getNodes().toJS()).toEqual(NODE_SET); }); @@ -271,7 +266,7 @@ describe('AppStore', function() { expect(AppStore.getAppState().selectedNodeId).toEqual('n1'); // go back in browsing - RouteAction.state = {"topologyId":"topo1","selectedNodeId": null}; + RouteAction.state = {'topologyId': 'topo1', 'selectedNodeId': null}; registeredCallback(RouteAction); expect(AppStore.getSelectedNodeId()).toBe(null); expect(AppStore.getNodes().toJS()).toEqual(NODE_SET); @@ -322,7 +317,7 @@ describe('AppStore', function() { expect(AppStore.getAdjacentNodes('n1').has('n1')).toBeTruthy(); expect(AppStore.getAdjacentNodes('n1').has('n2')).toBeTruthy(); - registeredCallback(HitEscAction) + registeredCallback(HitEscAction); expect(AppStore.getAdjacentNodes().size).toEqual(0); }); @@ -339,5 +334,4 @@ describe('AppStore', function() { registeredCallback(ClickTopologyAction); expect(AppStore.isTopologyEmpty()).toBeFalsy(); }); - });