Hi all,
Is it possible to simulate input event in angular unit test?
I understand that Robot.js can be used for simulating input event when we run whole application in browser.
However, does Robot.js still work for unit test?
Thanks!
Hi all,
Is it possible to simulate input event in angular unit test?
I understand that Robot.js can be used for simulating input event when we run whole application in browser.
However, does Robot.js still work for unit test?
Thanks!
What unit tests do you want to run?
You can certainly do a lot programmatically, manipulating Nodes and Links and Groups. Most of our regression tests are written this way.
We would like test several input event handler, such as Changedselection, LinkDrawn, etc.
Could you please point me to some regression test example? That will be very helpful.
Thanks!
// initialize the Diagram normally
var diagram = ...;
// add nodes and links
diagram.startTransaction();
. . .
diagram.commitTransaction();
// setup the test
var robot = new Robot(diagram); // this can be reused for multiple tests involving this Diagram
var listener = function(e) {
assert(e.diagram.selection.count === 1, "should be one selected Part in ChangedSelection event");
};
// do the test
diagram.clearSelection();
assert(diagram.selection.count === 0);
diagram.addDiagramListener("ChangedSelection", listener);
var pt = new go.Point(12, 12); // or wherever a Node should be given the above initialization
assert(diagram.findPartAt(pt, true) === diagram.findNodeForKey(...));
robot.mouseDown(pt.x, pt.y, 0);
robot.mouseUp(pt.x, pt.y, 200);
diagram.removeDiagramListener("ChangedSelection", listener);