Commit e0dd40f9 authored by Jérome Perrin's avatar Jérome Perrin Committed by Ioannis Papagiannopoulos

Graph editor: test for removing a node

parent e56a82f6
...@@ -385,18 +385,48 @@ ...@@ -385,18 +385,48 @@
function runTest() { function runTest() {
return jsplumb_gadget.getContent().then(function () { return jsplumb_gadget.getContent().then(function () {
$("div[title='Node 1']").simulate("dblclick"); equal(1, $("div[title='Node 1']").length, "node 1 is visible");
equal(1, $("._jsPlumb_connector").length, "there is one connection");
// XXX popup not displayed
$("input[value='Delete']").click(); // click on node 1 to see display the popup
}) $("div[title='Node 1']").simulate("dblclick");
.then(function () {
return jsplumb_gadget.getContent(); // Promises that handle the dialog actions are not available
}) // immediately after clicking.
.then(function (content) { var promise = RSVP.Promise( function (resolve) {
var graph = JSON.parse(content).graph; var waitForDialogAndDelete = function() {
equal(1, Object.keys(graph.node).length); if (! jsplumb_gadget.props.dialog_promise ) {
// Dialog not ready. Let's retry later.
// XXX this condition is actually incorrect. We need to wait
// for the event listener to have been registered for the
// dialog buttons. This setTimeout is good enough for now.
return setTimeout(waitForDialogAndDelete, 1000);
}
$("input[value='Delete']").click();
// resolve our test promise once the dialog handling promise is
// finished.
jsplumb_gadget.props.dialog_promise.then(resolve);
};
waitForDialogAndDelete();
} );
return promise.then( function () {
return jsplumb_gadget.getContent().then(function (content) {
var graph = JSON.parse(content).graph;
equal(1, Object.keys(graph.node).length,
"node is removed from data");
equal(0, Object.keys(graph.edge).length,
"edge referencing this node is also removed");
equal(0, $("div[title='Node 1']").length,
"DOM element for node is removed");
equal(0, $("._jsPlumb_connector").length,
"DOM element for edge is removed");
});
}); });
});
} }
g.declareGadget("./index.html", { g.declareGadget("./index.html", {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment