Enable linter for js test files

This commit is contained in:
David Kaltschmidt
2015-11-11 19:09:40 +01:00
parent 6cb825f6f3
commit 7d5cc11d7e
5 changed files with 24 additions and 25 deletions

View File

@@ -1 +0,0 @@
app/**/__tests__/*.js

View File

@@ -3,6 +3,11 @@
"globals": {
__WS_URL__: false
},
"env": {
"browser": true,
"jest": true,
"node": true
},
"rules": {
"comma-dangle": 0,
"func-names": 0,

View File

@@ -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));
});
});

View File

@@ -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');
});
});

View File

@@ -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();
});
});