UNPKG

1.17 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 arg and adds it to attributes', () => {
9 graph.uniform.should.be.eql(k)
10 })
11
12 it('requires uniform to be an integer equal or grater than 2', () => {
13 ;(() => {
14 Graph({ uniform: 7.5 })
15 }).should.throw()
16
17 ;(() => {
18 Graph({ uniform: -2 })
19 }).should.throw()
20
21 ;(() => {
22 Graph({ uniform: 1 })
23 }).should.throw()
24 })
25 })
26
27 describe('addEdge()', () => {
28 it('cannot create edges with cardinality other than k', () => {
29 const nodeId1 = graph.addNode()
30 const nodeId2 = graph.addNode()
31 const nodeId3 = graph.addNode()
32
33 const nodeIds = [nodeId1, nodeId2, nodeId3]
34
35 ;(() => {
36 graph.addEdge(nodeIds)
37 }).should.throw()
38 })
39 })
40
41 describe('getRank()', () => {
42 it('returns the value of uniform, even if the graph is still empty', () => {
43 const rank = 10
44
45 const graph = new Graph({ uniform: rank })
46
47 rank.should.be.equal(graph.getRank())
48 })
49 })
50})