UNPKG

1.09 kBJavaScriptView Raw
1describe('uniform Graph', () => {
2 const Graph = require('iper').Graph
3 const k = 2
4
5 const graph = new Graph({ uniform: k })
6
7 describe('constructor', () => {
8 it('accepts uniform flag and adds it to attributes', () => {
9 graph.uniform.should.be.eql(k)
10 })
11
12 it('required uniform to be equal or grater than 2', () => {
13 ;(() => {
14 Graph({ uniform: -2 })
15 }).should.throw()
16
17 ;(() => {
18 Graph({ uniform: 1 })
19 }).should.throw()
20 })
21 })
22
23 describe('addEdge()', () => {
24 it('cannot create edges with cardinality other than k', () => {
25 const nodeId1 = graph.addNode()
26 const nodeId2 = graph.addNode()
27 const nodeId3 = graph.addNode()
28
29 const nodeIds = [nodeId1, nodeId2, nodeId3]
30
31 ;(() => {
32 graph.addEdge(nodeIds)
33 }).should.throw()
34 })
35 })
36
37 describe('getRank()', () => {
38 it('returns the value of uniform, even if the graph is still empty', () => {
39 const rank = 10
40
41 const graph = new Graph({ uniform: rank })
42
43 rank.should.be.equal(graph.getRank())
44 })
45 })
46})