mirror of
https://github.com/trekhleb/javascript-algorithms.git
synced 2026-03-13 08:51:02 +08:00
Make sure toString is called on edge key when calling edge.toString()
This commit is contained in:
committed by
Oleksii Trekhleb
parent
0d956c2253
commit
e743df6fab
@@ -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');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user