Skip to content

Commit

Permalink
Fix bug where undefined name was stringified
Browse files Browse the repository at this point in the history
  • Loading branch information
cpettitt committed Oct 16, 2014
1 parent b378221 commit d5ccf0a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ Graph.prototype.setEdge = function(v, w, value, name) {

v = String(v);
w = String(w);
if (arguments.length > 3) {
if (!_.isUndefined(name)) {
name = String(name);
}

Expand Down
10 changes: 9 additions & 1 deletion test/graph-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -528,11 +528,19 @@ describe("Graph", function() {
expect(g.edge("a", "b", "name")).to.equal("value");
});

it("uses the stringified form of the id", function() {
it("uses the stringified form of the id #1", function() {
g.setEdge(1, 2, "foo");
expect(g.edges()).eqls([{ v: "1", w: "2" }]);
expect(g.edge("1", "2")).to.equal("foo");
expect(g.edge(1, 2)).to.equal("foo");
});

it("uses the stringified form of the id #2", function() {
g = new Graph({ multigraph: true });
g.setEdge(1, 2, "foo", undefined);
expect(g.edges()).eqls([{ v: "1", w: "2" }]);
expect(g.edge("1", "2")).to.equal("foo");
expect(g.edge(1, 2)).to.equal("foo");
});

it("uses the stringified form of the id with a name", function() {
Expand Down

0 comments on commit d5ccf0a

Please sign in to comment.