1
0
Fork 0

GraphViewer: Added Tests for communication between Adapter and NodeReducer

This commit is contained in:
Michael Hackstein 2013-05-17 15:26:28 +02:00
parent 17cb716bdc
commit 4161ff662c
2 changed files with 34 additions and 1 deletions

View File

@ -613,7 +613,11 @@
beforeEach(function() {
runs(function() {
var self = this;
this.fakeReducerRequest = function() {};
spyOn(window, "NodeReducer").andCallFake(function(v, e) {
this.getCommunity = self.fakeReducerRequest;
});
spyOn($, "ajax").andCallFake(function(request) {
if (spyHook !== undefined) {
if(!spyHook(request)) {
@ -840,6 +844,22 @@
});
});
it('should trigger the reducer if too many nodes are added', function() {
runs(function() {
adapter.setNodeLimit(6);
spyOn(this, "fakeReducerRequest");
adapter.loadNodeFromTreeById(c1, checkCallbackFunction);
expect(this.fakeReducerRequest).toHaveBeenCalledWith(6, c1);
});
});
it('should not trigger the reducer if the limit is set large enough', function() {
spyOn(this, "fakeReducerRequest");
adapter.setNodeLimit(10);
expect(this.fakeReducerRequest).not.toHaveBeenCalled();
});
describe('that has loaded several queries', function() {
var c8, c9, e2_8;

View File

@ -139,6 +139,19 @@
expect(com).toContainNodes([5, 6, 7]);
});
it('should also take the best community if no focus is given', function() {
helper.insertSimpleNodes(nodes, [0, 1, 2, 3, 4, 5, 6, 7]);
helper.insertClique(nodes, edges, [0, 1, 2]);
edges.push(helper.createSimpleEdge(nodes, 3, 2));
edges.push(helper.createSimpleEdge(nodes, 3, 4));
edges.push(helper.createSimpleEdge(nodes, 4, 5));
edges.push(helper.createSimpleEdge(nodes, 5, 6));
edges.push(helper.createSimpleEdge(nodes, 5, 7));
var com = reducer.getCommunity(6);
expect(com).toContainNodes([0, 1, 2]);
});
});
});