layouter-utils-test.js 874 B

123456789101112131415161718192021222324252627282930313233
  1. import { fromJS } from 'immutable';
  2. import {
  3. initEdgesFromNodes,
  4. constructEdgeId as edge
  5. } from '../layouter-utils';
  6. describe('LayouterUtils', () => {
  7. describe('initEdgesFromNodes', () => {
  8. it('should return map of edges', () => {
  9. const input = fromJS({
  10. a: { adjacency: ['b', 'c'] },
  11. b: { adjacency: ['a', 'b'] },
  12. c: {}
  13. });
  14. expect(initEdgesFromNodes(input).toJS()).toEqual({
  15. [edge('a', 'b')]: {
  16. id: edge('a', 'b'), source: 'a', target: 'b', value: 1
  17. },
  18. [edge('a', 'c')]: {
  19. id: edge('a', 'c'), source: 'a', target: 'c', value: 1
  20. },
  21. [edge('b', 'a')]: {
  22. id: edge('b', 'a'), source: 'b', target: 'a', value: 1
  23. },
  24. [edge('b', 'b')]: {
  25. id: edge('b', 'b'), source: 'b', target: 'b', value: 1
  26. },
  27. });
  28. });
  29. });
  30. });