Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jpellizzari committed Mar 20, 2017
1 parent 451f6b2 commit df2190d
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 28 deletions.
38 changes: 20 additions & 18 deletions client/app/scripts/charts/__tests__/node-layout-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { fromJS, Map } from 'immutable';

import { constructEdgeId as edge } from '../../utils/layouter-utils';

const makeMap = Map;

describe('NodesLayout', () => {
Expand Down Expand Up @@ -30,9 +32,9 @@ describe('NodesLayout', () => {
n4: {id: 'n4'}
}),
edges: fromJS({
'n1-n3': {id: 'n1-n3', source: 'n1', target: 'n3'},
'n1-n4': {id: 'n1-n4', source: 'n1', target: 'n4'},
'n2-n4': {id: 'n2-n4', source: 'n2', target: 'n4'}
[edge('n1', 'n3')]: {id: edge('n1', 'n3'), source: 'n1', target: 'n3'},
[edge('n1', 'n4')]: {id: edge('n1', 'n4'), source: 'n1', target: 'n4'},
[edge('n2', 'n4')]: {id: edge('n2', 'n4'), source: 'n2', target: 'n4'}
})
},
rank4: {
Expand All @@ -43,9 +45,9 @@ describe('NodesLayout', () => {
n4: {id: 'n4', rank: 'B'}
}),
edges: fromJS({
'n1-n3': {id: 'n1-n3', source: 'n1', target: 'n3'},
'n1-n4': {id: 'n1-n4', source: 'n1', target: 'n4'},
'n2-n4': {id: 'n2-n4', source: 'n2', target: 'n4'}
[edge('n1', 'n3')]: {id: edge('n1', 'n3'), source: 'n1', target: 'n3'},
[edge('n1', 'n4')]: {id: edge('n1', 'n4'), source: 'n1', target: 'n4'},
[edge('n2', 'n4')]: {id: edge('n2', 'n4'), source: 'n2', target: 'n4'}
})
},
rank6: {
Expand All @@ -58,11 +60,11 @@ describe('NodesLayout', () => {
n6: {id: 'n6', rank: 'B'},
}),
edges: fromJS({
'n1-n3': {id: 'n1-n3', source: 'n1', target: 'n3'},
'n1-n4': {id: 'n1-n4', source: 'n1', target: 'n4'},
'n1-n5': {id: 'n1-n5', source: 'n1', target: 'n5'},
'n2-n4': {id: 'n2-n4', source: 'n2', target: 'n4'},
'n2-n6': {id: 'n2-n6', source: 'n2', target: 'n6'},
[edge('n1', 'n3')]: {id: edge('n1', 'n3'), source: 'n1', target: 'n3'},
[edge('n1', 'n4')]: {id: edge('n1', 'n4'), source: 'n1', target: 'n4'},
[edge('n1', 'n5')]: {id: edge('n1', 'n5'), source: 'n1', target: 'n5'},
[edge('n2', 'n4')]: {id: edge('n2', 'n4'), source: 'n2', target: 'n4'},
[edge('n2', 'n6')]: {id: edge('n2', 'n6'), source: 'n2', target: 'n6'},
})
},
removeEdge24: {
Expand All @@ -73,8 +75,8 @@ describe('NodesLayout', () => {
n4: {id: 'n4'}
}),
edges: fromJS({
'n1-n3': {id: 'n1-n3', source: 'n1', target: 'n3'},
'n1-n4': {id: 'n1-n4', source: 'n1', target: 'n4'}
[edge('n1', 'n3')]: {id: edge('n1', 'n3'), source: 'n1', target: 'n3'},
[edge('n1', 'n4')]: {id: edge('n1', 'n4'), source: 'n1', target: 'n4'}
})
},
removeNode2: {
Expand All @@ -84,8 +86,8 @@ describe('NodesLayout', () => {
n4: {id: 'n4'}
}),
edges: fromJS({
'n1-n3': {id: 'n1-n3', source: 'n1', target: 'n3'},
'n1-n4': {id: 'n1-n4', source: 'n1', target: 'n4'}
[edge('n1', 'n3')]: {id: edge('n1', 'n3'), source: 'n1', target: 'n3'},
[edge('n1', 'n4')]: {id: edge('n1', 'n4'), source: 'n1', target: 'n4'}
})
},
removeNode23: {
Expand All @@ -94,7 +96,7 @@ describe('NodesLayout', () => {
n4: {id: 'n4'}
}),
edges: fromJS({
'n1-n4': {id: 'n1-n4', source: 'n1', target: 'n4'}
[edge('n1', 'n4')]: {id: edge('n1', 'n4'), source: 'n1', target: 'n4'}
})
},
single3: {
Expand All @@ -114,7 +116,7 @@ describe('NodesLayout', () => {
n5: {id: 'n5'}
}),
edges: fromJS({
'n1-n4': {id: 'n1-n4', source: 'n1', target: 'n4'}
[edge('n1', 'n4')]: {id: edge('n1', 'n4'), source: 'n1', target: 'n4'}
})
},
singlePortrait6: {
Expand All @@ -127,7 +129,7 @@ describe('NodesLayout', () => {
n6: {id: 'n6'}
}),
edges: fromJS({
'n1-n4': {id: 'n1-n4', source: 'n1', target: 'n4'}
[edge('n1', 'n4')]: {id: edge('n1', 'n4'), source: 'n1', target: 'n4'}
})
}
};
Expand Down
2 changes: 1 addition & 1 deletion client/app/scripts/constants/naming.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@

