Skip to content

Commit

Permalink
Make setGraph chainable.
Browse files Browse the repository at this point in the history
  • Loading branch information
cpettitt committed Sep 24, 2014
1 parent 3bf0a4d commit 051eecc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/base-graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ BaseGraph.prototype.setGraph = function(label) {
} else {
delete this._graphLabel;
}
return this;
};

BaseGraph.prototype.updateGraph = function(fn) {
Expand Down
10 changes: 10 additions & 0 deletions test/base-graph-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ exports.tests = function(GraphConstructor) {
g.setGraph();
expect(g.getGraph()).to.be.undefined;
});

it("is chainable", function() {
var g2 = g.setGraph("foo");
expect(g).to.equal(g2);
});
});

describe("updateGraph", function() {
Expand All @@ -48,6 +53,11 @@ exports.tests = function(GraphConstructor) {
g.updateGraph(function() {});
expect(g.getGraph()).to.be.undefined;
});

it("is chainable", function() {
var g2 = g.updateGraph(function(old) { return old + "-new"; });
expect(g).to.equal(g2);
});
});

describe("hasNode", function() {
Expand Down

0 comments on commit 051eecc

Please sign in to comment.