diff --git a/html/admin/js/graphViewer/graphViewer.js b/html/admin/js/graphViewer/graphViewer.js index d64ad976f0..570d6c617d 100644 --- a/html/admin/js/graphViewer/graphViewer.js +++ b/html/admin/js/graphViewer/graphViewer.js @@ -58,6 +58,7 @@ function GraphViewer(svg, width, height, adapterConfig, config) { nodeShaper, edgeShaper, layouter, + zoomManager, graphContainer, nodeContainer, edgeContainer, @@ -95,7 +96,7 @@ function GraphViewer(svg, width, height, adapterConfig, config) { parseZoomConfig = function(config) { if (config) { - self.zoomManager = new ZoomManager(width, height, svg, + zoomManager = new ZoomManager(width, height, svg, graphContainer, nodeShaper, edgeShaper, {}, nodeLimitCallBack); } @@ -162,14 +163,14 @@ function GraphViewer(svg, width, height, adapterConfig, config) { parseConfig(config || {}); - self.start = function() { + this.start = function() { layouter.stop(); nodeShaper.drawNodes(nodes); edgeShaper.drawEdges(edges); layouter.start(); }; - self.loadGraph = function(nodeId, callback) { + this.loadGraph = function(nodeId, callback) { // loadNode // loadInitialNode adapter.loadInitialNode(nodeId, function (node) { @@ -185,7 +186,7 @@ function GraphViewer(svg, width, height, adapterConfig, config) { }); }; - self.loadGraphWithAttributeValue = function(attribute, value, callback) { + this.loadGraphWithAttributeValue = function(attribute, value, callback) { // loadNodeFromTreeByAttributeValue adapter.loadInitialNodeByAttributeValue(attribute, value, function (node) { if (node.errorCode) { @@ -200,7 +201,7 @@ function GraphViewer(svg, width, height, adapterConfig, config) { }); }; - self.dispatcherConfig = { + this.dispatcherConfig = { expand: { edges: edges, nodes: nodes, @@ -220,8 +221,9 @@ function GraphViewer(svg, width, height, adapterConfig, config) { adapter: adapter } }; - self.adapter = adapter; - self.nodeShaper = nodeShaper; - self.edgeShaper = edgeShaper; - self.layouter = layouter; -} \ No newline at end of file + this.adapter = adapter; + this.nodeShaper = nodeShaper; + this.edgeShaper = edgeShaper; + this.layouter = layouter; + this.zoomManager = zoomManager; +} diff --git a/html/admin/js/graphViewer/jasmine_test/helper/uiMatchers.js b/html/admin/js/graphViewer/jasmine_test/helper/uiMatchers.js index e88266deac..efedbc36a1 100644 --- a/html/admin/js/graphViewer/jasmine_test/helper/uiMatchers.js +++ b/html/admin/js/graphViewer/jasmine_test/helper/uiMatchers.js @@ -47,7 +47,7 @@ var uiMatchers = uiMatchers || {}; toBeOfClass: function(name) { var el = $(this.actual); this.message = function() { - return "Expected " + el.className + " to contain " + name; + return "Expected \"" + el.attr("class") + "\" to contain " + name; }; return el.hasClass(name); }, diff --git a/html/admin/js/graphViewer/jasmine_test/specGraphViewer/graphViewerUISpec.js b/html/admin/js/graphViewer/jasmine_test/specGraphViewer/graphViewerUISpec.js index ed9cf867d9..229ea61c6c 100644 --- a/html/admin/js/graphViewer/jasmine_test/specGraphViewer/graphViewerUISpec.js +++ b/html/admin/js/graphViewer/jasmine_test/specGraphViewer/graphViewerUISpec.js @@ -60,6 +60,12 @@ r.getCollections = function(callback) { callback(["nodes"], ["edges"]); }; + r.getGraphs = function(callback) { + callback(["graph"]); + }; + r.getAttributeExamples = function(callback) { + callback(["name", "type"]); + }; r.getPrioList = function() { return []; }; @@ -67,9 +73,13 @@ }; //Mock for ZoomManager if (window.ZoomManager === undefined) { - window.ZoomManager = {}; + window.ZoomManager = { + getMinimalZoomFactor: function() { + return 0.16; + } + }; } - spyOn(window, "ZoomManager"); + spyOn(window, "ZoomManager").andCallThrough(); div = document.createElement("div"); div.id = "contentDiv"; div.style.width = "200px"; @@ -187,12 +197,13 @@ expect($(barSelector + " #loadnode").length).toEqual(1); expect(attrfield).toBeTag("input"); expect(attrfield.type).toEqual("text"); - expect(attrfield.className).toEqual("input-mini searchByAttribute"); - expect(attrfield.placeholder).toEqual("key"); + expect(attrfield).toBeOfClass("input"); + expect(attrfield.placeholder).toEqual("Attribute"); expect(valfield).toBeTag("input"); expect(valfield.type).toEqual("text"); - expect(valfield.className).toEqual("searchInput"); - expect(valfield.placeholder).toEqual("value"); + expect(valfield).toBeOfClass("searchInput"); + expect(valfield).toBeOfClass("input-xlarge"); + expect(valfield.placeholder).toEqual("Value"); expect(btn).toBeTag("img"); expect(btn.className).toEqual("searchSubmit"); }); @@ -261,7 +272,8 @@ it('should have the same layout as the web interface', function() { var header = div.children[0], transHeader = header.firstChild, - searchField = transHeader.children[0], + transPH = transHeader.children[0], + searchField = transPH.children[0], content = div.children[1]; expect(header).toBeTag("ul"); @@ -269,15 +281,20 @@ expect(header.className).toEqual("thumbnails2"); expect(transHeader).toBeTag("div"); expect(transHeader.id).toEqual("transparentHeader"); - + + expect(transPH).toBeTag("div"); + expect(transPH).toBeOfClass("pull-left"); + expect(transPH.id).toEqual("transparentPlaceholder"); expect(searchField).toBeTag("div"); - expect(searchField.id).toEqual("transparentPlaceholder"); - expect(searchField.className).toEqual("pull-left"); + expect(searchField).toBeOfClass("pull-left"); + expect(searchField).toBeOfClass("input-append"); + expect(searchField).toBeOfClass("searchByAttribute"); + expect(searchField.children[0]).toBeTag("input"); expect(searchField.children[0].id).toEqual("attribute"); - expect(searchField.children[1]).toBeTag("span"); - expect(searchField.children[1].textContent).toEqual("=="); - expect(searchField.children[2].id).toEqual("value"); - expect(searchField.children[3].id).toEqual("loadnode"); + expect(transPH.children[1]).toBeTag("span"); + expect(transPH.children[1].textContent).toEqual("=="); + expect(transPH.children[2].id).toEqual("value"); + expect(transPH.children[3].id).toEqual("loadnode"); }); }); @@ -668,4 +685,4 @@ }); -}()); \ No newline at end of file +}());