export const EDGE_ID_SEPARATOR = '-------';
export const EDGE_ID_SEPARATOR = '---';
7 changes: 4 additions & 3 deletions client/app/scripts/reducers/__tests__/root-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {is, fromJS} from 'immutable';
// Root reducer test suite using Jasmine matchers
import { constructEdgeId } from '../../utils/layouter-utils';

describe('RootReducer', () => {
const ActionTypes = require('../../constants/action-types').default;
Expand Down Expand Up @@ -543,12 +544,12 @@ describe('RootReducer', () => {
it('highlights bidirectional edges', () => {
const action = {
type: ActionTypes.ENTER_EDGE,
edgeId: 'abc123-def456'
edgeId: constructEdgeId('abc123', 'def456')
};
const nextState = reducer(initialState, action);
expect(nextState.get('highlightedEdgeIds').toJS()).toEqual([
'abc123-def456',
'def456-abc123'
constructEdgeId('abc123', 'def456'),
constructEdgeId('def456', 'abc123')
]);
});
});
11 changes: 6 additions & 5 deletions client/app/scripts/utils/__tests__/layouter-utils-test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { fromJS } from 'immutable';

import {
initEdgesFromNodes
initEdgesFromNodes,
constructEdgeId as edge
} from '../layouter-utils';


Expand All @@ -14,10 +15,10 @@ describe('LayouterUtils', () => {
c: {}
});
expect(initEdgesFromNodes(input).toJS()).toEqual({
'a-b': { id: 'a-b', source: 'a', target: 'b', value: 1 },
'a-c': { id: 'a-c', source: 'a', target: 'c', value: 1 },
'b-a': { id: 'b-a', source: 'b', target: 'a', value: 1 },
'b-b': { id: 'b-b', source: 'b', target: 'b', value: 1 },
[edge('a', 'b')]: { id: edge('a', 'b'), source: 'a', target: 'b', value: 1 },
[edge('a', 'c')]: { id: edge('a', 'c'), source: 'a', target: 'c', value: 1 },
[edge('b', 'a')]: { id: edge('b', 'a'), source: 'b', target: 'a', value: 1 },
[edge('b', 'b')]: { id: edge('b', 'b'), source: 'b', target: 'b', value: 1 },
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion client/app/scripts/utils/layouter-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Map as makeMap } from 'immutable';
import { EDGE_ID_SEPARATOR } from '../constants/naming';


function constructEdgeId(source, target) {
export function constructEdgeId(source, target) {
return [source, target].join(EDGE_ID_SEPARATOR);
}

Expand Down

0 comments on commit df2190d

Please sign in to comment.