1
0
Fork 0

GraphViewer: Adapted Tests for EdgeShaper, this will be moved to the same interface as NodeShaper

This commit is contained in:
Michael Hackstein 2013-04-02 08:58:27 +02:00
parent 8d4b9b557a
commit 6c03247b2b
1 changed files with 55 additions and 7 deletions

View File

@ -144,8 +144,11 @@
},
shaper = new EdgeShaper(d3.select("svg"));
shaper.on("click", click);
shaper.drawEdges(edges);
shaper.changeTo({
actions: {
click: click
}
});
helper.simulateMouseEvent("click", "1-2");
helper.simulateMouseEvent("click", "3-4");
@ -180,7 +183,11 @@
it('should be able to add a click event to existing edges', function() {
expect($("svg .link").length).toEqual(3);
shaper.on("click", click);
shaper.changeTo({
actions: {
click: click
}
});
helper.simulateMouseEvent("click", "1-2");
helper.simulateMouseEvent("click", "3-4");
expect(clicked[1]).toBeTruthy();
@ -190,7 +197,11 @@
it('should add a click event to newly arriving edges', function() {
shaper.on("click", click);
shaper.changeTo({
actions: {
click: click
}
});
edges.push({_id: 4, source: nodes[3], target: nodes[0]});
edges.push({_id: 5, source: nodes[0], target: nodes[2]});
shaper.drawEdges(edges);
@ -206,11 +217,23 @@
});
it('should display each edge exactly once if an event is added', function() {
shaper.on("click", function() {return 0;});
shaper.changeTo({
actions: {
click: function() {return 0;}
}
});
expect($("svg .link").length).toEqual(3);
shaper.on("click", function() {return 1;});
shaper.changeTo({
actions: {
click: function() {return 0;}
}
});
expect($("svg .link").length).toEqual(3);
shaper.on("click", function() {return 2;});
shaper.changeTo({
actions: {
click: function() {return 0;}
}
});
expect($("svg .link").length).toEqual(3);
});
});
@ -289,6 +312,31 @@
expect($("#4-1 text")[0].textContent).toEqual("correct");
});
it('should be able to switch to another label', function() {
var nodes = [{"_id": 1}, {"_id": 2}],
edges = [
{
"source": nodes[0],
"target": nodes[1],
"label": "old"
},
{
"source": nodes[1],
"target": nodes[0],
"new": "new"
}
];
shaper.drawEdges(edges);
expect($("#1-2")[0].textContent).toEqual("old");
expect($("#2-1")[0].textContent).toEqual("");
shaper.changeTo({label: "new"});
expect($("#1-2")[0].textContent).toEqual("");
expect($("#2-1")[0].textContent).toEqual("new");
});
});
describe('using a function for labels', function() {