Make sure toString is called on edge key when calling edge.toString()

This commit is contained in:
Alex Rock Ancelet 2019-12-18 08:55:29 +01:00
parent 9465d0e4c4
commit 6045f67230
No known key found for this signature in database
GPG Key ID: 4A7B1CB0178A73F5

View File

@ -51,4 +51,15 @@ describe('GraphEdge', () => {
expect(edge.getKey()).toEqual('custom_key');
expect(edge.toString()).toEqual('custom_key');
});
it('should execute toString on key when calling toString on edge', () => {
const customKey = {
toString() { return 'custom_key'; },
};
const edge = new GraphEdge(new GraphVertex('A'), new GraphVertex('B'), 0, customKey);
expect(edge.getKey()).toEqual(customKey);
expect(edge.toString()).toEqual('custom_key');
});
});