Skip to content

Commit e743df6

Browse files
Pierstovaltrekhleb
authored andcommitted
Make sure toString is called on edge key when calling edge.toString()
1 parent 0d956c2 commit e743df6

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/data-structures/graph/__test__/GraphEdge.test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,15 @@ describe('GraphEdge', () => {
5151
expect(edge.getKey()).toEqual('custom_key');
5252
expect(edge.toString()).toEqual('custom_key');
5353
});
54+
55+
it('should execute toString on key when calling toString on edge', () => {
56+
const customKey = {
57+
toString() { return 'custom_key'; },
58+
};
59+
60+
const edge = new GraphEdge(new GraphVertex('A'), new GraphVertex('B'), 0, customKey);
61+
62+
expect(edge.getKey()).toEqual(customKey);
63+
expect(edge.toString()).toEqual('custom_key');
64+
});
5465
});

0 commit comments

Comments
 (0)