mirror of
https://github.moeyy.xyz/https://github.com/trekhleb/javascript-algorithms.git
synced 2024-09-20 07:43:04 +08:00
Make sure toString is called on edge key when calling edge.toString()
This commit is contained in:
parent
9465d0e4c4
commit
6045f67230
@ -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');
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user