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
committed by Oleksii Trekhleb
parent 0d956c2253
commit e743df6fab

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');
});
});