UNPKG

1.33 kBJavaScriptView Raw
1var IperEdge, IperElement, IperGraph, IperNode, data, graph, iper;
2
3iper = require('../index');
4
5IperEdge = iper.IperEdge;
6
7IperElement = iper.IperElement;
8
9IperGraph = iper.IperGraph;
10
11IperNode = iper.IperNode;
12
13data = [1, 2, 3];
14
15graph = new IperGraph();
16
17describe('IperNode', function() {
18 describe('inheritance', function() {
19 return it('is an IperElement', function() {
20 var node;
21 node = new IperNode();
22 return node.should.be.instanceOf(IperElement);
23 });
24 });
25 describe('constructor', function() {
26 it('has signature (graph)', function() {
27 var node;
28 node = new IperNode(graph);
29 return node.should.be.instanceOf(IperNode);
30 });
31 return it('has signature (graph, data)', function() {
32 var node;
33 node = new IperNode(graph, data);
34 return node.should.be.instanceOf(IperNode);
35 });
36 });
37 return describe('methods', function() {
38 return describe('#remove()', function() {
39 return it('removes the node from its graph', function() {
40 var node, nodeId;
41 node = new IperNode(graph);
42 nodeId = node.id;
43 node.remove();
44 (function() {
45 return graph.getEdge(nodeId);
46 }).should.throwError();
47 return node.should.exists;
48 });
49 });
50 });
51});