Addressed the PR comment

This commit is contained in:
Filip Barl
2017-02-22 18:15:24 +01:00
parent f1b80c0cfc
commit 689973ae7f

View File

@@ -1,18 +1,20 @@
import { fromJS } from 'immutable';
import {
initEdgesFromNodes,
collapseMultiEdges,
} from '../layouter-utils';
describe('LayouterUtils', () => {
const LayouterUtils = require('../layouter-utils');
describe('initEdgesFromNodes', () => {
const f = LayouterUtils.initEdgesFromNodes;
it('should return map of edges', () => {
const input = fromJS({
a: { adjacency: ['b', 'c'] },
b: { adjacency: ['a', 'b'] },
c: {}
});
expect(f(input).toJS()).toEqual({
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 },
@@ -22,8 +24,6 @@ describe('LayouterUtils', () => {
});
describe('collapseMultiEdges', () => {
const f = LayouterUtils.collapseMultiEdges;
it('should return collapsed multi-edges', () => {
const input = fromJS({
'a-b': { id: 'a-b', source: 'a', target: 'b' },
@@ -31,7 +31,7 @@ describe('LayouterUtils', () => {
'b-a': { id: 'b-a', source: 'b', target: 'a' },
'b-b': { id: 'b-b', source: 'b', target: 'b' },
});
expect(f(input).toJS()).toEqual({
expect(collapseMultiEdges(input).toJS()).toEqual({
'a-b': { id: 'a-b', source: 'a', target: 'b', bidirectional: true },
'a-c': { id: 'a-c', source: 'a', target: 'c' },
'b-b': { id: 'b-b', source: 'b', target: 'b' },