UNPKG

1.22 kBJavaScriptView Raw
1describe('getIncidentEdgeIds', () => {
2 const getIncidentEdgeIds = require('./utils').getIncidentEdgeIds
3
4 const graph1 = require('./examples/graphs/graph1.json')
5 const graph2 = require('./examples/graphs/graph2.json')
6 const isolatedNode = require('./examples/graphs/isolatedNode.json')
7
8 it('returns an empty array if there is no incident edge', () => {
9 const nodeId = 'isolated'
10 const edges = isolatedNode.edges
11
12 getIncidentEdgeIds(edges, nodeId).should.be.eql([])
13 })
14
15 it('returns incident edges', () => {
16 var result
17 var nodeId
18 var edges
19
20 nodeId = '1'
21 edges = graph1.edges
22 result = ['0']
23 getIncidentEdgeIds(edges, nodeId).should.be.eql(result)
24
25 nodeId = '2'
26 edges = graph1.edges
27 result = ['0']
28 getIncidentEdgeIds(edges, nodeId).should.be.eql(result)
29
30 nodeId = 'a'
31 edges = graph2.edges
32 result = ['0', '1', '2']
33 getIncidentEdgeIds(edges, nodeId).should.be.eql(result)
34
35 nodeId = 'b'
36 edges = graph2.edges
37 result = ['0', '1', '2']
38 getIncidentEdgeIds(edges, nodeId).should.be.eql(result)
39
40 nodeId = 'c'
41 edges = graph2.edges
42 result = ['0', '1', '2']
43 getIncidentEdgeIds(edges, nodeId).should.be.eql(result)
44 })
45})