From 9a42ea07e860da794300d7d8d9660508fbd2f12d Mon Sep 17 00:00:00 2001 From: Piotr Gawron <piotr.gawron@uni.lu> Date: Fri, 25 Aug 2017 19:29:17 +0200 Subject: [PATCH] fixing spelling typos --- frontend-js/src/main/js/Configuration.js | 16 +- frontend-js/src/main/js/Functions.js | 8 +- frontend-js/src/main/js/GuiConnector.js | 4 +- .../src/main/js/ObjectWithListeners.js | 20 +- .../src/main/js/gui/AbstractGuiElement.js | 8 +- frontend-js/src/main/js/gui/Legend.js | 4 +- frontend-js/src/main/js/gui/LoginDialog.js | 4 +- frontend-js/src/main/js/gui/OverviewDialog.js | 22 +- frontend-js/src/main/js/gui/Panel.js | 2 +- .../main/js/gui/PanelControlElementType.js | 6 +- .../main/js/gui/leftPanel/AbstractDbPanel.js | 2 +- .../main/js/gui/leftPanel/ChemicalPanel.js | 29 +- .../src/main/js/gui/leftPanel/GuiUtils.js | 2 +- .../src/main/js/gui/leftPanel/LeftPanel.js | 6 +- .../js/gui/leftPanel/PublicationListDialog.js | 2 +- .../src/main/js/gui/leftPanel/SearchPanel.js | 6 +- .../src/main/js/gui/topMenu/TopMenu.js | 2 +- .../src/main/js/map/AbstractCustomMap.js | 36 +- frontend-js/src/main/js/map/CustomMap.js | 12 +- frontend-js/src/main/js/map/Submap.js | 7 +- frontend-js/src/main/js/map/data/Alias.js | 4 +- frontend-js/src/main/js/map/data/BioEntity.js | 2 +- frontend-js/src/main/js/map/data/Chemical.js | 10 +- .../src/main/js/map/data/IdentifiedElement.js | 2 +- .../src/main/js/map/data/LayoutAlias.js | 4 +- .../src/main/js/map/data/LayoutData.js | 2 +- .../src/main/js/map/data/LayoutReaction.js | 2 +- frontend-js/src/main/js/map/data/Reaction.js | 2 +- .../src/main/js/map/marker/AliasMarker.js | 4 +- .../src/main/js/map/marker/ReactionMarker.js | 4 +- .../src/main/js/map/surface/AliasSurface.js | 10 +- .../main/js/map/surface/ReactionSurface.js | 6 +- .../main/js/map/window/AbstractInfoWindow.js | 4 +- frontend-js/src/main/js/minerva.js | 4 +- .../src/test/js/ServerConnector-mock.js | 8 +- .../src/test/js/ServerConnector-test.js | 2 +- frontend-js/src/test/js/google-map-mock.js | 4 +- .../src/test/js/gui/CommentDialog-test.js | 2 +- .../src/test/js/gui/LoginDialog-test.js | 2 +- .../js/gui/leftPanel/AbstractPanel-test.js | 2 +- .../js/gui/leftPanel/ChemicalPanel-test.js | 6 +- .../test/js/gui/leftPanel/DrugPanel-test.js | 6 +- .../gui/leftPanel/GenericSearchPanel-test.js | 6 +- .../test/js/gui/leftPanel/GuiUtils-test.js | 6 +- .../test/js/gui/leftPanel/MiRnaPanel-test.js | 6 +- .../leftPanel/PublicationListDialog-test.js | 64 +- .../test/js/gui/leftPanel/SubmapPanel-test.js | 2 +- frontend-js/src/test/js/helper.js | 40 +- .../src/test/js/map/AbstractCustomMap-test.js | 40 +- frontend-js/src/test/js/map/CustomMap-test.js | 1684 ++++++++--------- .../src/test/js/map/CustomMapOptions-test.js | 73 +- frontend-js/src/test/js/map/Submap-test.js | 2 +- .../src/test/js/map/data/Alias-test.js | 183 +- .../src/test/js/map/data/GeneVariant-test.js | 2 +- .../js/map/data/IdentifiedElement-test.js | 290 +-- .../src/test/js/map/data/LayoutAlias-test.js | 2 +- .../src/test/js/map/data/LayoutData-test.js | 4 +- .../src/test/js/map/data/PointData-test.js | 8 +- .../test/js/map/data/ReferenceGenome-test.js | 63 +- .../data/ReferenceGenomeGeneMapping-test.js | 2 +- .../test/js/map/overlay/UserDbOverlay-test.js | 4 +- .../js/map/surface/ReactionSurface-test.js | 6 +- frontend-js/src/test/js/minerva-test.js | 9 +- frontend-js/src/test/js/mocha-config.js | 2 +- 64 files changed, 1398 insertions(+), 1390 deletions(-) diff --git a/frontend-js/src/main/js/Configuration.js b/frontend-js/src/main/js/Configuration.js index dbd30aead7..d5d7899ec4 100644 --- a/frontend-js/src/main/js/Configuration.js +++ b/frontend-js/src/main/js/Configuration.js @@ -23,17 +23,17 @@ function Configuration(json) { } var legendFiles = []; - if (self.getOption("LENGEND_FILE_1") !== undefined) { - legendFiles.push(self.getOption("LENGEND_FILE_1")); + if (self.getOption("LEGEND_FILE_1") !== undefined) { + legendFiles.push(self.getOption("LEGEND_FILE_1")); } - if (self.getOption("LENGEND_FILE_2") !== undefined) { - legendFiles.push(self.getOption("LENGEND_FILE_2")); + if (self.getOption("LEGEND_FILE_2") !== undefined) { + legendFiles.push(self.getOption("LEGEND_FILE_2")); } - if (self.getOption("LENGEND_FILE_3") !== undefined) { - legendFiles.push(self.getOption("LENGEND_FILE_3")); + if (self.getOption("LEGEND_FILE_3") !== undefined) { + legendFiles.push(self.getOption("LEGEND_FILE_3")); } - if (self.getOption("LENGEND_FILE_4") !== undefined) { - legendFiles.push(self.getOption("LENGEND_FILE_4")); + if (self.getOption("LEGEND_FILE_4") !== undefined) { + legendFiles.push(self.getOption("LEGEND_FILE_4")); } self.setOption(ConfigurationType.LEGEND_FILES, legendFiles); diff --git a/frontend-js/src/main/js/Functions.js b/frontend-js/src/main/js/Functions.js index c2594abb15..f26951632a 100644 --- a/frontend-js/src/main/js/Functions.js +++ b/frontend-js/src/main/js/Functions.js @@ -32,8 +32,8 @@ Functions.radiansToDegrees = function(rad) { Functions.intToColorString = function(value) { /* jslint bitwise: true */ - var timmedValue = (value & 0xFFFFFF); - var colorStr = timmedValue.toString(16); + var trimmedValue = (value & 0xFFFFFF); + var colorStr = trimmedValue.toString(16); while (colorStr.length < 6) { colorStr = "0" + colorStr; } @@ -103,8 +103,8 @@ Functions.pointInsidePolygon = function(point, polygon) { }; /** - * In a browser variable we store inforamtion about browser user is currently - * using. Right now only IE is suppoerted. + * In a browser variable we store information about browser user is currently + * using. Right now only IE is supported. */ Functions.browser = { init : function() { diff --git a/frontend-js/src/main/js/GuiConnector.js b/frontend-js/src/main/js/GuiConnector.js index 1f68d4408c..cc14c32533 100644 --- a/frontend-js/src/main/js/GuiConnector.js +++ b/frontend-js/src/main/js/GuiConnector.js @@ -17,6 +17,8 @@ function GuiConnector() { this.xPos = 0; // coordinate of the mouse in a browser. this.yPos = 0; + + this.getParams = []; } function returnThisOrSingleton(object) { @@ -43,7 +45,7 @@ GuiConnector.prototype.init = function () { var isIE = /* @cc_on!@ */false || !!document.documentMode; if (isIE) { - alert("This webpage works well with Chrome, Firefox and Safari."); + alert("This web page works well with Chrome, Firefox and Safari."); } // bootstrap tab initialization $("ul.nav-tabs a").click(function (e) { diff --git a/frontend-js/src/main/js/ObjectWithListeners.js b/frontend-js/src/main/js/ObjectWithListeners.js index bcc2e9759c..485d77c41b 100644 --- a/frontend-js/src/main/js/ObjectWithListeners.js +++ b/frontend-js/src/main/js/ObjectWithListeners.js @@ -19,7 +19,7 @@ function ObjectWithListeners() { * @param type * string defining type of the listener * @param fun - * function that should be thrown when type event occures + * function that should be thrown when type event occurs */ ObjectWithListeners.prototype.addListener = function(type, fun) { if (this._validListeners[type] === undefined) { @@ -58,7 +58,7 @@ ObjectWithListeners.prototype.addPropertyChangeListener = function(name, fun) { * Register new type of listener. * * @param type - * string identifing new type of listener + * string identifying new type of listener */ ObjectWithListeners.prototype.registerListenerType = function(type) { if (this._validListeners[type] !== undefined) { @@ -71,7 +71,7 @@ ObjectWithListeners.prototype.registerListenerType = function(type) { * Register new property for listening. * * @param name - * string identifing proeprty + * string identifying property */ ObjectWithListeners.prototype.registerPropertyType = function(name) { if (this._validPropertyListeners[name] !== undefined) { @@ -86,7 +86,7 @@ ObjectWithListeners.prototype.registerPropertyType = function(name) { * @param type * type of the listener * @param fun - * function that was call when event occred that should be removed + * function that was call when event occurred that should be removed */ ObjectWithListeners.prototype.removeListener = function(type, fun) { if (this._validListeners[type] === undefined) { @@ -113,7 +113,7 @@ ObjectWithListeners.prototype.removeListener = function(type, fun) { * @param name * name of the property * @param fun - * function that was call when event occred that should be removed + * function that was call when event occurred that should be removed */ ObjectWithListeners.prototype.removePropertyListener = function(name, fun) { if (this._validPropertyListeners[name] === undefined) { @@ -171,12 +171,12 @@ ObjectWithListeners.prototype.getListeners = function(type) { * * @param propertyName * name of the property - * @param oldval + * @param oldValue * old value of the property - * @param newval + * @param newValue * new value of the property */ -ObjectWithListeners.prototype.firePropertyChangeListener = function(propertyName, oldval, newval) { +ObjectWithListeners.prototype.firePropertyChangeListener = function(propertyName, oldValue, newValue) { var self = this; if (this._validPropertyListeners[propertyName] === undefined) { throw new Error("Unknown property type: " + propertyName); @@ -188,8 +188,8 @@ ObjectWithListeners.prototype.firePropertyChangeListener = function(propertyName var e = { propertyName : propertyName, object : self, - oldVal : oldval, - newVal : newval, + oldVal : oldValue, + newVal : newValue, }; promises.push(listenerList[i](e)); } diff --git a/frontend-js/src/main/js/gui/AbstractGuiElement.js b/frontend-js/src/main/js/gui/AbstractGuiElement.js index 6f52b63cd0..e83a90d4a2 100644 --- a/frontend-js/src/main/js/gui/AbstractGuiElement.js +++ b/frontend-js/src/main/js/gui/AbstractGuiElement.js @@ -59,10 +59,10 @@ AbstractGuiElement.prototype.getProject = function() { AbstractGuiElement.prototype.setControlElement = function(type, element) { if (type === null || type === undefined) { - throw new Error("Unknown controle element type"); + throw new Error("Unknown control element type"); } if (PanelControlElementType[type] === undefined) { - throw new Error("Unknown controle element type: " + type); + throw new Error("Unknown control element type: " + type); } this._controlElements[type] = element; @@ -70,10 +70,10 @@ AbstractGuiElement.prototype.setControlElement = function(type, element) { AbstractGuiElement.prototype.getControlElement = function(type) { if (type === null || type === undefined) { - throw new Error("Unknown controle element type"); + throw new Error("Unknown control element type"); } if (PanelControlElementType[type] === undefined) { - throw new Error("Unknown controle element type: " + type); + throw new Error("Unknown control element type: " + type); } return this._controlElements[type]; diff --git a/frontend-js/src/main/js/gui/Legend.js b/frontend-js/src/main/js/gui/Legend.js index 53d386109b..860f60cc79 100644 --- a/frontend-js/src/main/js/gui/Legend.js +++ b/frontend-js/src/main/js/gui/Legend.js @@ -34,7 +34,7 @@ Legend.prototype._initializeGui = function() { className : "carousel-indicators", }); legendDiv.appendChild(indicators); - self.setControlElement(PanelControlElementType.LEGEND_INDICATIORS_OL, indicators); + self.setControlElement(PanelControlElementType.LEGEND_INDICATORS_OL, indicators); var slidesDiv = Functions.createElement({ type : "div", @@ -101,7 +101,7 @@ function createLegendSlide(file, index) { Legend.prototype.init = function() { var self = this; var element = self.getElement(); - var menu = self.getControlElement(PanelControlElementType.LEGEND_INDICATIORS_OL); + var menu = self.getControlElement(PanelControlElementType.LEGEND_INDICATORS_OL); var slides = self.getControlElement(PanelControlElementType.LEGEND_SLIDES_DIV); return ServerConnector.getConfigurationParam(ConfigurationType.LEGEND_FILES).then(function(legendFiles) { for (var i = 0; i < legendFiles.length; i++) { diff --git a/frontend-js/src/main/js/gui/LoginDialog.js b/frontend-js/src/main/js/gui/LoginDialog.js index 5de2e0e013..428c527e41 100644 --- a/frontend-js/src/main/js/gui/LoginDialog.js +++ b/frontend-js/src/main/js/gui/LoginDialog.js @@ -19,7 +19,7 @@ function LoginDialog(params) { var loginButton = self.getControlElement(PanelControlElementType.USER_TAB_LOGIN_BUTTON); loginButton.onclick = function() { var login = self.getControlElement(PanelControlElementType.USER_TAB_LOGIN_INPUT_TEXT).value; - var password = self.getControlElement(PanelControlElementType.USER_TAB_PASSOWRD_INPUT_TEXT).value; + var password = self.getControlElement(PanelControlElementType.USER_TAB_PASSWORD_INPUT_TEXT).value; return ServerConnector.login(login, password).then(function() { window.location.reload(false); @@ -87,7 +87,7 @@ LoginDialog.prototype._createLoginTab = function () { style: "width:100%", name: "passwordText" }); - this.setControlElement(PanelControlElementType.USER_TAB_PASSOWRD_INPUT_TEXT, passwordInput); + this.setControlElement(PanelControlElementType.USER_TAB_PASSWORD_INPUT_TEXT, passwordInput); authorizationFormTab.appendChild(self.createTableRow([passwordLabel, passwordInput])); diff --git a/frontend-js/src/main/js/gui/OverviewDialog.js b/frontend-js/src/main/js/gui/OverviewDialog.js index 7237b783f1..648702aa07 100644 --- a/frontend-js/src/main/js/gui/OverviewDialog.js +++ b/frontend-js/src/main/js/gui/OverviewDialog.js @@ -72,7 +72,7 @@ OverviewDialog.prototype.showOverview = function(overviewImageId) { var ratio = 1.0; - // check how image should be resized to fit dialog and resize it manually!!! + // check how image should be re-sized to fit dialog and resize it manually!!! if (width / this.overviewImage.width > height / this.overviewImage.height) { this.overviewImageTag.style.height = height + "px"; ratio = height / this.overviewImage.height; @@ -86,7 +86,7 @@ OverviewDialog.prototype.showOverview = function(overviewImageId) { } // on click event (what should happen when we click on the image) - var onclickevent = function getClickPosition(e) { + var onClickEvent = function getClickPosition(e) { var parentPosition = functions.getPosition(e.currentTarget); var xPosition = e.clientX - parentPosition.x; var yPosition = e.clientY - parentPosition.y; @@ -117,16 +117,16 @@ OverviewDialog.prototype.showOverview = function(overviewImageId) { } }; - this.overviewImageTag.onclick = onclickevent; + this.overviewImageTag.onclick = onClickEvent; - // resize canvas where on mouse over highligh will appear + // resize canvas where on mouse over highlight will appear // in debug mode draw clickable shapes if (map.isDebug()) { canvasDebug.style.display = ""; canvasDebug.width = width; canvasDebug.height = height; - canvasDebug.onclick = onclickevent; + canvasDebug.onclick = onClickEvent; this.drawClickableShapes(canvasDebug, ratio); } @@ -136,9 +136,9 @@ OverviewDialog.prototype.showOverview = function(overviewImageId) { }; // this listener should be called when mouse moves over image, it purpose is - // to change coursor to pointer when mouse enters clickable polygon and back + // to change cursor to pointer when mouse enters clickable polygon and back // to normal when mouse leaves such region - var onmousemove = function getMouseOverPosition(e) { + var onMouseMove = function getMouseOverPosition(e) { var position = functions.getPosition(e.currentTarget); position.x = e.clientX - position.x; position.y = e.clientY - position.y; @@ -170,11 +170,11 @@ OverviewDialog.prototype.showOverview = function(overviewImageId) { } }; - // onmousemove listener should be assigned to canvas (which is on top of the - // image) and overviewimage (just in case something went wrong with resizing + // onMouseMove listener should be assigned to canvas (which is on top of the + // image) and overviewImage (just in case something went wrong with resizing // canvas) - canvasDebug.onmousemove = onmousemove; - this.overviewImageTag.onmousemove = onmousemove; + canvasDebug.onmousemove = onMouseMove; + this.overviewImageTag.onmousemove = onMouseMove; $(self.getElement()).dialog("open"); }; diff --git a/frontend-js/src/main/js/gui/Panel.js b/frontend-js/src/main/js/gui/Panel.js index 4daa6ce710..f609e491b9 100644 --- a/frontend-js/src/main/js/gui/Panel.js +++ b/frontend-js/src/main/js/gui/Panel.js @@ -99,7 +99,7 @@ Panel.prototype.disablePanel = function (message) { self.getElement().insertBefore(hideReasonDiv, searchQueryElement); }; -Panel.prototype.isDisbaled = function () { +Panel.prototype.isDisabled = function () { var self = this; var searchQueryElement = self.getControlElement(PanelControlElementType.SEARCH_DIV); return searchQueryElement.style.visibility === "hidden"; diff --git a/frontend-js/src/main/js/gui/PanelControlElementType.js b/frontend-js/src/main/js/gui/PanelControlElementType.js index f45e90114a..6b2347f96d 100644 --- a/frontend-js/src/main/js/gui/PanelControlElementType.js +++ b/frontend-js/src/main/js/gui/PanelControlElementType.js @@ -20,7 +20,7 @@ var PanelControlElementType = { USER_TAB_LOGIN_DIV : "USER_TAB_LOGIN_DIV", USER_TAB_LOGIN_INPUT_TEXT : "USER_TAB_LOGIN_INPUT_TEXT", - USER_TAB_PASSOWRD_INPUT_TEXT : "USER_TAB_PASSOWRD_INPUT_TEXT", + USER_TAB_PASSWORD_INPUT_TEXT : "USER_TAB_PASSWORD_INPUT_TEXT", USER_TAB_LOGIN_BUTTON : "USER_TAB_LOGIN_BUTTON", USER_TAB_USER_DIV : "USER_TAB_USER_DIV", @@ -36,12 +36,12 @@ var PanelControlElementType = { INFO_DIV : "INFO_DIV", INFO_PROJECT_NAME_TEXT : "INFO_PROJECT_NAME_TEXT", INFO_PROJECT_VERSION_TEXT : "INFO_PROJECT_VERSION_TEXT", - INFO_PROJECT_DESCRIOPTION_TEXT : "INFO_PROJECT_DESCRIOPTION_TEXT", + INFO_PROJECT_DESCRIPTION_TEXT : "INFO_PROJECT_DESCRIPTION_TEXT", INFO_PROJECT_PUBLICATIONS_TEXT : "INFO_PROJECT_PUBLICATIONS_TEXT", INFO_PROJECT_SHOW_PUBLICATIONS_BUTTON : "INFO_PROJECT_SHOW_PUBLICATIONS_BUTTON", INFO_PROJECT_GET_ORIGINAL_FILE_BUTTON : "INFO_PROJECT_GET_ORIGINAL_FILE_BUTTON", - LEGEND_INDICATIORS_OL : "LEGEND_INDICATIORS_OL", + LEGEND_INDICATORS_OL : "LEGEND_INDICATORS_OL", LEGEND_SLIDES_DIV : "LEGEND_SLIDES_DIV", MENU_LEGEND_CHECKBOX : "MENU_LEGEND_CHECKBOX", diff --git a/frontend-js/src/main/js/gui/leftPanel/AbstractDbPanel.js b/frontend-js/src/main/js/gui/leftPanel/AbstractDbPanel.js index 2cb3751678..0e329cb5f5 100644 --- a/frontend-js/src/main/js/gui/leftPanel/AbstractDbPanel.js +++ b/frontend-js/src/main/js/gui/leftPanel/AbstractDbPanel.js @@ -193,7 +193,7 @@ AbstractPanel.prototype.getAutocomplete = function() { }; AbstractPanel.prototype.searchByQuery = function() { - throw new Error("searchByQuery is not implemnted"); + throw new Error("searchByQuery is not implemented"); }; AbstractPanel.prototype.addResultTab = function(query, elements) { diff --git a/frontend-js/src/main/js/gui/leftPanel/ChemicalPanel.js b/frontend-js/src/main/js/gui/leftPanel/ChemicalPanel.js index ef5fafe663..cd600c7da6 100644 --- a/frontend-js/src/main/js/gui/leftPanel/ChemicalPanel.js +++ b/frontend-js/src/main/js/gui/leftPanel/ChemicalPanel.js @@ -29,20 +29,21 @@ ChemicalPanel.prototype = Object.create(AbstractDbPanel.prototype); ChemicalPanel.prototype.constructor = ChemicalPanel; ChemicalPanel.prototype.createPreamble = function (chemical) { - var self = this; - var guiUtils = self.getGuiUtils(); - var result = document.createElement("div"); - if (chemical === undefined || chemical.getName() === undefined) { - result.appendChild(guiUtils.createLabel("NOT FOUND")); - } else { - result.appendChild(guiUtils.createParamLine("Chemical: ", chemical.getName())); - result.appendChild(guiUtils.createParamLine("Description: ", chemical.getDescription())); - result.appendChild(guiUtils.createArrayParamLine("Synonyms: ", chemical.getSynonyms())); - result.appendChild(guiUtils.createParamLine("Direct Evidence: ", chemical.getDirectEvidence())); - result.appendChild(guiUtils.createAnnotations("Direct Evidence Publications: ", chemical.getDirectEvidenceReferences())); - result.appendChild(guiUtils.createAnnotations("Sources: ", chemical.getReferences())); - result.appendChild(guiUtils.createNewLine()); - } + var self = this; + var guiUtils = self.getGuiUtils(); + var result = document.createElement("div"); + if (chemical === undefined || chemical.getName() === undefined) { + result.appendChild(guiUtils.createLabel("NOT FOUND")); + } else { + result.appendChild(guiUtils.createParamLine("Chemical: ", chemical.getName())); + result.appendChild(guiUtils.createParamLine("Description: ", chemical.getDescription())); + result.appendChild(guiUtils.createArrayParamLine("Synonyms: ", chemical.getSynonyms())); + result.appendChild(guiUtils.createParamLine("Direct Evidence: ", chemical.getDirectEvidence())); + result.appendChild(guiUtils + .createAnnotations("Direct Evidence Publications: ", chemical.getDirectEvidenceReferences())); + result.appendChild(guiUtils.createAnnotations("Sources: ", chemical.getReferences())); + result.appendChild(guiUtils.createNewLine()); + } return result; }; diff --git a/frontend-js/src/main/js/gui/leftPanel/GuiUtils.js b/frontend-js/src/main/js/gui/leftPanel/GuiUtils.js index 17bd7acaae..8c6f1b1208 100644 --- a/frontend-js/src/main/js/gui/leftPanel/GuiUtils.js +++ b/frontend-js/src/main/js/gui/leftPanel/GuiUtils.js @@ -367,7 +367,7 @@ GuiUtils.prototype.createAliasElement = function(params) { div.appendChild(self.createParamLine("Abbreviation: ", alias.getAbbreviation())); div.appendChild(self.createParamLine("Formula: ", alias.getFormula())); div.appendChild(self.createArrayParamLine("Former symbols: ", alias.getFormerSymbols())); - div.appendChild(self.createPostTranslationalModifications("Posttranslational modifications: ", alias + div.appendChild(self.createPostTranslationalModifications("PostTranslational modifications: ", alias .getOther('modifications'))); div.appendChild(self.createParamLine("Charge: ", alias.getCharge())); div.appendChild(self.createArrayParamLine("Synonyms: ", alias.getSynonyms())); diff --git a/frontend-js/src/main/js/gui/leftPanel/LeftPanel.js b/frontend-js/src/main/js/gui/leftPanel/LeftPanel.js index 4c8be9c50c..584d8c6626 100644 --- a/frontend-js/src/main/js/gui/leftPanel/LeftPanel.js +++ b/frontend-js/src/main/js/gui/leftPanel/LeftPanel.js @@ -115,9 +115,9 @@ LeftPanel.prototype.getPanelsDefinition = function () { LeftPanel.prototype.hideTab = function (panel) { var self = this; - var panelDeifinitions = self.getPanelsDefinition(); - for (var i = 0; i < panelDeifinitions.length; i++) { - if (panel instanceof panelDeifinitions[i].panelClass) { + var panelDefinitions = self.getPanelsDefinition(); + for (var i = 0; i < panelDefinitions.length; i++) { + if (panel instanceof panelDefinitions[i].panelClass) { var liElement = $("li:has(a[href='#left_panel_tab_" + i + "'])", $(self.getElement()))[0]; if (liElement !== undefined) { liElement.style.display = "none"; diff --git a/frontend-js/src/main/js/gui/leftPanel/PublicationListDialog.js b/frontend-js/src/main/js/gui/leftPanel/PublicationListDialog.js index df3a82c994..7018ef0c9e 100644 --- a/frontend-js/src/main/js/gui/leftPanel/PublicationListDialog.js +++ b/frontend-js/src/main/js/gui/leftPanel/PublicationListDialog.js @@ -162,7 +162,7 @@ PublicationListDialog.prototype.getColumnsDefinition = function () { }, { orderable: false, searchable: false, - name: "elemnts" + name: "elements" }]; }; diff --git a/frontend-js/src/main/js/gui/leftPanel/SearchPanel.js b/frontend-js/src/main/js/gui/leftPanel/SearchPanel.js index 5726cba066..ab9b88c9e2 100644 --- a/frontend-js/src/main/js/gui/leftPanel/SearchPanel.js +++ b/frontend-js/src/main/js/gui/leftPanel/SearchPanel.js @@ -78,9 +78,9 @@ SearchPanel.prototype.getPanelsDefinition = function() { SearchPanel.prototype.hideTab = function(panel) { var self = this; - var panelDeifinitions = self.getPanelsDefinition(); - for (var i = 0; i < panelDeifinitions.length; i++) { - if (panel instanceof panelDeifinitions[i].panelClass) { + var panelDefinitions = self.getPanelsDefinition(); + for (var i = 0; i < panelDefinitions.length; i++) { + if (panel instanceof panelDefinitions[i].panelClass) { var liElement = $("li:has(a[href='#search_panel_tab_" + i + "'])", $(self.getElement()))[0]; if (liElement !== undefined) { liElement.style.display = "none"; diff --git a/frontend-js/src/main/js/gui/topMenu/TopMenu.js b/frontend-js/src/main/js/gui/topMenu/TopMenu.js index 9fa110dd8f..d498e1a9b1 100644 --- a/frontend-js/src/main/js/gui/topMenu/TopMenu.js +++ b/frontend-js/src/main/js/gui/topMenu/TopMenu.js @@ -235,6 +235,6 @@ TopMenu.prototype.toggleLegend = function () { } else { legend.hide(); } -} +}; module.exports = TopMenu; \ No newline at end of file diff --git a/frontend-js/src/main/js/map/AbstractCustomMap.js b/frontend-js/src/main/js/map/AbstractCustomMap.js index cca342d9d8..f843a3db3e 100644 --- a/frontend-js/src/main/js/map/AbstractCustomMap.js +++ b/frontend-js/src/main/js/map/AbstractCustomMap.js @@ -35,7 +35,7 @@ function AbstractCustomMap(model, options) { // layout) this.selectedLayoutOverlays = []; - // following fields are used in conversion between x,y coordinates and latlng + // following fields are used in conversion between x,y coordinates and lat,lng // coordinates this.pixelOrigin_ = new google.maps.Point(this.getTileSize() / 2, this.getTileSize() / 2); this.pixelsPerLonDegree_ = this.getTileSize() / 360; @@ -57,7 +57,7 @@ function AbstractCustomMap(model, options) { // elements in the client this._drawingManager = null; - // this is the polgyon that was selected (clicked) last time on the map + // this is the polygon that was selected (clicked) last time on the map this._selectedArea = null; // markers should be optimized by default, @@ -95,7 +95,7 @@ AbstractCustomMap.prototype.setupLayouts = function () { * Creates general google maps options used in this map. * */ -AbstractCustomMap.prototype.creatMapOptions = function () { +AbstractCustomMap.prototype.createMapOptions = function () { var self = this; var centerPoint = this.getModel().getCenterLatLng(); @@ -224,24 +224,24 @@ AbstractCustomMap.prototype.getMouseLatLng = function () { * @param pixels * x,y distance in pixels * @param zoomLevel - * at which zoom level this pixels where mesaured + * at which zoom level this pixels where measured * */ AbstractCustomMap.prototype.fromPixelsToPoint = function (pixels, zoomLevel) { var zoomScale = this.getPictureSize() / (Math.pow(2, zoomLevel - this.getMinZoom()) * this.getTileSize()); - var pointx = pixels.x * zoomScale; - var pointy = pixels.y * zoomScale; - return new google.maps.Point(pointx, pointy); + var pointX = pixels.x * zoomScale; + var pointY = pixels.y * zoomScale; + return new google.maps.Point(pointX, pointY); }; /** * Transforms coordinates on the map from google.maps.LatLng to * google.maps.Point * - * @param latlng - * cooordinates in x,y format - * @param coordinates + * @param latLng * in lat,lng format + * @param coordinates in x,y format + * */ AbstractCustomMap.prototype.fromLatLngToPoint = function (latLng) { var me = this; @@ -268,7 +268,7 @@ AbstractCustomMap.prototype.fromLatLngToPoint = function (latLng) { * * @param point * coordinates in standard x,y format - * @return cooordinates in lat,lng format + * @return coordinates in lat,lng format */ AbstractCustomMap.prototype.fromPointToLatLng = function (point) { var me = this; @@ -288,11 +288,11 @@ AbstractCustomMap.prototype.fromPointToLatLng = function (point) { * mouse clicked). * * - * @param latlng + * @param latLng * coordinates in latlng format * @param z * zoom level at which we want to find coordinates of tile - * @return cooordinates of a tile + * @return coordinates of a tile */ AbstractCustomMap.prototype.latLngToTile = function (latLng, z) { var worldCoordinate = this.fromLatLngToPoint(latLng); @@ -846,7 +846,7 @@ AbstractCustomMap.prototype._createMapChangedCallbacks = function () { google.maps.event.addListener(this.getGoogleMap(), 'zoom_changed', function () { sessionData.setZoomLevel(self.getModel(), self.getGoogleMap().getZoom()); }); - // listener for changing location of the map (moving left/reght/top/bottom + // listener for changing location of the map (moving left/right/top/bottom google.maps.event.addListener(this.getGoogleMap(), 'center_changed', function () { var coord = self.getGoogleMap().getCenter(); var point = self.fromLatLngToPoint(coord); @@ -916,11 +916,11 @@ AbstractCustomMap.prototype.getPictureSize = function () { }; /** - * Returns array containining elements that are presented on a specific layout + * Returns array containing elements that are presented on a specific layout * (set of google map objects representing lines/areas that are associated with * layout). * - * @returns {Array} containining elements that are presented on a specific + * @returns {Array} containing elements that are presented on a specific * layout (set of google map objects representing lines/areas that are * associated with layout). */ @@ -941,8 +941,8 @@ AbstractCustomMap.prototype.getGoogleMap = function () { * Sets google.maps.map object used to representing data. * */ -AbstractCustomMap.prototype.setGoogleMap = function (gmap) { - this._map = gmap; +AbstractCustomMap.prototype.setGoogleMap = function (googleMap) { + this._map = googleMap; }; AbstractCustomMap.prototype.isMarkerOptimization = function () { diff --git a/frontend-js/src/main/js/map/CustomMap.js b/frontend-js/src/main/js/map/CustomMap.js index 2225dc615c..9ccbc98e5b 100644 --- a/frontend-js/src/main/js/map/CustomMap.js +++ b/frontend-js/src/main/js/map/CustomMap.js @@ -158,7 +158,7 @@ CustomMap.prototype.clearDbOverlays = function () { * Open data overlay given in the parameter. * * @param param - * identifier or LayoutData identifing data overlay to open + * identifier or LayoutData identifying data overlay to open */ CustomMap.prototype.openDataOverlay = function (param) { logger.debug("Opening data overlay: " + param); @@ -414,7 +414,7 @@ CustomMap.prototype.openSubmap = function (id) { }; CustomMap.prototype.customizeGoogleMapView = function (div) { - var mapOptions = this.creatMapOptions(); + var mapOptions = this.createMapOptions(); this.setGoogleMap(new google.maps.Map(div, mapOptions)); this.setupLayouts(); @@ -481,7 +481,7 @@ CustomMap.prototype.createMapChangedCallbacks = function () { * * @param identifier * identifier of the submap - * @returns AbstractCustomMap (submap or this map) with given identfier of the model + * @returns AbstractCustomMap (submap or this map) with given identifier of the model */ CustomMap.prototype.getSubmapById = function (identifier) { identifier = parseInt(identifier); @@ -800,7 +800,7 @@ CustomMap.prototype.openInfoWindowForIdentifiedElement = function (element, mark }; /** - * Sends requestes to download detailed data about element in all + * Sends requests to download detailed data about element in all * {@link OverlayCollection}. * * @param element @@ -851,7 +851,7 @@ CustomMap.prototype.updateInfoWindowForIdentifiedElement = function (identifiedE * {@link Alias} for which overlay data will be returned * @param general * if true then all elements will be returned, if false then only ones - * availble right now in the overlay + * available right now in the overlay * @returns data from all {@link OverlayCollection} for a given alias */ CustomMap.prototype.getOverlayDataForAlias = function (alias, general) { @@ -866,7 +866,7 @@ CustomMap.prototype.getOverlayDataForAlias = function (alias, general) { * {@link Reaction} for which overlay data will be returned * @param general * if true then all elements will be returned, if false then only ones - * availble right now in the overlay + * available right now in the overlay * @returns data from all {@link OverlayCollection} for a given alias */ CustomMap.prototype.getOverlayDataForReaction = function (reaction, general) { diff --git a/frontend-js/src/main/js/map/Submap.js b/frontend-js/src/main/js/map/Submap.js index 4ce6afb62c..6ab2182991 100644 --- a/frontend-js/src/main/js/map/Submap.js +++ b/frontend-js/src/main/js/map/Submap.js @@ -37,13 +37,10 @@ Submap.prototype.constructor = Submap; /** * This method initializes submap with gui component. Before this point submap - * is created and contains data, but cannot be visualized in the broswer. + * is created and contains data, but cannot be visualized in the browser. * * @param htmlTag * html div tag where google map should be placed - * @param jsVar - * javascript component of primefaces popup dialog where submap will be - * visualized */ Submap.prototype.open = function (htmlTag) { var self = this; @@ -51,7 +48,7 @@ Submap.prototype.open = function (htmlTag) { if (!this.initialized) { self.htmlTag = htmlTag; - var mapOptions = self.creatMapOptions(self.getLayouts().length); + var mapOptions = self.createMapOptions(self.getLayouts().length); var contentDiv = document.createElement("div"); contentDiv.setAttribute("name", "submap-div-" + self.getId()); diff --git a/frontend-js/src/main/js/map/data/Alias.js b/frontend-js/src/main/js/map/data/Alias.js index a13785067d..d785c3dc6b 100644 --- a/frontend-js/src/main/js/map/data/Alias.js +++ b/frontend-js/src/main/js/map/data/Alias.js @@ -6,7 +6,7 @@ var BioEntity = require("./BioEntity"); * Class representing alias data. * * @param javaObject - * object deserialized ajax query to the server side + * object de-serialized ajax query to the server side */ function Alias(javaObject) { BioEntity.call(this, javaObject); @@ -39,7 +39,7 @@ Alias.prototype.constructor = Alias; /** * Updates alias with full data information. This function should be called when - * full informatin about alias is retrieved from server. + * full information about alias is retrieved from server. * * @param javaObject * object representing data from server side diff --git a/frontend-js/src/main/js/map/data/BioEntity.js b/frontend-js/src/main/js/map/data/BioEntity.js index f5e74463f7..a811be4c2c 100644 --- a/frontend-js/src/main/js/map/data/BioEntity.js +++ b/frontend-js/src/main/js/map/data/BioEntity.js @@ -6,7 +6,7 @@ var Annotation = require("./Annotation"); * Class representing BioEntity. * * @param javaObject - * object deserialized ajax query to the server side + * object de-serialized ajax query to the server side */ function BioEntity() { } diff --git a/frontend-js/src/main/js/map/data/Chemical.js b/frontend-js/src/main/js/map/data/Chemical.js index 1a9c79e733..51ce30b53c 100644 --- a/frontend-js/src/main/js/map/data/Chemical.js +++ b/frontend-js/src/main/js/map/data/Chemical.js @@ -18,18 +18,18 @@ function Chemical(javaObject) { Chemical.prototype = Object.create(TargettingStructure.prototype); Chemical.prototype.constructor = Chemical; -Chemical.prototype.setDirectEvidence = function(directeEvidence) { - this._directeEvidence = directeEvidence; +Chemical.prototype.setDirectEvidence = function(directEvidence) { + this._directEvidence = directEvidence; }; Chemical.prototype.getDirectEvidence = function() { - return this._directeEvidence; + return this._directEvidence; }; Chemical.prototype.setDirectEvidenceReferences = function(directeEvidenceReferences) { - this._directeEvidenceReferences = []; + this._directEvidenceReferences = []; for (var i = 0; i < directeEvidenceReferences.length; i++) { - this._directeEvidenceReferences.push(new Annotation(directeEvidenceReferences[i])); + this._directEvidenceReferences.push(new Annotation(directeEvidenceReferences[i])); } }; diff --git a/frontend-js/src/main/js/map/data/IdentifiedElement.js b/frontend-js/src/main/js/map/data/IdentifiedElement.js index 4b7f15df7b..1f6f2d0e3f 100644 --- a/frontend-js/src/main/js/map/data/IdentifiedElement.js +++ b/frontend-js/src/main/js/map/data/IdentifiedElement.js @@ -83,7 +83,7 @@ function IdentifiedElement(javaObject) { * Returns point where it should be visualized when the type of object is * "POINT". * - * @returns {@linke google.maps.Point} where it should be visualized when the + * @returns {@link google.maps.Point} where it should be visualized when the * type of object is "POINT". */ IdentifiedElement.prototype.getPoint = function() { diff --git a/frontend-js/src/main/js/map/data/LayoutAlias.js b/frontend-js/src/main/js/map/data/LayoutAlias.js index f8404122aa..7527d6ec95 100644 --- a/frontend-js/src/main/js/map/data/LayoutAlias.js +++ b/frontend-js/src/main/js/map/data/LayoutAlias.js @@ -6,7 +6,7 @@ var GeneVariant = require('./GeneVariant'); * Class representing alias visualized in a layout. * * @param javaObject - * object deserialized ajax query to the server side + * object de-serialized ajax query to the server side */ function LayoutAlias(javaObject) { this.setId(javaObject.idObject); @@ -86,7 +86,7 @@ LayoutAlias.prototype.setGeneVariants = function(newGeneVariants) { LayoutAlias.prototype.update = function(alias) { if (!(alias instanceof LayoutAlias)) { - throw new Error("Unknown paramter type: " + alias); + throw new Error("Unknown parameter type: " + alias); } this.setValue(alias.getValue()); diff --git a/frontend-js/src/main/js/map/data/LayoutData.js b/frontend-js/src/main/js/map/data/LayoutData.js index e502f6d1b5..8d8c29ba94 100644 --- a/frontend-js/src/main/js/map/data/LayoutData.js +++ b/frontend-js/src/main/js/map/data/LayoutData.js @@ -16,7 +16,7 @@ function LayoutData(layoutId, name) { this.setInitialized(false); if (name === undefined) { - // from jsonified structure + // from json structure var object = layoutId; this.setId(object.idObject); this.setName(object.name); diff --git a/frontend-js/src/main/js/map/data/LayoutReaction.js b/frontend-js/src/main/js/map/data/LayoutReaction.js index f7cca0fdf3..58d3dfd3b6 100644 --- a/frontend-js/src/main/js/map/data/LayoutReaction.js +++ b/frontend-js/src/main/js/map/data/LayoutReaction.js @@ -4,7 +4,7 @@ * Class representing reaction visualized in a layout. * * @param javaObject - * object deserialized from ajax query to the server side + * object de-serialized from ajax query to the server side */ function LayoutReaction(javaObject) { this.setId(javaObject.idObject); diff --git a/frontend-js/src/main/js/map/data/Reaction.js b/frontend-js/src/main/js/map/data/Reaction.js index 8e54bb475b..ba28f59d4b 100644 --- a/frontend-js/src/main/js/map/data/Reaction.js +++ b/frontend-js/src/main/js/map/data/Reaction.js @@ -11,7 +11,7 @@ var logger = require('../../logger'); * Class representing reaction data. * * @param javaObject - * object deserialized from ajax query to the server side + * object de-serialized from ajax query to the server side */ function Reaction(javaObject) { BioEntity.call(this, javaObject); diff --git a/frontend-js/src/main/js/map/marker/AliasMarker.js b/frontend-js/src/main/js/map/marker/AliasMarker.js index 26fda035d9..7fb256fde0 100644 --- a/frontend-js/src/main/js/map/marker/AliasMarker.js +++ b/frontend-js/src/main/js/map/marker/AliasMarker.js @@ -32,9 +32,9 @@ AliasMarker.prototype.setAliasData = function(data) { }; /** - * Returns coordinates where marker is poiting. + * Returns coordinates where marker is pointing. * - * @returns {google.maps.Point} - coordinates where marker is poiting + * @returns {google.maps.Point} - coordinates where marker is pointing */ AliasMarker.prototype.getCoordinates = function() { return new google.maps.Point(this._aliasData.x + this._aliasData.width / 2, this._aliasData.y diff --git a/frontend-js/src/main/js/map/marker/ReactionMarker.js b/frontend-js/src/main/js/map/marker/ReactionMarker.js index 10a1b82f7b..4ebe4248a9 100644 --- a/frontend-js/src/main/js/map/marker/ReactionMarker.js +++ b/frontend-js/src/main/js/map/marker/ReactionMarker.js @@ -42,9 +42,9 @@ ReactionMarker.prototype.setReactionData = function(data) { }; /** - * Returns coordinates where marker is poiting. + * Returns coordinates where marker is pointing. * - * @returns {google.maps.Point} - coordinates where marker is poiting + * @returns {google.maps.Point} - coordinates where marker is pointing */ ReactionMarker.prototype.getCoordinates = function() { return new google.maps.Point(this._reactionData.getCenter().x, this._reactionData.getCenter().y); diff --git a/frontend-js/src/main/js/map/surface/AliasSurface.js b/frontend-js/src/main/js/map/surface/AliasSurface.js index b6cb975357..58c38c691e 100644 --- a/frontend-js/src/main/js/map/surface/AliasSurface.js +++ b/frontend-js/src/main/js/map/surface/AliasSurface.js @@ -28,9 +28,9 @@ AliasSurface.prototype.constructor = AliasSurface; AliasSurface.prototype.setColor = function(color) { this._color = color; - var gmapObjects = this.getGoogleMapObjects(); - for (var i = 0; i < gmapObjects.length; i++) { - gmapObjects[i].setOptions({ + var googleMapObjects = this.getGoogleMapObjects(); + for (var i = 0; i < googleMapObjects.length; i++) { + googleMapObjects[i].setOptions({ strokeColor : color, }); } @@ -42,9 +42,9 @@ AliasSurface.prototype.setColor = function(color) { * visualization. * * @param startX - * value between 0..1 defininf where should be the start on OX axis + * value between 0..1 defining where should be the start on OX axis * @param endX - * value between 0..1 defininf where should be the end on OX axis + * value between 0..1 defining where should be the end on OX axis */ AliasSurface.prototype.setBoundsForAlias = function(startX, endX) { var pointA = new google.maps.Point(this.aliasData.x + startX * this.aliasData.width, this.aliasData.y); diff --git a/frontend-js/src/main/js/map/surface/ReactionSurface.js b/frontend-js/src/main/js/map/surface/ReactionSurface.js index 0a4432fdc9..a722520568 100644 --- a/frontend-js/src/main/js/map/surface/ReactionSurface.js +++ b/frontend-js/src/main/js/map/surface/ReactionSurface.js @@ -154,7 +154,7 @@ ReactionSurface.prototype.setBoundsForAlias = function(startX, endX) { if (this.isCustomized() && (startX > 0 || endX < 1)) { this.changedToDefault(); } else if (!this.isCustomized() && (startX <= 0 && endX >= 1)) { - this.changedToCustimzed(); + this.changedToCustomized(); } }; @@ -176,7 +176,7 @@ ReactionSurface.prototype.changedToDefault = function() { * Changes visualization of the ReactionSurface to customized mode where we mark * reaction as highlighted with customized reaction layout data. */ -ReactionSurface.prototype.changedToCustimzed = function() { +ReactionSurface.prototype.changedToCustomized = function() { for (var i = 0; i < this.getGoogleMapObjects().length; i++) { this.getGoogleMapObjects()[i].setOptions({ strokeColor : this.getColor(), @@ -196,7 +196,7 @@ ReactionSurface.prototype.changedToCustimzed = function() { * @param width * width that should be used for visualization of the line * @param map - * {google.maps.Map} where line shoul dbe visualized + * {google.maps.Map} where line should be visualized * @returns {google.maps.Polyline} from input data */ ReactionSurface.createLine = function(line, color, width, map) { diff --git a/frontend-js/src/main/js/map/window/AbstractInfoWindow.js b/frontend-js/src/main/js/map/window/AbstractInfoWindow.js index 23ddf813c4..7b0378b139 100644 --- a/frontend-js/src/main/js/map/window/AbstractInfoWindow.js +++ b/frontend-js/src/main/js/map/window/AbstractInfoWindow.js @@ -224,7 +224,7 @@ AbstractInfoWindow.prototype.createOverlayInfoDiv = function (overlay, data) { * Creates and returns div for drug overlay information. * * @param data - * data taken from drug iverlay + * data taken from drug overlay * @returns {String} with a div for drug overlay information */ AbstractInfoWindow.prototype._createDrugInfoDiv = function (overlay, data) { @@ -239,7 +239,7 @@ AbstractInfoWindow.prototype._createDrugInfoDiv = function (overlay, data) { * Creates and returns div for comment overlay information. * * @param data - * data taken from comment iverlay + * data taken from comment overlay * @returns {String} with a div for comment overlay information */ AbstractInfoWindow.prototype._createCommentInfoDiv = function (overlay, data) { diff --git a/frontend-js/src/main/js/minerva.js b/frontend-js/src/main/js/minerva.js index 914330c165..deed136a3b 100644 --- a/frontend-js/src/main/js/minerva.js +++ b/frontend-js/src/main/js/minerva.js @@ -454,8 +454,8 @@ function verifyBrowser() { var browser = functions.browser; if (browser.name === "IE") { if (browser.version <= 8 || browser.compatibilityMode) { - var message = "This webpage works only with Internet Explorer version 9 or greater.\n" - + "If you have Internet Explorer version 9 or greater and still see this message, please, turn the 'Compatibility modeoff:\n" + var message = "This web page works only with Internet Explorer version 9 or greater.\n" + + "If you have Internet Explorer version 9 or greater and still see this message, please, turn the 'Compatibility mode off:\n" + "Open Internet Explorer and press the Alt key on your keyboard.\n" + "Select 'Tools' menu item. \n" + "Select the 'Compatibility View' settings option. \n" diff --git a/frontend-js/src/test/js/ServerConnector-mock.js b/frontend-js/src/test/js/ServerConnector-mock.js index 29a52ea2ae..5e23ddf2a4 100644 --- a/frontend-js/src/test/js/ServerConnector-mock.js +++ b/frontend-js/src/test/js/ServerConnector-mock.js @@ -49,12 +49,12 @@ ServerConnectorMock._sendRequest = function(params) { } else { prefix = "/" + prefix + "_"; } - var sufix = ""; + var suffix = ""; if (params.form !== undefined) { - sufix += self.createGetParams(encodeParams(params.form)); + suffix += self.createGetParams(encodeParams(params.form)); } if (params.json !== undefined) { - sufix += self.createGetParams(params.json); + suffix += self.createGetParams(params.json); } return new Promise(function(resolve, reject) { if (url.indexOf("http") === 0) { @@ -68,7 +68,7 @@ ServerConnectorMock._sendRequest = function(params) { } }); } else { - var fileName = urlToFileName(url + prefix + sufix); + var fileName = urlToFileName(url + prefix + suffix); fs.readFile(fileName, 'utf8', function(err, content) { if (err) { reject(new NetworkError(err.message, { diff --git a/frontend-js/src/test/js/ServerConnector-test.js b/frontend-js/src/test/js/ServerConnector-test.js index 8adb10b29f..ab6fc4ec0a 100644 --- a/frontend-js/src/test/js/ServerConnector-test.js +++ b/frontend-js/src/test/js/ServerConnector-test.js @@ -284,7 +284,7 @@ describe('ServerConnector', function() { statusCode : HttpStatus.FORBIDDEN })); }; - return ServerConnector.login("blabla", "blablabla").then(function() { + return ServerConnector.login("unknown", "unknown password").then(function() { ServerConnector.sendPostRequest = method; assert.ok(false); }, function(error) { diff --git a/frontend-js/src/test/js/google-map-mock.js b/frontend-js/src/test/js/google-map-mock.js index 7b8d8245c3..3d50280af2 100644 --- a/frontend-js/src/test/js/google-map-mock.js +++ b/frontend-js/src/test/js/google-map-mock.js @@ -286,8 +286,8 @@ var google = { this.options.map = map; }; this.setOptions = function (options) { - for (var attrname in options) { - this.options[attrname] = options[attrname]; + for (var key in options) { + this.options[key] = options[key]; } }; this.getBounds = function () { diff --git a/frontend-js/src/test/js/gui/CommentDialog-test.js b/frontend-js/src/test/js/gui/CommentDialog-test.js index 199aff0a2b..7e87c882c8 100644 --- a/frontend-js/src/test/js/gui/CommentDialog-test.js +++ b/frontend-js/src/test/js/gui/CommentDialog-test.js @@ -10,7 +10,7 @@ var logger = require('../logger'); describe('CommentDialog', function() { - it('contructor', function() { + it('constructor', function() { var map = helper.createCustomMap(); var dialog = new CommentDialog({ diff --git a/frontend-js/src/test/js/gui/LoginDialog-test.js b/frontend-js/src/test/js/gui/LoginDialog-test.js index 4f9ec418e0..e7caebb84e 100644 --- a/frontend-js/src/test/js/gui/LoginDialog-test.js +++ b/frontend-js/src/test/js/gui/LoginDialog-test.js @@ -11,7 +11,7 @@ var logger = require('../logger'); describe('LoginDialog', function() { - it('contructor', function() { + it('constructor', function() { var map = helper.createCustomMap(); var dialog = new LoginDialog({ diff --git a/frontend-js/src/test/js/gui/leftPanel/AbstractPanel-test.js b/frontend-js/src/test/js/gui/leftPanel/AbstractPanel-test.js index b0fe518592..51b82ca66f 100644 --- a/frontend-js/src/test/js/gui/leftPanel/AbstractPanel-test.js +++ b/frontend-js/src/test/js/gui/leftPanel/AbstractPanel-test.js @@ -14,7 +14,7 @@ var logger = require('../../logger'); describe('AbstractDbPanel', function() { - it('contructor', function() { + it('constructor', function() { var div = document.createElement("div"); var map = helper.createCustomMap(); diff --git a/frontend-js/src/test/js/gui/leftPanel/ChemicalPanel-test.js b/frontend-js/src/test/js/gui/leftPanel/ChemicalPanel-test.js index b526d38ef8..cdf1b7d628 100644 --- a/frontend-js/src/test/js/gui/leftPanel/ChemicalPanel-test.js +++ b/frontend-js/src/test/js/gui/leftPanel/ChemicalPanel-test.js @@ -13,7 +13,7 @@ var logger = require('../../logger'); describe('ChemicalPanel', function() { - describe('contructor', function() { + describe('constructor', function() { it('default', function() { var map = helper.createCustomMap(); helper.createChemicalDbOverlay(map); @@ -23,7 +23,7 @@ describe('ChemicalPanel', function() { customMap : map }); assert.equal(logger.getWarnings().length, 0); - assert.ok(panel.isDisbaled()); + assert.ok(panel.isDisabled()); }); it('map with disease', function() { return ServerConnector.getProject().then(function(project) { @@ -41,7 +41,7 @@ describe('ChemicalPanel', function() { customMap : map }); assert.equal(logger.getWarnings().length, 0); - assert.notOk(panel.isDisbaled()); + assert.notOk(panel.isDisabled()); }); }); }); diff --git a/frontend-js/src/test/js/gui/leftPanel/DrugPanel-test.js b/frontend-js/src/test/js/gui/leftPanel/DrugPanel-test.js index 569b01ef93..da683237f9 100644 --- a/frontend-js/src/test/js/gui/leftPanel/DrugPanel-test.js +++ b/frontend-js/src/test/js/gui/leftPanel/DrugPanel-test.js @@ -12,7 +12,7 @@ var logger = require('../../logger'); describe('DrugPanel', function() { - it('contructor', function() { + it('constructor', function() { var map = helper.createCustomMap(); helper.createDrugDbOverlay(map); @@ -23,7 +23,7 @@ describe('DrugPanel', function() { assert.equal(logger.getWarnings().length, 0); }); - it('createDrugeader for empty', function() { + it('create DrugPanel', function() { var map = helper.createCustomMap(); helper.createDrugDbOverlay(map); @@ -35,7 +35,7 @@ describe('DrugPanel', function() { assert.ok(panel.createPreamble().innerHTML.indexOf("NOT FOUND") > 0); }); - it('createDrugeader for empty', function() { + it('create DrugPanel for empty drug', function() { var map = helper.createCustomMap(); helper.createDrugDbOverlay(map); diff --git a/frontend-js/src/test/js/gui/leftPanel/GenericSearchPanel-test.js b/frontend-js/src/test/js/gui/leftPanel/GenericSearchPanel-test.js index 35b1fc7163..deb9f4b060 100644 --- a/frontend-js/src/test/js/gui/leftPanel/GenericSearchPanel-test.js +++ b/frontend-js/src/test/js/gui/leftPanel/GenericSearchPanel-test.js @@ -12,7 +12,7 @@ var logger = require('../../logger'); describe('GenericSearchPanel', function() { - it('contructor', function() { + it('constructor', function() { var map = helper.createCustomMap(); helper.createSearchDbOverlay(map); @@ -103,13 +103,13 @@ describe('GenericSearchPanel', function() { helper.createSearchDbOverlay(map); var aliasObj = { - symbol : "S1_SYMB", + symbol : "S1_SYMBOL", formerSymbols : [], modelId : map.getId(), synonyms : [ "syn44" ], description : "DESCRIPTION", type : "Simple molecule", - abbreviation : "ABREVIATION", + abbreviation : "ABBREVIATION", name : "s1", bounds : { x : 170.0, diff --git a/frontend-js/src/test/js/gui/leftPanel/GuiUtils-test.js b/frontend-js/src/test/js/gui/leftPanel/GuiUtils-test.js index c57e0c9665..f179817e80 100644 --- a/frontend-js/src/test/js/gui/leftPanel/GuiUtils-test.js +++ b/frontend-js/src/test/js/gui/leftPanel/GuiUtils-test.js @@ -11,7 +11,7 @@ var logger = require('../../logger'); describe('GuiUtils', function() { - it('contructor', function() { + it('constructor', function() { var map = helper.createCustomMap(); helper.createSearchDbOverlay(map); @@ -21,13 +21,13 @@ describe('GuiUtils', function() { it('default', function() { var aliasObj = { - symbol : "S1_SYMB", + symbol : "S1_SYMBOL", formerSymbols : [], modelId : 15781, synonyms : [ "syn44" ], description : "DESCRIPTION", type : "Simple molecule", - abbreviation : "ABREVIATION", + abbreviation : "ABBREVIATION", name : "s1", bounds : { x : 170.0, diff --git a/frontend-js/src/test/js/gui/leftPanel/MiRnaPanel-test.js b/frontend-js/src/test/js/gui/leftPanel/MiRnaPanel-test.js index 258647f76c..874e0c9a2e 100644 --- a/frontend-js/src/test/js/gui/leftPanel/MiRnaPanel-test.js +++ b/frontend-js/src/test/js/gui/leftPanel/MiRnaPanel-test.js @@ -12,7 +12,7 @@ var logger = require('../../logger'); describe('MiRnaPanel', function() { - it('contructor', function() { + it('constructor', function() { var map = helper.createCustomMap(); helper.createMiRnaDbOverlay(map); @@ -23,7 +23,7 @@ describe('MiRnaPanel', function() { assert.equal(logger.getWarnings().length, 0); }); - it('createMiRnaeader for empty', function() { + it('create MiRnaPanel for empty', function() { var map = helper.createCustomMap(); helper.createMiRnaDbOverlay(map); @@ -35,7 +35,7 @@ describe('MiRnaPanel', function() { assert.ok(panel.createPreamble().innerHTML.indexOf("NOT FOUND") > 0); }); - it('createMiRnaeader for empty', function() { + it('create MiRnaPanel for empty MiRna', function() { var map = helper.createCustomMap(); helper.createMiRnaDbOverlay(map); diff --git a/frontend-js/src/test/js/gui/leftPanel/PublicationListDialog-test.js b/frontend-js/src/test/js/gui/leftPanel/PublicationListDialog-test.js index 58068fddd6..dc9d95fd5c 100644 --- a/frontend-js/src/test/js/gui/leftPanel/PublicationListDialog-test.js +++ b/frontend-js/src/test/js/gui/leftPanel/PublicationListDialog-test.js @@ -10,41 +10,41 @@ var logger = require('../../logger'); describe('PublicationListDialog', function () { - it('contructor', function () { - var div = testDiv; + it('constructor', function () { + var div = testDiv; - var map = helper.createCustomMap(); + var map = helper.createCustomMap(); - var dialog = new PublicationListDialog({ - element: div, - customMap: map - }); - assert.equal(logger.getWarnings().length, 0); - - dialog.destroy(); + var dialog = new PublicationListDialog({ + element: div, + customMap: map }); - - it('_dataTableAjaxCall', function () { - var dialog; - var callbackCalled = false; - return ServerConnector.getProject().then(function (project) { - dialog = new PublicationListDialog({ - element: testDiv, - customMap: helper.createCustomMap(project), - }); - return dialog._dataTableAjaxCall({ - start: 0, - length: 10, - order: [{column: 0, dir: 'asc'}], - search: {value: '', regex: false} - }, function () { - callbackCalled = true; - }); - }).then(function () { - assert.ok(callbackCalled); - }).finally(function () { - dialog.destroy(); - }); + assert.equal(logger.getWarnings().length, 0); + + dialog.destroy(); + }); + + it('_dataTableAjaxCall', function () { + var dialog; + var callbackCalled = false; + return ServerConnector.getProject().then(function (project) { + dialog = new PublicationListDialog({ + element: testDiv, + customMap: helper.createCustomMap(project), + }); + return dialog._dataTableAjaxCall({ + start: 0, + length: 10, + order: [{column: 0, dir: 'asc'}], + search: {value: '', regex: false} + }, function () { + callbackCalled = true; + }); + }).then(function () { + assert.ok(callbackCalled); + }).finally(function () { + dialog.destroy(); }); + }); }); diff --git a/frontend-js/src/test/js/gui/leftPanel/SubmapPanel-test.js b/frontend-js/src/test/js/gui/leftPanel/SubmapPanel-test.js index c04d1893d9..ce0bddc904 100644 --- a/frontend-js/src/test/js/gui/leftPanel/SubmapPanel-test.js +++ b/frontend-js/src/test/js/gui/leftPanel/SubmapPanel-test.js @@ -10,7 +10,7 @@ var logger = require('../../logger'); describe('SubmapPanel', function() { - it('contructor', function() { + it('constructor', function() { var div = document.createElement("div"); var map = helper.createCustomMap(); diff --git a/frontend-js/src/test/js/helper.js b/frontend-js/src/test/js/helper.js index 947e0cd778..f023345657 100644 --- a/frontend-js/src/test/js/helper.js +++ b/frontend-js/src/test/js/helper.js @@ -143,7 +143,7 @@ Helper.prototype.createComment = function (element) { return result; }; -Helper.prototype.createProject = function () { +Helper.prototype.createProject = function() { var result = new Project(); result.setProjectId("testId"); result.setId(this.idCounter++); @@ -151,17 +151,17 @@ Helper.prototype.createProject = function () { return result; }; -Helper.prototype.createUser = function () { +Helper.prototype.createUser = function() { var result = new User({ - login: "testlogin", - id: this.idCounter++, - name: "some name", - surname: "surn", + login : "test_login", + id : this.idCounter++, + name : "some name", + surname : "surname", }); return result; }; -Helper.prototype.createAlias = function (map) { +Helper.prototype.createAlias = function(map) { var mapId; if (map === undefined) { mapId = this.idCounter++; @@ -169,15 +169,15 @@ Helper.prototype.createAlias = function (map) { mapId = map.getId(); } var result = new Alias({ - idObject: this.idCounter++, - name: "Test element", - type: "RNA", - modelId: mapId, - bounds: { - x: 10.0, - y: 20.0, - width: 30.0, - height: 40.0, + idObject : this.idCounter++, + name : "Test element", + type : "RNA", + modelId : mapId, + bounds : { + x : 10.0, + y : 20.0, + width : 30.0, + height : 40.0, }, references: [], }); @@ -198,10 +198,10 @@ Helper.prototype.createLayoutAlias = function (alias) { modelId = this.idCounter++; } var result = new LayoutAlias({ - idObject: id, - value: 0.2, - color: { - a: 23 + idObject : id, + value : 0.2, + color : { + a : 23 }, modelId: modelId, geneVariations: [{}] diff --git a/frontend-js/src/test/js/map/AbstractCustomMap-test.js b/frontend-js/src/test/js/map/AbstractCustomMap-test.js index e1eac29194..31a38dc20a 100644 --- a/frontend-js/src/test/js/map/AbstractCustomMap-test.js +++ b/frontend-js/src/test/js/map/AbstractCustomMap-test.js @@ -42,17 +42,17 @@ describe('AbstractCustomMap', function() { var mockObject = new AbstractCustomMap(model, options); - var gmap = helper.createGoogleMap(); + var googleMap = helper.createGoogleMap(); - mockObject.setGoogleMap(gmap); + mockObject.setGoogleMap(googleMap); mockObject.setupLayouts(); assert.ok(mockObject.getGoogleMap().getMapTypeId().indexOf(layout.getId()) >= 0); }); - it("creatMapOptions", function() { + it("createMapOptions", function() { var mockObject = helper.createCustomMap(); - assert.ok(mockObject.creatMapOptions()); + assert.ok(mockObject.createMapOptions()); }); @@ -87,9 +87,9 @@ describe('AbstractCustomMap', function() { var mockObject = new AbstractCustomMap(model, options); - var gmap = helper.createGoogleMap(); + var googleMap = helper.createGoogleMap(); - mockObject.setGoogleMap(gmap); + mockObject.setGoogleMap(googleMap); mockObject.setMaxZoomLevel(); assert.equal(model.getMaxZoom(), mockObject.getGoogleMap().getZoom()); @@ -103,15 +103,15 @@ describe('AbstractCustomMap', function() { var mockObject = new AbstractCustomMap(model, options); - var gmap = new google.maps.Map(testDiv, {}); - gmap.setCenter(new google.maps.LatLng(1, 2)); + var googleMap = new google.maps.Map(testDiv, {}); + googleMap.setCenter(new google.maps.LatLng(1, 2)); - mockObject.setGoogleMap(gmap); + mockObject.setGoogleMap(googleMap); - var coords = mockObject.getMouseLatLng(); + var coordinates = mockObject.getMouseLatLng(); - assert.ok(coords); - assert.ok(coords instanceof google.maps.LatLng); + assert.ok(coordinates); + assert.ok(coordinates instanceof google.maps.LatLng); }); it("fromPixelsToPoint 1", function() { @@ -201,9 +201,9 @@ describe('AbstractCustomMap', function() { it("registerMapClickEvents", function() { var mockObject = helper.createAbstractCustomMap(); - var gmap = new google.maps.Map(testDiv, {}); + var googleMap = new google.maps.Map(testDiv, {}); - mockObject.setGoogleMap(gmap); + mockObject.setGoogleMap(googleMap); // mock function to not put error log on console mockObject.getTopMap = function() { return null; @@ -226,9 +226,9 @@ describe('AbstractCustomMap', function() { it("_turnOnOffDrawing", function() { var mockObject = helper.createAbstractCustomMap(); - var gmap = new google.maps.Map(testDiv, {}); + var googleMap = new google.maps.Map(testDiv, {}); - mockObject.setGoogleMap(gmap); + mockObject.setGoogleMap(googleMap); // mock function to not put error log on console mockObject.getTopMap = function() { @@ -245,12 +245,12 @@ describe('AbstractCustomMap', function() { it("areaToString", function() { var mockObject = helper.createAbstractCustomMap(); - var triangleCoords = [ new google.maps.LatLng(25.774, -80.190), new google.maps.LatLng(18.466, -66.118), + var triangleCoordinates = [ new google.maps.LatLng(25.774, -80.190), new google.maps.LatLng(18.466, -66.118), new google.maps.LatLng(32.321, -64.757), new google.maps.LatLng(25.774, -80.190), ]; // Construct the polygon. var bermudaTriangle = new google.maps.Polygon({ - paths : triangleCoords, + paths : triangleCoordinates, strokeColor : '#FF0000', strokeOpacity : 0.8, strokeWeight : 2, @@ -270,9 +270,9 @@ describe('AbstractCustomMap', function() { var y = 11040; var point = new google.maps.Point(x, y); - var coord = mockObject.fromPointToLatLng(point); + var coordinates = mockObject.fromPointToLatLng(point); - var point2 = mockObject.fromLatLngToPoint(coord); + var point2 = mockObject.fromLatLngToPoint(coordinates); assert.closeTo(point2.x, point.x, 0.5, "X coordinate is invalid after transformation"); assert.closeTo(point2.y, point.y, 0.5, "Y coordinate is invalid after transformation"); diff --git a/frontend-js/src/test/js/map/CustomMap-test.js b/frontend-js/src/test/js/map/CustomMap-test.js index fcba29e81a..95c127229c 100644 --- a/frontend-js/src/test/js/map/CustomMap-test.js +++ b/frontend-js/src/test/js/map/CustomMap-test.js @@ -22,97 +22,97 @@ var chai = require('chai'); var assert = chai.assert; describe('CustomMap', function () { - describe("constructor", function () { - it("default", function () { - var options = helper.createCustomMapOptions(); - var map = new CustomMap(options); - assert.ok(map); - }); - - it("with submaps", function () { - var options = helper.createCustomMapOptions(); - - options.getProject().getModel().addSubmodel(helper.createModel()); - - var map = new CustomMap(options); - assert.ok(map); - }); + describe("constructor", function () { + it("default", function () { + var options = helper.createCustomMapOptions(); + var map = new CustomMap(options); + assert.ok(map); + }); - it("with session data pointing to not existing overlay", function () { - var options = helper.createCustomMapOptions(); + it("with submaps", function () { + var options = helper.createCustomMapOptions(); - ServerConnector.getSessionData(options.getProject()).setSelectedBackgroundOverlay("-1"); + options.getProject().getModel().addSubmodel(helper.createModel()); - var map = new CustomMap(options); - assert.ok(map); - }); + var map = new CustomMap(options); + assert.ok(map); }); - it("getSubmapById", function () { - var map = helper.createCustomMap(); - assert.ok(map.getSubmapById(map.getId())); - }); + it("with session data pointing to not existing overlay", function () { + var options = helper.createCustomMapOptions(); - it("getSubmapById (invalid)", function () { - var map = helper.createCustomMap(); - assert.equal(map.getSubmapById(-1), null); - }); + ServerConnector.getSessionData(options.getProject()).setSelectedBackgroundOverlay("-1"); - it("getSubmapById (string id)", function () { - var map = helper.createCustomMap(); - assert.ok(map.getSubmapById(map.getId() + "")); + var map = new CustomMap(options); + assert.ok(map); }); + }); - describe("openDataOverlay", function () { - it("for not existing id", function () { - var map = helper.createCustomMap(); - try { - map.openDataOverlay(-1); - assert.ok(false); - } catch (exception) { - assert.ok(exception.message.indexOf("You have no privileges") >= 0); - } - }); + it("getSubmapById", function () { + var map = helper.createCustomMap(); + assert.ok(map.getSubmapById(map.getId())); + }); - it("for int id", function () { - var options = helper.createCustomMapOptions(); - var model = options.getProject().getModel(); - var layout = model.getLayouts()[0]; - var map = new CustomMap(options); - map.openDataOverlay(layout.getId()); - assert.equal(logger.getErrors().length, 0); - }); + it("getSubmapById (invalid)", function () { + var map = helper.createCustomMap(); + assert.equal(map.getSubmapById(-1), null); + }); - it("for overlay object", function () { - var options = helper.createCustomMapOptions(); - var model = options.getProject().getModel(); - var layout = model.getLayouts()[0]; - var map = new CustomMap(options); - map.openDataOverlay(layout); - assert.equal(logger.getErrors().length, 0); - }); + it("getSubmapById (string id)", function () { + var map = helper.createCustomMap(); + assert.ok(map.getSubmapById(map.getId() + "")); + }); - it("for string id", function () { - var options = helper.createCustomMapOptions(); - var model = options.getProject().getModel(); - var layout = model.getLayouts()[0]; - var map = new CustomMap(options); - map.openDataOverlay(layout.getId() + ""); - assert.equal(logger.getErrors().length, 0); - }); + describe("openDataOverlay", function () { + it("for not existing id", function () { + var map = helper.createCustomMap(); + try { + map.openDataOverlay(-1); + assert.ok(false); + } catch (exception) { + assert.ok(exception.message.indexOf("You have no privileges") >= 0); + } + }); + + it("for int id", function () { + var options = helper.createCustomMapOptions(); + var model = options.getProject().getModel(); + var layout = model.getLayouts()[0]; + var map = new CustomMap(options); + map.openDataOverlay(layout.getId()); + assert.equal(logger.getErrors().length, 0); + }); + + it("for overlay object", function () { + var options = helper.createCustomMapOptions(); + var model = options.getProject().getModel(); + var layout = model.getLayouts()[0]; + var map = new CustomMap(options); + map.openDataOverlay(layout); + assert.equal(logger.getErrors().length, 0); + }); + + it("for string id", function () { + var options = helper.createCustomMapOptions(); + var model = options.getProject().getModel(); + var layout = model.getLayouts()[0]; + var map = new CustomMap(options); + map.openDataOverlay(layout.getId() + ""); + assert.equal(logger.getErrors().length, 0); + }); + + it("with background overlay", function () { + var map = helper.createCustomMap(); + var layout = helper.createLayout(); + layout.setInitialized(true); + layout.setInputDataAvailable(false); + map.getModel().addLayout(layout); - it("with background overlay", function () { - var map = helper.createCustomMap(); - var layout = helper.createLayout(); - layout.setInitialized(true); - layout.setInputDataAvailable(false); - map.getModel().addLayout(layout); - - return map.openDataOverlay(layout.getId()).then(function () { - var vLayouts = ServerConnector.getSessionData(map.getProject()).getVisibleOverlays(); - assert.equal(0, vLayouts.length); - }); - }); + return map.openDataOverlay(layout.getId()).then(function () { + var vLayouts = ServerConnector.getSessionData(map.getProject()).getVisibleOverlays(); + assert.equal(0, vLayouts.length); + }); + }); it("simple", function() { var map = helper.createCustomMap(); @@ -131,851 +131,851 @@ describe('CustomMap', function () { var layoutReaction = helper.createLayoutReaction(reaction); layout.addReaction(layoutReaction); - map.getModel().addLayout(layout); + map.getModel().addLayout(layout); - return map.openDataOverlay(layout.getId()).then(function () { - return map._showSelectedLayout(layout.getId(), 0, 1); - }).then(function () { - var vLayouts = ServerConnector.getSessionData(map.getProject()).getVisibleOverlays(); - assert.equal(1, vLayouts.length); - assert.equal(layout.getId(), vLayouts[0]); + return map.openDataOverlay(layout.getId()).then(function () { + return map._showSelectedLayout(layout.getId(), 0, 1); + }).then(function () { + var vLayouts = ServerConnector.getSessionData(map.getProject()).getVisibleOverlays(); + assert.equal(1, vLayouts.length); + assert.equal(layout.getId(), vLayouts[0]); - assert.equal(2, map.selectedLayoutOverlays[layout.getId()].length); - assert.ok(map.selectedLayoutOverlays[layout.getId()][0] instanceof AliasSurface); - assert.ok(map.selectedLayoutOverlays[layout.getId()][1] instanceof ReactionSurface); + assert.equal(2, map.selectedLayoutOverlays[layout.getId()].length); + assert.ok(map.selectedLayoutOverlays[layout.getId()][0] instanceof AliasSurface); + assert.ok(map.selectedLayoutOverlays[layout.getId()][1] instanceof ReactionSurface); - // now hide the layout - map._hideSelectedLayout(layout.getId()); - assert.ok(map.selectedLayoutOverlays[layout.getId()]); - assert.equal(0, map.selectedLayoutOverlays[layout.getId()].length); - }); - - }); - - it("with submaps", function () { - var projectId = "complex_model_with_submaps"; - helper.setUrl("http://test/?id=" + projectId); - var customMap; - var emptySubmodelId = 16730; - var filledSubmodelId = 16731; - var overlayId = 18083; - - return ServerConnector.getProject(projectId).then(function (project) { - var options = helper.createCustomMapOptions(project); - customMap = new CustomMap(options); - - return customMap.openSubmap(emptySubmodelId); - }).then(function () { - return customMap.openSubmap(filledSubmodelId); - }).then(function () { - - var emptySubmap = customMap.getSubmapById(emptySubmodelId); - var filledSubmap = customMap.getSubmapById(filledSubmodelId); - - return customMap.openDataOverlay(overlayId).then(function () { - - assert.equal(1, customMap.selectedLayoutOverlays[overlayId].length); - assert.equal(1, filledSubmap.selectedLayoutOverlays[overlayId].length); - assert.equal(0, emptySubmap.selectedLayoutOverlays[overlayId].length); - - // now hide the layout - customMap.hideSelectedLayout(overlayId); - assert.equal(0, customMap.selectedLayoutOverlays[overlayId].length); - assert.equal(0, filledSubmap.selectedLayoutOverlays[overlayId].length); - assert.equal(0, emptySubmap.selectedLayoutOverlays[overlayId].length); - }); - - }).then(function () { - return customMap.destroy(); - }); - }); + // now hide the layout + map._hideSelectedLayout(layout.getId()); + assert.ok(map.selectedLayoutOverlays[layout.getId()]); + assert.equal(0, map.selectedLayoutOverlays[layout.getId()].length); + }); }); - it("removeSelectedLayout", function () { - var map = helper.createCustomMap(); - var layout = helper.createLayout(); - layout.setInitialized(true); - layout.setInputDataAvailable(true); - map.getModel().addLayout(layout); + it("with submaps", function () { + var projectId = "complex_model_with_submaps"; + helper.setUrl("http://test/?id=" + projectId); + var customMap; + var emptySubmodelId = 16730; + var filledSubmodelId = 16731; + var overlayId = 18083; - return map.openDataOverlay(layout.getId()).then(function () { - return map.removeSelectedLayout(layout.getId()); - }).then(function () { - var vLayouts = ServerConnector.getSessionData(map.getProject()).getVisibleOverlays(); - assert.equal(0, vLayouts.length); - }); - }); + return ServerConnector.getProject(projectId).then(function (project) { + var options = helper.createCustomMapOptions(project); + customMap = new CustomMap(options); - describe("openInfoWindowForAlias", function () { - it("default", function () { - var map = helper.createCustomMap(); - var layout = helper.createLayout(); - var alias = helper.createAlias(); - alias.setModelId(map.getId()); - var layoutAlias = helper.createLayoutAlias(); - layoutAlias.setId(alias.getId()); + return customMap.openSubmap(emptySubmodelId); + }).then(function () { + return customMap.openSubmap(filledSubmodelId); + }).then(function () { - layout.addAlias(layoutAlias); + var emptySubmap = customMap.getSubmapById(emptySubmodelId); + var filledSubmap = customMap.getSubmapById(filledSubmodelId); - // create layout - map.getModel().addLayout(layout); - map.getModel().addAlias(alias); + return customMap.openDataOverlay(overlayId).then(function () { - return map.openInfoWindowForAlias(alias).then(function () { - assert.ok(map.getAliasInfoWindowById(alias.getId())); - assert.ok(map.getAliasInfoWindowById(alias.getId()).isOpened()); - }); - }); + assert.equal(1, customMap.selectedLayoutOverlays[overlayId].length); + assert.equal(1, filledSubmap.selectedLayoutOverlays[overlayId].length); + assert.equal(0, emptySubmap.selectedLayoutOverlays[overlayId].length); - it("for incomplete alias", function () { - var map, alias; - return ServerConnector.getProject().then(function (project) { - var options = helper.createCustomMapOptions(project); - map = new CustomMap(options); - - return map.getModel().getAliasById(329171, false); - }).then(function (result) { - alias = result; - assert.notOk(alias.isComplete()); - return map.openInfoWindowForAlias(alias); - }).then(function () { - assert.ok(map.getAliasInfoWindowById(alias.getId())); - assert.ok(map.getAliasInfoWindowById(alias.getId()).isOpened()); - }); + // now hide the layout + customMap.hideSelectedLayout(overlayId); + assert.equal(0, customMap.selectedLayoutOverlays[overlayId].length); + assert.equal(0, filledSubmap.selectedLayoutOverlays[overlayId].length); + assert.equal(0, emptySubmap.selectedLayoutOverlays[overlayId].length); }); - }); - - it("getSearchAutocomplete", function () { - var map = helper.createCustomMap(); - var t = map.getSearchAutocomplete("s"); - assert.ok(t); - assert.equal(t.length, 0); + }).then(function () { + return customMap.destroy(); + }); }); - it("getSearchAutocomplete 2", function () { - var map = helper.createCustomMap(); + }); - return map.refreshSearchAutocomplete("s").then(function () { - var t = map.getSearchAutocomplete("s"); - assert.ok(t); - assert.ok(t.length > 0); - }); - }); - - describe("renderOverlayCollection", function () { - it("for alias", function () { - var map = helper.createCustomMap(); - var reaction = helper.createReaction(); - var alias = helper.createAlias(); - map.getModel().addAlias(alias); - map.getModel().addReaction(reaction); - - var oc = helper.createDbOverlay(map); - - oc.getIdentifiedElements = function () { - return Promise.resolve([new IdentifiedElement({ - objectId: alias.getId(), - icon: "empty.png", - modelId: map.getId(), - type: "Alias" - })]); - }; - return map.renderOverlayCollection({ - overlayCollection: oc - }).then(function () { - var aliasMarkerCount = 0; - var markers = oc.markers["ALIAS"]; - for (var id in markers) { - if (markers.hasOwnProperty(id)) { - aliasMarkerCount++; - } - } - assert.equal(1, aliasMarkerCount); - }); - }); - - it("alias re-rendering with different icon", function () { - var map = helper.createCustomMap(); - var reaction = helper.createReaction(map); - var alias = helper.createAlias(map); - map.getModel().addAlias(alias); - map.getModel().addReaction(reaction); - - var marker; - var oc = helper.createDbOverlay(map); - - oc.getIdentifiedElements = function () { - return Promise.resolve([new IdentifiedElement({ - objectId: alias.getId(), - icon: "empty.png", - modelId: map.getId(), - type: "Alias" - }), new IdentifiedElement(reaction)]); - }; - return map.renderOverlayCollection({ - overlayCollection: oc - }).then(function () { - marker = oc.markers["ALIAS"][alias.getId()]; - oc.getIdentifiedElements = function () { - return Promise.resolve([new IdentifiedElement({ - objectId: alias.getId(), - icon: "new_icon.png", - modelId: map.getId(), - type: "Alias" - })]); - }; - assert.ok(oc.mapOverlays["REACTION"][reaction.getId()]); - - return map.renderOverlayCollection({ - overlayCollection: oc - }); - }).then(function () { - assert.equal(marker.getIcon(), "new_icon.png"); - - assert.notOk(oc.mapOverlays["REACTION"][reaction.getId()]); - }); - }); - - it("for set of aliases", function () { - var map = helper.createCustomMap(); - - var oc = helper.createDbOverlay(map); - - var identifiedElements = []; - for (var i = 0; i < 3; i++) { - var alias = helper.createAlias(map); - map.getModel().addAlias(alias); - var ie = helper.createIdentifiedElement(alias); - ie.setIcon(""); - identifiedElements.push(ie); - } - - oc.getIdentifiedElements = function () { - return Promise.resolve(identifiedElements); - }; - - return map.renderOverlayCollection({ - overlayCollection: oc - }).then(function () { - var aliasMarkerCount = 0; - var markers = oc.markers["ALIAS"]; - for (var id in markers) { - if (markers.hasOwnProperty(id)) { - aliasMarkerCount++; - } - } - - assert.equal(aliasMarkerCount, 3); - }); - }); - - it("for point", function () { - var map = helper.createCustomMap(); - - var oc = helper.createDbOverlay(map); - - var javaObj = { - objectId: "Point2D.Double[117.685546875, 204.6923828125001]", - modelId: map.getId(), - type: "POINT", - icon: "marker/empty.png" - }; - - oc.getIdentifiedElements = function () { - return Promise.resolve([new IdentifiedElement(javaObj)]); - }; - - return map.renderOverlayCollection({ - overlayCollection: oc - }).then(function () { - var markerCount = 0; - var markers = oc.markers["POINT"]; - for (var id in markers) { - if (markers.hasOwnProperty(id)) { - markerCount++; - } - } - assert.equal(1, markerCount); - }); - }); - - it("for reaction", function () { - var map = helper.createCustomMap(); - var reaction = helper.createReaction(); - map.getModel().addReaction(reaction); - - var oc = helper.createDbOverlay(map); - - var javaObj = { - objectId: reaction.getId(), - modelId: map.getId(), - type: "Reaction", - }; - - oc.getIdentifiedElements = function () { - return Promise.resolve([new IdentifiedElement(javaObj)]); - }; - - return map.renderOverlayCollection({ - overlayCollection: oc - }).then(function () { - var markerCount = 0; - var markers = oc.mapOverlays["REACTION"]; - for (var id in markers) { - if (markers.hasOwnProperty(id)) { - markerCount++; - } - } - assert.equal(1, markerCount); - }); - }); - }); - - it("clearDbOverlays", function () { - var map = helper.createCustomMap(); - - var oc = helper.createDbOverlay(map); - - var javaObj = { - objectId: "Point2D.Double[117.685546875, 204.6923828125001]", - modelId: map.getId(), - type: "POINT", - icon: "marker/empty.png" - }; - var searchResults = [new IdentifiedElement(javaObj)]; - - oc.getIdentifiedElements = function () { - return Promise.resolve(searchResults); - }; - oc.clear = function () { - searchResults = []; - return this.callListeners("onSearch", searchResults); - }; - - return map.renderOverlayCollection({ - overlayCollection: oc - }).then(function () { - - return map.clearDbOverlays(); - }).then(function () { - var markerCount = 0; - for (var id in oc.pointMarkers) { - if (oc.pointMarkers.hasOwnProperty(id)) { - markerCount++; - } - } - - assert.equal(0, markerCount); - }); + it("removeSelectedLayout", function () { + var map = helper.createCustomMap(); + var layout = helper.createLayout(); + layout.setInitialized(true); + layout.setInputDataAvailable(true); + map.getModel().addLayout(layout); + return map.openDataOverlay(layout.getId()).then(function () { + return map.removeSelectedLayout(layout.getId()); + }).then(function () { + var vLayouts = ServerConnector.getSessionData(map.getProject()).getVisibleOverlays(); + assert.equal(0, vLayouts.length); }); + }); - it("getInfoWindowForIdentifiedElement ( reaction)", function () { - var map = helper.createCustomMap(); - var reaction = helper.createReaction(map); - map.getModel().addReaction(reaction); - - var ie = helper.createIdentifiedElement(reaction); - - var infoWindow = map.getInfoWindowForIdentifiedElement(ie); + describe("openInfoWindowForAlias", function () { + it("default", function () { + var map = helper.createCustomMap(); + var layout = helper.createLayout(); + var alias = helper.createAlias(); + alias.setModelId(map.getId()); + var layoutAlias = helper.createLayoutAlias(); + layoutAlias.setId(alias.getId()); - assert.equal(null, infoWindow); - return map._openInfoWindowForReaction(reaction).then(function () { - infoWindow = map.getInfoWindowForIdentifiedElement(ie); + layout.addAlias(layoutAlias); - assert.ok(infoWindow); - }); + // create layout + map.getModel().addLayout(layout); + map.getModel().addAlias(alias); + return map.openInfoWindowForAlias(alias).then(function () { + assert.ok(map.getAliasInfoWindowById(alias.getId())); + assert.ok(map.getAliasInfoWindowById(alias.getId()).isOpened()); + }); }); - it("right click on map", function () { - var map = helper.createCustomMap(); - map.setContextMenu(new MapContextMenu({ - customMap: map, - element: testDiv - })); - - var mev = { - stop: null, - latLng: new google.maps.LatLng(40.0, -90.0) - }; - - assert.notOk(map.getActiveSubmapId()); - google.maps.event.trigger(map.getGoogleMap(), 'rightclick', mev); - assert.equal(map.getId(), map.getActiveSubmapId()); + it("for incomplete alias", function () { + var map, alias; + return ServerConnector.getProject().then(function (project) { + var options = helper.createCustomMapOptions(project); + map = new CustomMap(options); + return map.getModel().getAliasById(329171, false); + }).then(function (result) { + alias = result; + assert.notOk(alias.isComplete()); + return map.openInfoWindowForAlias(alias); + }).then(function () { + assert.ok(map.getAliasInfoWindowById(alias.getId())); + assert.ok(map.getAliasInfoWindowById(alias.getId()).isOpened()); + }); }); + }); - it("left click on map", function () { - var map; - var searchOverlay; - return ServerConnector.getProject().then(function (project) { - map = helper.createCustomMap(project); - searchOverlay = helper.createSearchDbOverlay(map); - - var mev = { - stop: null, - latLng: new google.maps.LatLng(82.32061703407554, -167.25586206896548), - }; - map.getGoogleMap().setZoom(4); - // latLng : new google.maps.LatLng(82.40238643645326, -148.44758620689652) + it("getSearchAutocomplete", function () { + var map = helper.createCustomMap(); - assert.notOk(map.getActiveSubmapId()); - return google.maps.event.trigger(map.getGoogleMap(), 'click', mev); + var t = map.getSearchAutocomplete("s"); + assert.ok(t); + assert.equal(t.length, 0); + }); - }).then(function () { - assert.equal(map.getId(), map.getActiveSubmapId()); - assert.ok(searchOverlay.markers["ALIAS"][329171]); - }); + it("getSearchAutocomplete 2", function () { + var map = helper.createCustomMap(); + return map.refreshSearchAutocomplete("s").then(function () { + var t = map.getSearchAutocomplete("s"); + assert.ok(t); + assert.ok(t.length > 0); }); + }); - it("left click on reaction", function () { - var map; - var searchOverlay; - return ServerConnector.getProject().then(function (project) { - map = helper.createCustomMap(project); - searchOverlay = helper.createSearchDbOverlay(map); - - var mev = { - stop: null, - latLng: new google.maps.LatLng(82.40238643645326, -148.44758620689652) - }; - map.getGoogleMap().setZoom(4); + describe("renderOverlayCollection", function () { + it("for alias", function () { + var map = helper.createCustomMap(); + var reaction = helper.createReaction(); + var alias = helper.createAlias(); + map.getModel().addAlias(alias); + map.getModel().addReaction(reaction); - assert.notOk(map.getActiveSubmapId()); - return google.maps.event.trigger(map.getGoogleMap(), 'click', mev); - }).then(function () { - assert.equal(map.getId(), map.getActiveSubmapId()); - assert.ok(searchOverlay.mapOverlays["REACTION"][153521]); - assert.ok(searchOverlay.mapOverlays["REACTION"][153521].isShown()); - assert.ok(searchOverlay.markers["ALIAS"][329165]); - }); + var oc = helper.createDbOverlay(map); + + oc.getIdentifiedElements = function () { + return Promise.resolve([new IdentifiedElement({ + objectId: alias.getId(), + icon: "empty.png", + modelId: map.getId(), + type: "Alias" + })]); + }; + return map.renderOverlayCollection({ + overlayCollection: oc + }).then(function () { + var aliasMarkerCount = 0; + var markers = oc.markers["ALIAS"]; + for (var id in markers) { + if (markers.hasOwnProperty(id)) { + aliasMarkerCount++; + } + } + assert.equal(1, aliasMarkerCount); + }); }); - it("create polygon through drawingManager", function () { - var map = helper.createCustomMap(); - - map.setSelectionContextMenu(new SelectionContextMenu({ - customMap: map, - element: testDiv - })); - - map.turnOnDrawing(); - - var triangleCoords = [new google.maps.LatLng(25.774, -80.190), new google.maps.LatLng(18.466, -66.118), - new google.maps.LatLng(32.321, -64.757), new google.maps.LatLng(25.774, -80.190),]; - - // Construct the polygon. - var bermudaTriangle = new google.maps.Polygon({ - paths: triangleCoords, - strokeColor: '#FF0000', - strokeOpacity: 0.8, - strokeWeight: 2, - fillColor: '#FF0000', - fillOpacity: 0.35 - }); - bermudaTriangle.setMap(map.getGoogleMap()); - - var eventParam = { - type: google.maps.drawing.OverlayType.POLYGON, - overlay: bermudaTriangle, - }; + it("alias re-rendering with different icon", function () { + var map = helper.createCustomMap(); + var reaction = helper.createReaction(map); + var alias = helper.createAlias(map); + map.getModel().addAlias(alias); + map.getModel().addReaction(reaction); - // check creation complete behaviour - assert.ok(map.isDrawingOn()); - assert.equal(google.maps.drawing.OverlayType.POLYGON, map._drawingManager.getDrawingMode()); - google.maps.event.trigger(map._drawingManager, 'overlaycomplete', eventParam); - assert.ok(map.isDrawingOn()); - assert.equal(null, map._drawingManager.getDrawingMode()); - - // and now check how it behaves when we wiught click on the polygon - var clickEventParam = { - stop: null, - latLng: new google.maps.LatLng(40.0, -90.0) + var marker; + var oc = helper.createDbOverlay(map); + + oc.getIdentifiedElements = function () { + return Promise.resolve([new IdentifiedElement({ + objectId: alias.getId(), + icon: "empty.png", + modelId: map.getId(), + type: "Alias" + }), new IdentifiedElement(reaction)]); + }; + return map.renderOverlayCollection({ + overlayCollection: oc + }).then(function () { + marker = oc.markers["ALIAS"][alias.getId()]; + oc.getIdentifiedElements = function () { + return Promise.resolve([new IdentifiedElement({ + objectId: alias.getId(), + icon: "new_icon.png", + modelId: map.getId(), + type: "Alias" + })]); }; + assert.ok(oc.mapOverlays["REACTION"][reaction.getId()]); - assert.notOk(map.getSelectedPolygon()); - - assert.notOk(map.getActiveSubmapId()); - assert.notOk(map.getSelectedArea()); - google.maps.event.trigger(bermudaTriangle, 'rightclick', clickEventParam); - assert.ok(map.getSelectedArea()); - assert.equal(map.getId(), map.getActiveSubmapId()); - - assert.ok(map.getSelectedPolygon()); - - }); - - it("getAliasVisibleLayoutsData", function () { - var mockObject = helper.createCustomMap(); - - var alias = helper.createAlias(); - mockObject.getModel().addAlias(alias); - - var layout = helper.createLayout(); - layout.setInputDataAvailable(true); - layout.setInitialized(true); - mockObject.getModel().addLayout(layout); - - return mockObject.openDataOverlay(layout.getId()).then(function () { - return mockObject.getAliasVisibleLayoutsData(alias.getId()); - }).then(function (layoutAliases) { - assert.equal(layoutAliases.length, 1); - }); - }); - - it("changed coords in map", function () { - var map = helper.createCustomMap(); - var oldCenter = map.getGoogleMap().getCenter(); - var newCenter = new google.maps.LatLng(3, 87); - map.getGoogleMap().setCenter(newCenter); - google.maps.event.trigger(map.getGoogleMap(), "center_changed"); - - var center = ServerConnector.getSessionData(map.getProject()).getCenter(map.getModel()); - assert.ok(center !== oldCenter); - assert.ok(center instanceof google.maps.Point); - }); - - it("refreshComments", function () { - var map = helper.createCustomMap(); - map.getModel().setId(15781); - var commentsOverlay = helper.createCommentDbOverlay(map); - - ServerConnector.getSessionData().setShowComments(true); - return map.refreshComments().then(function () { - assert.notOk(commentsOverlay.markers["POINT"]['(241.01,372.35)']); - assert.ok(commentsOverlay.markers["POINT"]['(643.96,144.09)']); - assert.notOk(commentsOverlay.markers["POINT"]['(216.65,370.00)']); - assert.notOk(commentsOverlay.markers["POINT"]['unkId']); - }); - }); - - it("hide comments", function () { - var map = helper.createCustomMap(); - map.getModel().setId(15781); - var commentsOverlay = helper.createCommentDbOverlay(map); - - ServerConnector.getSessionData().setShowComments(true); - return map.refreshComments().then(function () { - ServerConnector.getSessionData().setShowComments(false); - return map.refreshComments(); - }).then(function () { - assert.notOk(commentsOverlay.markers["POINT"]['(241.01, 372.35)']); - }); - }); - - it("openCommentDialog", function () { - var map = helper.createCustomMap(); - map.getModel().setId(15781); - map.setActiveSubmapId(15781); - map.setActiveSubmapClickCoordinates(new google.maps.Point(2, 12)); - return map.openCommentDialog().then(function () { - var types = map.getCommentDialog().getTypes(); - assert.equal(types.length, 6); - var selected = map.getCommentDialog().getSelectedType(); - assert.ok(selected === "<General>"); - - map.getCommentDialog().setSelectedType(1); - selected = map.getCommentDialog().getSelectedType(); - assert.notOk(selected === "<General>"); - - map.getCommentDialog().setSelectedType(2); - selected = map.getCommentDialog().getSelectedType(); - assert.notOk(selected === "<General>"); - }).then(function () { - map.getCommentDialog().destroy(); + return map.renderOverlayCollection({ + overlayCollection: oc }); - }); + }).then(function () { + assert.equal(marker.getIcon(), "new_icon.png"); - it("addComment", function () { - var map; - return ServerConnector.getProject().then(function (project) { - map = helper.createCustomMap(project); - helper.createCommentDbOverlay(map); - map.setActiveSubmapId(map.getId()); - map.setActiveSubmapClickCoordinates(new google.maps.Point(2, 12)); - return map.openCommentDialog(); - }).then(function () { - return map.getCommentDialog().addComment(); - }).then(function () { - map.getCommentDialog().destroy(); - }); + assert.notOk(oc.mapOverlays["REACTION"][reaction.getId()]); + }); }); - it("addComment for protein", function () { - var map; - return ServerConnector.getProject().then(function (project) { - map = helper.createCustomMap(project); - helper.createCommentDbOverlay(map); - map.setActiveSubmapId(map.getId()); - map.setActiveSubmapClickCoordinates(new google.maps.Point(2, 12)); - return map.openCommentDialog(); - }).then(function () { - var dialog = map.getCommentDialog(); - dialog.setSelectedType(1); - return dialog.addComment(); - }).then(function () { - map.getCommentDialog().destroy(); - }); - }); + it("for set of aliases", function () { + var map = helper.createCustomMap(); - it("retrieveOverlayDetailDataForElement for comment", function () { - var map = helper.createCustomMap(); - helper.createCommentDbOverlay(map); + var oc = helper.createDbOverlay(map); + var identifiedElements = []; + for (var i = 0; i < 3; i++) { var alias = helper.createAlias(map); - alias.setId(329158); map.getModel().addAlias(alias); + var ie = helper.createIdentifiedElement(alias); + ie.setIcon(""); + identifiedElements.push(ie); + } + + oc.getIdentifiedElements = function () { + return Promise.resolve(identifiedElements); + }; + + return map.renderOverlayCollection({ + overlayCollection: oc + }).then(function () { + var aliasMarkerCount = 0; + var markers = oc.markers["ALIAS"]; + for (var id in markers) { + if (markers.hasOwnProperty(id)) { + aliasMarkerCount++; + } + } - var ie = new IdentifiedElement(alias); - - return map.retrieveOverlayDetailDataForElement(ie, { - comment: true - }).then(function (details) { - assert.ok(details); - assert.equal(details.length, 1); - assert.equal(details[0].length, 1); - assert.ok(details[0][0] instanceof Comment); - }); + assert.equal(aliasMarkerCount, 3); + }); }); - it("getOverlayDataForIdentifiedElement", function () { - var map = helper.createCustomMap(); - var commentOverlay = helper.createCommentDbOverlay(map); - - var alias = helper.createAlias(map); - alias.setId(329158); - map.getModel().addAlias(alias); - - var ie = new IdentifiedElement(alias); - - return map.getOverlayDataForIdentifiedElement(ie, { - comment: true - }).then(function (details) { - assert.equal(details.length, 1); + it("for point", function () { + var map = helper.createCustomMap(); - var overlayData = details[0]; - assert.equal(overlayData.overlay, commentOverlay); - assert.ok(overlayData.data); - assert.equal(overlayData.data.length, 1); - assert.ok(overlayData.data[0] instanceof Comment); - }); + var oc = helper.createDbOverlay(map); + + var javaObj = { + objectId: "Point2D.Double[117.685546875, 204.6923828125001]", + modelId: map.getId(), + type: "POINT", + icon: "marker/empty.png" + }; + + oc.getIdentifiedElements = function () { + return Promise.resolve([new IdentifiedElement(javaObj)]); + }; + + return map.renderOverlayCollection({ + overlayCollection: oc + }).then(function () { + var markerCount = 0; + var markers = oc.markers["POINT"]; + for (var id in markers) { + if (markers.hasOwnProperty(id)) { + markerCount++; + } + } + assert.equal(1, markerCount); + }); }); - it("openSubmap", function () { - var options = helper.createCustomMapOptions(); - - var submodel = helper.createModel(); - options.getProject().getModel().addSubmodel(submodel); + it("for reaction", function () { + var map = helper.createCustomMap(); + var reaction = helper.createReaction(); + map.getModel().addReaction(reaction); - var map = new CustomMap(options); + var oc = helper.createDbOverlay(map); + + var javaObj = { + objectId: reaction.getId(), + modelId: map.getId(), + type: "Reaction", + }; + + oc.getIdentifiedElements = function () { + return Promise.resolve([new IdentifiedElement(javaObj)]); + }; + + return map.renderOverlayCollection({ + overlayCollection: oc + }).then(function () { + var markerCount = 0; + var markers = oc.mapOverlays["REACTION"]; + for (var id in markers) { + if (markers.hasOwnProperty(id)) { + markerCount++; + } + } + assert.equal(1, markerCount); + }); + }); + }); + + it("clearDbOverlays", function () { + var map = helper.createCustomMap(); + + var oc = helper.createDbOverlay(map); + + var javaObj = { + objectId: "Point2D.Double[117.685546875, 204.6923828125001]", + modelId: map.getId(), + type: "POINT", + icon: "marker/empty.png" + }; + var searchResults = [new IdentifiedElement(javaObj)]; + + oc.getIdentifiedElements = function () { + return Promise.resolve(searchResults); + }; + oc.clear = function () { + searchResults = []; + return this.callListeners("onSearch", searchResults); + }; + + return map.renderOverlayCollection({ + overlayCollection: oc + }).then(function () { + + return map.clearDbOverlays(); + }).then(function () { + var markerCount = 0; + for (var id in oc.pointMarkers) { + if (oc.pointMarkers.hasOwnProperty(id)) { + markerCount++; + } + } - map.openSubmap(submodel.getId()); - map.destroy(); + assert.equal(0, markerCount); }); - describe("setCenter", function () { - it("default", function () { - var options = helper.createCustomMapOptions(); + }); - var map = new CustomMap(options); + it("getInfoWindowForIdentifiedElement ( reaction)", function () { + var map = helper.createCustomMap(); + var reaction = helper.createReaction(map); + map.getModel().addReaction(reaction); - map.setCenter(new google.maps.LatLng(10, 20)); - assert.ok(ServerConnector.getSessionData().getCenter(map.getModel())); - }); + var ie = helper.createIdentifiedElement(reaction); - it("on submap", function () { - var options = helper.createCustomMapOptions(); + var infoWindow = map.getInfoWindowForIdentifiedElement(ie); - var submodel = helper.createModel(); - options.getProject().getModel().addSubmodel(submodel); + assert.equal(null, infoWindow); + return map._openInfoWindowForReaction(reaction).then(function () { + infoWindow = map.getInfoWindowForIdentifiedElement(ie); - var map = new CustomMap(options); - map.openSubmap(submodel.getId()); - map.setCenter(new google.maps.LatLng(10, 20)); - assert.ok(ServerConnector.getSessionData().getCenter(submodel)); - map.destroy(); - }); + assert.ok(infoWindow); }); - it("setZoom", function () { - var options = helper.createCustomMapOptions(); + }); - var map = new CustomMap(options); + it("right click on map", function () { + var map = helper.createCustomMap(); + map.setContextMenu(new MapContextMenu({ + customMap: map, + element: testDiv + })); - map.setZoom(3); - assert.equal(3, ServerConnector.getSessionData().getZoomLevel(map.getModel())); - }); + var mev = { + stop: null, + latLng: new google.maps.LatLng(40.0, -90.0) + }; - it("removeSelection when invalid model selected", function () { - var options = helper.createCustomMapOptions(); + assert.notOk(map.getActiveSubmapId()); + google.maps.event.trigger(map.getGoogleMap(), 'rightclick', mev); + assert.equal(map.getId(), map.getActiveSubmapId()); - var map = new CustomMap(options); - map.setActiveSubmapId(-1); + }); - try { - map.removeSelection(); - assert.ok(false); - } catch (e) { - assert.ok(e.message.indexOf("Cannot find submap") >= 0); - } - }); - - it("removeSelection", function () { - var options = helper.createCustomMapOptions(); - - var map = new CustomMap(options); - map.setActiveSubmapId(map.getId()); - map.setSelectedArea(new google.maps.Rectangle({})); - - map.removeSelection(); - assert.equal(map.getSelectedArea(), null); - }); - - describe("createMarkerForDbOverlay", function () { - it("update marker", function () { - var map; - var marker1, marker2; - var element = new IdentifiedElement({ - id: 329159, - modelId: 15781, - type: "ALIAS" - }); - var overlay; - return ServerConnector.getProject().then(function (project) { - var options = helper.createCustomMapOptions(project); - map = new CustomMap(options); - overlay = helper.createDbOverlay(map); - return map.createMarkerForDbOverlay(element, overlay); - }).then(function (result) { - marker1 = result; - element.setIcon("another.png"); - return map.createMarkerForDbOverlay(element, overlay); - }).then(function (result) { - marker2 = result; - assert.equal(marker1, marker2); - }); - }); + it("left click on map", function () { + var map; + var searchOverlay; + return ServerConnector.getProject().then(function (project) { + map = helper.createCustomMap(project); + searchOverlay = helper.createSearchDbOverlay(map); - it("update surface", function () { - var map; - var marker1, marker2; - var element = new IdentifiedElement({ - id: 329159, - modelId: 15781, - type: "ALIAS" - }); - var overlay; - return ServerConnector.getProject().then(function (project) { - var options = helper.createCustomMapOptions(project); - map = new CustomMap(options); - overlay = helper.createDbOverlay(map); - return map.createSurfaceForDbOverlay(element, overlay); - }).then(function (result) { - marker1 = result; - element.setColor("another.png"); - return map.createSurfaceForDbOverlay(element, overlay); - }).then(function (result) { - marker2 = result; - assert.equal(marker1, marker2); - }); - }); + var mev = { + stop: null, + latLng: new google.maps.LatLng(82.32061703407554, -167.25586206896548), + }; + map.getGoogleMap().setZoom(4); + // latLng : new google.maps.LatLng(82.40238643645326, -148.44758620689652) - it("reaction marker", function () { - var map; - var element = new IdentifiedElement({ - id: 153508, - modelId: 15781, - type: "REACTION" - }); - var overlay; - return ServerConnector.getProject().then(function (project) { - var options = helper.createCustomMapOptions(project); - map = new CustomMap(options); - overlay = helper.createDbOverlay(map); - return map.createMarkerForDbOverlay(element, overlay); - }).then(function (result) { - assert.ok(result.getReactionData()); - }); - }); + assert.notOk(map.getActiveSubmapId()); + return google.maps.event.trigger(map.getGoogleMap(), 'click', mev); + }).then(function () { + assert.equal(map.getId(), map.getActiveSubmapId()); + assert.ok(searchOverlay.markers["ALIAS"][329171]); }); - describe("_openInfoWindowForIdentifiedElement", function () { - it("for AliasMarker", function () { - var map; - var alias, marker; - return ServerConnector.getProject().then(function (project) { - map = helper.createCustomMap(project); - return map.getModel().getAliasById(329171); - }).then(function (result) { - alias = result; - - var identifiedElement = new IdentifiedElement(alias); - identifiedElement.setIcon("empty.png"); + }); - marker = new AliasMarker({ - element: identifiedElement, - map: map - }); + it("left click on reaction", function () { + var map; + var searchOverlay; + return ServerConnector.getProject().then(function (project) { + map = helper.createCustomMap(project); + searchOverlay = helper.createSearchDbOverlay(map); - return marker.init(); - }).then(function () { - assert.equal(null, map.getAliasInfoWindowById(alias.getId())); - return map._openInfoWindowForIdentifiedElement(marker).then(function () { - assert.ok(map.getAliasInfoWindowById(alias.getId())); - }); - }); - - }); - it("for ReactionMarker", function () { - var map; - var reaction, marker; - return ServerConnector.getProject().then(function (project) { - map = helper.createCustomMap(project); - return map.getModel().getReactionById(153510); - }).then(function (result) { - reaction = result; - - marker = new ReactionMarker({ - element: new IdentifiedElement(reaction), - map: map - }); - return marker.init(); - }).then(function () { - assert.equal(null, map.getReactionInfoWindowById(reaction.getId())); - return map._openInfoWindowForIdentifiedElement(marker); - }).then(function () { - assert.ok(map.getReactionInfoWindowById(reaction.getId())); - }); + var mev = { + stop: null, + latLng: new google.maps.LatLng(82.40238643645326, -148.44758620689652) + }; + map.getGoogleMap().setZoom(4); - }); - it("for PointMarker", function () { + assert.notOk(map.getActiveSubmapId()); + return google.maps.event.trigger(map.getGoogleMap(), 'click', mev); + }).then(function () { + assert.equal(map.getId(), map.getActiveSubmapId()); + assert.ok(searchOverlay.mapOverlays["REACTION"][153521]); + assert.ok(searchOverlay.mapOverlays["REACTION"][153521].isShown()); + assert.ok(searchOverlay.markers["ALIAS"][329165]); + }); + }); - var mockObject = helper.createCustomMap(); + it("create polygon through drawingManager", function () { + var map = helper.createCustomMap(); - mockObject.getOverlayDataForPoint = function () { - return Promise.resolve([]); - }; + map.setSelectionContextMenu(new SelectionContextMenu({ + customMap: map, + element: testDiv + })); - var point = new google.maps.Point(2, 3.45); - var pointData = new PointData(point, mockObject.getId()); + map.turnOnDrawing(); - var pointMarker = new PointMarker({ - element: new IdentifiedElement(pointData), - map: mockObject - }); + var triangleCoordinates = [new google.maps.LatLng(25.774, -80.190), new google.maps.LatLng(18.466, -66.118), + new google.maps.LatLng(32.321, -64.757), new google.maps.LatLng(25.774, -80.190),]; - return pointMarker.init().then(function () { - assert.equal(null, mockObject.getPointInfoWindowById(pointData.getId())); - return mockObject._openInfoWindowForIdentifiedElement(pointMarker.getIdentifiedElement()); - }).then(function () { - assert.ok(mockObject.getPointInfoWindowById(pointData.getId())); - }); - }); - }); + // Construct the polygon. + var bermudaTriangle = new google.maps.Polygon({ + paths: triangleCoordinates, + strokeColor: '#FF0000', + strokeOpacity: 0.8, + strokeWeight: 2, + fillColor: '#FF0000', + fillOpacity: 0.35 + }); + bermudaTriangle.setMap(map.getGoogleMap()); + + var eventParam = { + type: google.maps.drawing.OverlayType.POLYGON, + overlay: bermudaTriangle, + }; + + // check creation complete behaviour + assert.ok(map.isDrawingOn()); + assert.equal(google.maps.drawing.OverlayType.POLYGON, map._drawingManager.getDrawingMode()); + google.maps.event.trigger(map._drawingManager, 'overlaycomplete', eventParam); + assert.ok(map.isDrawingOn()); + assert.equal(null, map._drawingManager.getDrawingMode()); + + // and now check how it behaves when we click on the polygon + var clickEventParam = { + stop: null, + latLng: new google.maps.LatLng(40.0, -90.0) + }; + + assert.notOk(map.getSelectedPolygon()); + + assert.notOk(map.getActiveSubmapId()); + assert.notOk(map.getSelectedArea()); + google.maps.event.trigger(bermudaTriangle, 'rightclick', clickEventParam); + assert.ok(map.getSelectedArea()); + assert.equal(map.getId(), map.getActiveSubmapId()); + + assert.ok(map.getSelectedPolygon()); + + }); + + it("getAliasVisibleLayoutsData", function () { + var mockObject = helper.createCustomMap(); + + var alias = helper.createAlias(); + mockObject.getModel().addAlias(alias); + + var layout = helper.createLayout(); + layout.setInputDataAvailable(true); + layout.setInitialized(true); + mockObject.getModel().addLayout(layout); + + return mockObject.openDataOverlay(layout.getId()).then(function () { + return mockObject.getAliasVisibleLayoutsData(alias.getId()); + }).then(function (layoutAliases) { + assert.equal(layoutAliases.length, 1); + }); + }); + + it("changed coordinates in map", function () { + var map = helper.createCustomMap(); + var oldCenter = map.getGoogleMap().getCenter(); + var newCenter = new google.maps.LatLng(3, 87); + map.getGoogleMap().setCenter(newCenter); + google.maps.event.trigger(map.getGoogleMap(), "center_changed"); + + var center = ServerConnector.getSessionData(map.getProject()).getCenter(map.getModel()); + assert.ok(center !== oldCenter); + assert.ok(center instanceof google.maps.Point); + }); + + it("refreshComments", function () { + var map = helper.createCustomMap(); + map.getModel().setId(15781); + var commentsOverlay = helper.createCommentDbOverlay(map); + + ServerConnector.getSessionData().setShowComments(true); + return map.refreshComments().then(function () { + assert.notOk(commentsOverlay.markers["POINT"]['(241.01,372.35)']); + assert.ok(commentsOverlay.markers["POINT"]['(643.96,144.09)']); + assert.notOk(commentsOverlay.markers["POINT"]['(216.65,370.00)']); + assert.notOk(commentsOverlay.markers["POINT"]['unkId']); + }); + }); + + it("hide comments", function () { + var map = helper.createCustomMap(); + map.getModel().setId(15781); + var commentsOverlay = helper.createCommentDbOverlay(map); + + ServerConnector.getSessionData().setShowComments(true); + return map.refreshComments().then(function () { + ServerConnector.getSessionData().setShowComments(false); + return map.refreshComments(); + }).then(function () { + assert.notOk(commentsOverlay.markers["POINT"]['(241.01, 372.35)']); + }); + }); + + it("openCommentDialog", function () { + var map = helper.createCustomMap(); + map.getModel().setId(15781); + map.setActiveSubmapId(15781); + map.setActiveSubmapClickCoordinates(new google.maps.Point(2, 12)); + return map.openCommentDialog().then(function () { + var types = map.getCommentDialog().getTypes(); + assert.equal(types.length, 6); + var selected = map.getCommentDialog().getSelectedType(); + assert.ok(selected === "<General>"); + + map.getCommentDialog().setSelectedType(1); + selected = map.getCommentDialog().getSelectedType(); + assert.notOk(selected === "<General>"); + + map.getCommentDialog().setSelectedType(2); + selected = map.getCommentDialog().getSelectedType(); + assert.notOk(selected === "<General>"); + }).then(function () { + map.getCommentDialog().destroy(); + }); + }); + + it("addComment", function () { + var map; + return ServerConnector.getProject().then(function (project) { + map = helper.createCustomMap(project); + helper.createCommentDbOverlay(map); + map.setActiveSubmapId(map.getId()); + map.setActiveSubmapClickCoordinates(new google.maps.Point(2, 12)); + return map.openCommentDialog(); + }).then(function () { + return map.getCommentDialog().addComment(); + }).then(function () { + map.getCommentDialog().destroy(); + }); + }); + + it("addComment for protein", function () { + var map; + return ServerConnector.getProject().then(function (project) { + map = helper.createCustomMap(project); + helper.createCommentDbOverlay(map); + map.setActiveSubmapId(map.getId()); + map.setActiveSubmapClickCoordinates(new google.maps.Point(2, 12)); + return map.openCommentDialog(); + }).then(function () { + var dialog = map.getCommentDialog(); + dialog.setSelectedType(1); + return dialog.addComment(); + }).then(function () { + map.getCommentDialog().destroy(); + }); + }); + + it("retrieveOverlayDetailDataForElement for comment", function () { + var map = helper.createCustomMap(); + helper.createCommentDbOverlay(map); + + var alias = helper.createAlias(map); + alias.setId(329158); + map.getModel().addAlias(alias); + + var ie = new IdentifiedElement(alias); + + return map.retrieveOverlayDetailDataForElement(ie, { + comment: true + }).then(function (details) { + assert.ok(details); + assert.equal(details.length, 1); + assert.equal(details[0].length, 1); + assert.ok(details[0][0] instanceof Comment); + }); + }); + + it("getOverlayDataForIdentifiedElement", function () { + var map = helper.createCustomMap(); + var commentOverlay = helper.createCommentDbOverlay(map); + + var alias = helper.createAlias(map); + alias.setId(329158); + map.getModel().addAlias(alias); + + var ie = new IdentifiedElement(alias); + + return map.getOverlayDataForIdentifiedElement(ie, { + comment: true + }).then(function (details) { + assert.equal(details.length, 1); + + var overlayData = details[0]; + assert.equal(overlayData.overlay, commentOverlay); + assert.ok(overlayData.data); + assert.equal(overlayData.data.length, 1); + assert.ok(overlayData.data[0] instanceof Comment); + }); + }); + + it("openSubmap", function () { + var options = helper.createCustomMapOptions(); + + var submodel = helper.createModel(); + options.getProject().getModel().addSubmodel(submodel); + + var map = new CustomMap(options); + + map.openSubmap(submodel.getId()); + map.destroy(); + }); + + describe("setCenter", function () { + it("default", function () { + var options = helper.createCustomMapOptions(); + + var map = new CustomMap(options); + + map.setCenter(new google.maps.LatLng(10, 20)); + assert.ok(ServerConnector.getSessionData().getCenter(map.getModel())); + }); + + it("on submap", function () { + var options = helper.createCustomMapOptions(); + + var submodel = helper.createModel(); + options.getProject().getModel().addSubmodel(submodel); + + var map = new CustomMap(options); + map.openSubmap(submodel.getId()); + map.setCenter(new google.maps.LatLng(10, 20)); + assert.ok(ServerConnector.getSessionData().getCenter(submodel)); + map.destroy(); + }); + }); + + it("setZoom", function () { + var options = helper.createCustomMapOptions(); + + var map = new CustomMap(options); + + map.setZoom(3); + assert.equal(3, ServerConnector.getSessionData().getZoomLevel(map.getModel())); + }); + + it("removeSelection when invalid model selected", function () { + var options = helper.createCustomMapOptions(); + + var map = new CustomMap(options); + map.setActiveSubmapId(-1); + + try { + map.removeSelection(); + assert.ok(false); + } catch (e) { + assert.ok(e.message.indexOf("Cannot find submap") >= 0); + } + }); + + it("removeSelection", function () { + var options = helper.createCustomMapOptions(); + + var map = new CustomMap(options); + map.setActiveSubmapId(map.getId()); + map.setSelectedArea(new google.maps.Rectangle({})); + + map.removeSelection(); + assert.equal(map.getSelectedArea(), null); + }); + + describe("createMarkerForDbOverlay", function () { + it("update marker", function () { + var map; + var marker1, marker2; + var element = new IdentifiedElement({ + id: 329159, + modelId: 15781, + type: "ALIAS" + }); + var overlay; + return ServerConnector.getProject().then(function (project) { + var options = helper.createCustomMapOptions(project); + map = new CustomMap(options); + overlay = helper.createDbOverlay(map); + return map.createMarkerForDbOverlay(element, overlay); + }).then(function (result) { + marker1 = result; + element.setIcon("another.png"); + return map.createMarkerForDbOverlay(element, overlay); + }).then(function (result) { + marker2 = result; + assert.equal(marker1, marker2); + }); + }); + + it("update surface", function () { + var map; + var marker1, marker2; + var element = new IdentifiedElement({ + id: 329159, + modelId: 15781, + type: "ALIAS" + }); + var overlay; + return ServerConnector.getProject().then(function (project) { + var options = helper.createCustomMapOptions(project); + map = new CustomMap(options); + overlay = helper.createDbOverlay(map); + return map.createSurfaceForDbOverlay(element, overlay); + }).then(function (result) { + marker1 = result; + element.setColor("another.png"); + return map.createSurfaceForDbOverlay(element, overlay); + }).then(function (result) { + marker2 = result; + assert.equal(marker1, marker2); + }); + }); + + it("reaction marker", function () { + var map; + var element = new IdentifiedElement({ + id: 153508, + modelId: 15781, + type: "REACTION" + }); + var overlay; + return ServerConnector.getProject().then(function (project) { + var options = helper.createCustomMapOptions(project); + map = new CustomMap(options); + overlay = helper.createDbOverlay(map); + return map.createMarkerForDbOverlay(element, overlay); + }).then(function (result) { + assert.ok(result.getReactionData()); + }); + }); + + }); + + describe("_openInfoWindowForIdentifiedElement", function () { + it("for AliasMarker", function () { + var map; + var alias, marker; + return ServerConnector.getProject().then(function (project) { + map = helper.createCustomMap(project); + return map.getModel().getAliasById(329171); + }).then(function (result) { + alias = result; + + var identifiedElement = new IdentifiedElement(alias); + identifiedElement.setIcon("empty.png"); + + marker = new AliasMarker({ + element: identifiedElement, + map: map + }); + + return marker.init(); + }).then(function () { + assert.equal(null, map.getAliasInfoWindowById(alias.getId())); + return map._openInfoWindowForIdentifiedElement(marker).then(function () { + assert.ok(map.getAliasInfoWindowById(alias.getId())); + }); + }); + + }); + it("for ReactionMarker", function () { + var map; + var reaction, marker; + return ServerConnector.getProject().then(function (project) { + map = helper.createCustomMap(project); + return map.getModel().getReactionById(153510); + }).then(function (result) { + reaction = result; + + marker = new ReactionMarker({ + element: new IdentifiedElement(reaction), + map: map + }); + return marker.init(); + }).then(function () { + assert.equal(null, map.getReactionInfoWindowById(reaction.getId())); + return map._openInfoWindowForIdentifiedElement(marker); + }).then(function () { + assert.ok(map.getReactionInfoWindowById(reaction.getId())); + }); + + }); + it("for PointMarker", function () { + + var mockObject = helper.createCustomMap(); + + mockObject.getOverlayDataForPoint = function () { + return Promise.resolve([]); + }; + + var point = new google.maps.Point(2, 3.45); + var pointData = new PointData(point, mockObject.getId()); + + var pointMarker = new PointMarker({ + element: new IdentifiedElement(pointData), + map: mockObject + }); + + return pointMarker.init().then(function () { + assert.equal(null, mockObject.getPointInfoWindowById(pointData.getId())); + return mockObject._openInfoWindowForIdentifiedElement(pointMarker.getIdentifiedElement()); + }).then(function () { + assert.ok(mockObject.getPointInfoWindowById(pointData.getId())); + }); + }); + }); }); diff --git a/frontend-js/src/test/js/map/CustomMapOptions-test.js b/frontend-js/src/test/js/map/CustomMapOptions-test.js index 65bbdbc213..04e4f6d273 100644 --- a/frontend-js/src/test/js/map/CustomMapOptions-test.js +++ b/frontend-js/src/test/js/map/CustomMapOptions-test.js @@ -5,50 +5,53 @@ var chai = require('chai'); var assert = chai.assert; var logger = require('../logger'); -describe('CustomMapOptions', function() { - it("contructor with invalid arg", function() { - try { - new CustomMapOptions({ - markerOptimization : 12, - bigLogo : "some strange string", - hideDiv : "some div ide", - customTouchInterface : "strange param", - debug : "unk boolean" - }); - assert.ok(false); - } catch (exception) { - assert.ok(exception.message.indexOf("element must be defined") >= 0); - } - }); +describe('CustomMapOptions', function () { + describe("constructor", function () { + it("with invalid arg", function () { + try { + new CustomMapOptions({ + markerOptimization: 12, + bigLogo: "some strange string", + hideDiv: "some div ide", + customTouchInterface: "strange param", + debug: "unk boolean" + }); + assert.ok(false); + } catch (exception) { + assert.ok(exception.message.indexOf("element must be defined") >= 0); + } + }); + it("with invalid arg 3", function () { + try { + new CustomMapOptions({ + element: testDiv, + }); + } catch (exception) { + assert.ok(exception.message.indexOf("project must be defined") >= 0); + } + }); - it("contructor with invalid arg 3", function() { - try { + it("with valid arg 2", function () { + var project = helper.createProject(); new CustomMapOptions({ - element : testDiv, + element: testDiv, + project: project, + debug: false, }); - } catch (exception) { - assert.ok(exception.message.indexOf("project must be defined") >= 0); - } - }); - it("contructor with valid arg 2", function() { - var project = helper.createProject(); - new CustomMapOptions({ - element : testDiv, - project : project, - debug : false, + assert.equal(0, logger.getErrors().length); + assert.equal(0, logger.getWarnings().length); }); - assert.equal(0, logger.getErrors().length); - assert.equal(0, logger.getWarnings().length); }); - - it("getDebug", function() { + + + it("getDebug", function () { var project = helper.createProject(); var options = new CustomMapOptions({ - element : testDiv, - project : project, - debug : true, + element: testDiv, + project: project, + debug: true, }); assert.ok(options.isDebug()); diff --git a/frontend-js/src/test/js/map/Submap-test.js b/frontend-js/src/test/js/map/Submap-test.js index 2adb8b24ec..8a20f0c9da 100644 --- a/frontend-js/src/test/js/map/Submap-test.js +++ b/frontend-js/src/test/js/map/Submap-test.js @@ -9,7 +9,7 @@ var chai = require('chai'); var assert = chai.assert; describe('Submap', function() { - it("simple contructor", function() { + it("simple constructor", function() { var map = helper.createCustomMap(); var model = helper.createModel(); diff --git a/frontend-js/src/test/js/map/data/Alias-test.js b/frontend-js/src/test/js/map/data/Alias-test.js index afdfc51f59..ec4404357e 100644 --- a/frontend-js/src/test/js/map/data/Alias-test.js +++ b/frontend-js/src/test/js/map/data/Alias-test.js @@ -5,123 +5,126 @@ var chai = require('chai'); var assert = chai.assert; var logger = require('../../logger'); -describe('Alias', function() { - beforeEach(function() { +describe('Alias', function () { + beforeEach(function () { logger.flushBuffer(); }); - it("contructor with invalid arg", function() { - try { - new Alias({}); - assert.ok(null); - } catch (exception) { - assert.ok(exception.message.indexOf("ModelId is not defined") >= 0); - } - }); + describe("constructor", function () { + it("with invalid arg", function () { + try { + new Alias({}); + assert.ok(null); + } catch (exception) { + assert.ok(exception.message.indexOf("ModelId is not defined") >= 0); + } + }); + it("simple", function () { + var javaObject = { + bounds: { + x: 190, + y: 44, + width: 80, + height: 40 + }, + modelId: 57, + idObject: 18554 + }; + var alias = new Alias(javaObject); + assert.equal(alias.isComplete(), false); + assert.equal(null, alias.name); + assert.equal(alias.getX(), 190); + }); + it("complex", function () { + var javaObject = { + notes: "", + type: "Protein", + name: "s1", + synonyms: [], + formerSymbols: [], + references: [], + other: [], + bounds: { + x: 59, + y: 73, + width: 80, + height: 40 + }, + modelId: 54, + idObject: 18552 + }; + var alias = new Alias(javaObject); + assert.ok(alias.isComplete()); + assert.equal('s1', alias.name); + }); - it("Alias simple contructor", function() { - var javaObject = { - bounds : { - x : 190, - y : 44, - width : 80, - height : 40 - }, - modelId : 57, - idObject : 18554 - }; - var alias = new Alias(javaObject); - assert.equal(alias.isComplete(), false); - assert.equal(null, alias.name); - assert.equal(alias.getX(), 190); }); - it("Alias update method", function() { + + it("Alias update method", function () { var javaObject = { - bounds : { - x : 190, - y : 44, - width : 80, - height : 40 + bounds: { + x: 190, + y: 44, + width: 80, + height: 40 }, - modelId : 57, - idObject : 18554 + modelId: 57, + idObject: 18554 }; var alias = new Alias(javaObject); var javaObject2 = { - notes : "", - type : "Protein", - name : "s1", - synonyms : [], - formerSymbols : [], - references : [], - other : [], - bounds : { - x : 59, - y : 73, - width : 80, - height : 40 + notes: "", + type: "Protein", + name: "s1", + synonyms: [], + formerSymbols: [], + references: [], + other: [], + bounds: { + x: 59, + y: 73, + width: 80, + height: 40 }, - modelId : 54, - idObject : 18552 + modelId: 54, + idObject: 18552 }; alias.update(javaObject2); assert.ok(alias.isComplete()); assert.equal('s1', alias.name); }); - it("Alias update method 2", function() { + it("Alias update method 2", function () { var javaObject = { - bounds : { - x : 190, - y : 44, - width : 80, - height : 40 + bounds: { + x: 190, + y: 44, + width: 80, + height: 40 }, - modelId : 57, - idObject : 18554 + modelId: 57, + idObject: 18554 }; var alias = new Alias(javaObject); var javaObject2 = { - notes : "", - type : "Protein", - synonyms : [], - formerSymbols : [], - references : [], - other : [], - bounds : { - x : 59, - y : 73, - width : 80, - height : 40 + notes: "", + type: "Protein", + synonyms: [], + formerSymbols: [], + references: [], + other: [], + bounds: { + x: 59, + y: 73, + width: 80, + height: 40 }, - modelId : 54, - idObject : 18552 + modelId: 54, + idObject: 18552 }; alias.update(javaObject2); assert.equal(alias.isComplete(), false); }); - it("Alias complex contructor", function() { - var javaObject = { - notes : "", - type : "Protein", - name : "s1", - synonyms : [], - formerSymbols : [], - references : [], - other : [], - bounds : { - x : 59, - y : 73, - width : 80, - height : 40 - }, - modelId : 54, - idObject : 18552 - }; - var alias = new Alias(javaObject); - assert.ok(alias.isComplete()); - assert.equal('s1', alias.name); - }); }); diff --git a/frontend-js/src/test/js/map/data/GeneVariant-test.js b/frontend-js/src/test/js/map/data/GeneVariant-test.js index a776ad9f68..de7f1fa518 100644 --- a/frontend-js/src/test/js/map/data/GeneVariant-test.js +++ b/frontend-js/src/test/js/map/data/GeneVariant-test.js @@ -4,7 +4,7 @@ var GeneVariant = require('../../../../main/js/map/data/GeneVariant'); var assert = require('assert'); describe('GeneVariant', function() { - it("contructor", function() { + it("constructor", function() { var data = { position : 12, originalDna : "A", diff --git a/frontend-js/src/test/js/map/data/IdentifiedElement-test.js b/frontend-js/src/test/js/map/data/IdentifiedElement-test.js index 755f32394c..271f40c60f 100644 --- a/frontend-js/src/test/js/map/data/IdentifiedElement-test.js +++ b/frontend-js/src/test/js/map/data/IdentifiedElement-test.js @@ -11,163 +11,167 @@ var chai = require('chai'); var assert = chai.assert; var expect = chai.expect; -describe('IdentifiedElement', function() { - beforeEach(function() { +describe('IdentifiedElement', function () { + beforeEach(function () { logger.flushBuffer(); }); - it("simple contructor", function() { - var javaObj = { - objectId : "31165", - modelId : 269, - type : "alias", - icon : "marker/marker/marker_red_1.png" - }; - var ie = new IdentifiedElement(javaObj); - assert.ok(ie); - assert.equal(31165, ie.getId()); - assert.equal(269, ie.getModelId()); - assert.equal("ALIAS", ie.getType()); - assert.equal("marker/marker/marker_red_1.png", ie.getIcon()); + describe("constructor", function () { + it("simple", function () { + var javaObj = { + objectId: "31165", + modelId: 269, + type: "alias", + icon: "marker/marker/marker_red_1.png" + }; + var ie = new IdentifiedElement(javaObj); + assert.ok(ie); + assert.equal(31165, ie.getId()); + assert.equal(269, ie.getModelId()); + assert.equal("ALIAS", ie.getType()); + assert.equal("marker/marker/marker_red_1.png", ie.getIcon()); + }); + + it("from point", function () { + var javaObj = { + objectId: "Point2D.Double[117.685546875, 204.6923828125001]", + modelId: 269, + type: "POINT", + icon: "icons/comment.png" + }; + var ie = new IdentifiedElement(javaObj); + assert.ok(ie); + assert.ok(ie.getPoint()); + }); + + it("from point 2", function () { + var javaObj = { + objectId: "(117.685546875, 204.6923828125001)", + modelId: 269, + type: "POINT", + icon: "empty.png" + }; + var ie = new IdentifiedElement(javaObj); + assert.ok(ie); + assert.ok(ie.getPoint()); + }); + it("from alias", function () { + var jsonString = '{"bounds":{"x":190,"y":44,"width":80,"height":40},"modelId":57,"idObject":18554}'; + var javaObject = JSON.parse(jsonString); + var alias = new Alias(javaObject); + var ie = new IdentifiedElement(alias); + assert.ok(ie); + assert.equal(ie.getType(), "ALIAS"); + }); + + it("from Reaction", function () { + var javaObject = { + lines: [{ + start: Object, + end: Object, + type: "START" + }, { + start: Object, + end: Object, + type: "END" + }, { + start: Object, + end: Object, + type: "MIDDLE" + }], + modelId: 319, + idObject: "13178", + centerPoint: {} + }; + var reaction = new Reaction(javaObject); + + var ie = new IdentifiedElement(reaction); + assert.ok(ie); + assert.equal(ie.getType(), "REACTION"); + }); + + it("from invalid object", function () { + var javaObject = { + modelId: 2 + }; + var code = function () { + new IdentifiedElement(javaObject); + }; + assert.throws(code, new RegExp("Type not defined")); + }); + + it("from PointData", function () { + var modelId = 3; + var point = new google.maps.Point(2, 3.45); + var pointData = new PointData(point, modelId); + + var ie = new IdentifiedElement(pointData); + assert.ok(ie); + assert.equal(ie.getType(), "POINT"); + }); + + it("from invalid object 2", function () { + var javaObject = { + modelId: 2, + type: "unk_type" + }; + var code = function () { + new IdentifiedElement(javaObject); + }; + assert.throws(code, new RegExp("Unknown type")); + }); + + it("from invalid object 3", function () { + var javaObject = { + type: "alias", + objectId: "el_id" + }; + var code = function () { + new IdentifiedElement(javaObject); + }; + assert.throws(code, new RegExp("ModelId is invalid")); + }); + + it("from invalid object 4", function () { + var javaObject = { + type: "alias", + modelId: 4, + }; + var code = function () { + new IdentifiedElement(javaObject); + }; + assert.throws(code, new RegExp("Id not defined")); + }); + + it("from artificial obj", function () { + var javaObject = { + type: "alias", + objectId: "el_id", + modelId: "m_id" + }; + var ie = new IdentifiedElement(javaObject); + var point = ie.getPoint(); + expect(point).to.equal(null); + assert.equal(logger.getWarnings().length, 1); + }); + }); - it("equals", function() { + it("equals", function () { var javaObj = { - objectId : "31165", - modelId : 269, - type : "alias" + objectId: "31165", + modelId: 269, + type: "alias" }; var ie = new IdentifiedElement(javaObj); var ie2 = new IdentifiedElement(javaObj); - + var ie3 = helper.createIdentifiedElement(); - + assert.ok(ie.equals(ie)); assert.ok(ie.equals(ie2)); assert.notOk(ie.equals(ie3)); - - }); - it("point contructor", function() { - var javaObj = { - objectId : "Point2D.Double[117.685546875, 204.6923828125001]", - modelId : 269, - type : "POINT", - icon : "icons/comment.png" - }; - var ie = new IdentifiedElement(javaObj); - assert.ok(ie); - assert.ok(ie.getPoint()); }); - it("point contructor 2", function() { - var javaObj = { - objectId : "(117.685546875, 204.6923828125001)", - modelId : 269, - type : "POINT", - icon : "empty.png" - }; - var ie = new IdentifiedElement(javaObj); - assert.ok(ie); - assert.ok(ie.getPoint()); - }); - it("contructor from alias", function() { - var jsonString = '{"bounds":{"x":190,"y":44,"width":80,"height":40},"modelId":57,"idObject":18554}'; - var javaObject = JSON.parse(jsonString); - var alias = new Alias(javaObject); - var ie = new IdentifiedElement(alias); - assert.ok(ie); - assert.equal(ie.getType(), "ALIAS"); - }); - - it("contructor from Reaction", function() { - var javaObject = { - lines : [ { - start : Object, - end : Object, - type : "START" - }, { - start : Object, - end : Object, - type : "END" - }, { - start : Object, - end : Object, - type : "MIDDLE" - } ], - modelId : 319, - idObject : "13178", - centerPoint : {} - }; - var reaction = new Reaction(javaObject); - - var ie = new IdentifiedElement(reaction); - assert.ok(ie); - assert.equal(ie.getType(), "REACTION"); - }); - - it("contructor from invalid object", function() { - var javaObject = { - modelId : 2 - }; - var code = function() { - new IdentifiedElement(javaObject); - }; - assert.throws(code, new RegExp("Type not defined")); - }); - - it("contructor from PointData", function() { - var modelId = 3; - var point = new google.maps.Point(2, 3.45); - var pointData = new PointData(point, modelId); - - var ie = new IdentifiedElement(pointData); - assert.ok(ie); - assert.equal(ie.getType(), "POINT"); - }); - - it("contructor from invalid object 2", function() { - var javaObject = { - modelId : 2, - type : "unk_type" - }; - var code = function() { - new IdentifiedElement(javaObject); - }; - assert.throws(code, new RegExp("Unknown type")); - }); - - it("contructor from invalid object 3", function() { - var javaObject = { - type : "alias", - objectId : "el_id" - }; - var code = function() { - new IdentifiedElement(javaObject); - }; - assert.throws(code, new RegExp("ModelId is invalid")); - }); - - it("contructor from invalid object 4", function() { - var javaObject = { - type : "alias", - modelId : 4, - }; - var code = function() { - new IdentifiedElement(javaObject); - }; - assert.throws(code, new RegExp("Id not defined")); - }); - - it("contructor from artifitial obj", function() { - var javaObject = { - type : "alias", - objectId : "el_id", - modelId : "m_id" - }; - var ie = new IdentifiedElement(javaObject); - var point = ie.getPoint(); - expect(point).to.equal(null); - assert.equal(logger.getWarnings().length, 1); - }); }); diff --git a/frontend-js/src/test/js/map/data/LayoutAlias-test.js b/frontend-js/src/test/js/map/data/LayoutAlias-test.js index cd33b25e11..d4fd9295f4 100644 --- a/frontend-js/src/test/js/map/data/LayoutAlias-test.js +++ b/frontend-js/src/test/js/map/data/LayoutAlias-test.js @@ -70,7 +70,7 @@ describe('LayoutAlias', function() { alias.update("invalid data"); assert.ok(false); } catch (exception) { - assert.ok(exception.message.indexOf("Unknown paramter type") >= 0); + assert.ok(exception.message.indexOf("Unknown parameter type") >= 0); } }); diff --git a/frontend-js/src/test/js/map/data/LayoutData-test.js b/frontend-js/src/test/js/map/data/LayoutData-test.js index ed1af0ba80..92413c34b7 100644 --- a/frontend-js/src/test/js/map/data/LayoutData-test.js +++ b/frontend-js/src/test/js/map/data/LayoutData-test.js @@ -9,7 +9,7 @@ var assert = chai.assert; var logger = require('../../logger'); describe('LayoutData', function() { - describe("contructor", function() { + describe("constructor", function() { it("default", function() { var layoutId = 3; var name = "nm"; @@ -43,7 +43,7 @@ describe('LayoutData', function() { assert.equal(data.getDirectory(), "dir/subDir"); }); - it("from prolematic json", function() { + it("from problematic json", function() { var obj = { modelId : 15781, name : "test", diff --git a/frontend-js/src/test/js/map/data/PointData-test.js b/frontend-js/src/test/js/map/data/PointData-test.js index b950c77d44..4a4d577bcf 100644 --- a/frontend-js/src/test/js/map/data/PointData-test.js +++ b/frontend-js/src/test/js/map/data/PointData-test.js @@ -1,12 +1,12 @@ "use strict"; var PointData = require('../../../../main/js/map/data/PointData'); -var IdentfiedElement = require('../../../../main/js/map/data/IdentifiedElement'); +var IdentifiedElement = require('../../../../main/js/map/data/IdentifiedElement'); var assert = require('assert'); describe('PointData', function() { - describe("contructor", function() { - it("from coords", function() { + describe("constructor", function() { + it("from coordinates", function() { var point = new google.maps.Point(2, 3.45); var pointData = new PointData(point); assert.ok(pointData); @@ -28,7 +28,7 @@ describe('PointData', function() { var pointData = new PointData({ idObject : "Point2D.Double[2.0, 3.0]" }, 102); - var ie = new IdentfiedElement(pointData); + var ie = new IdentifiedElement(pointData); var pointData2 = new PointData(ie); assert.equal(pointData.getModelId(), pointData2.getModelId()); }); diff --git a/frontend-js/src/test/js/map/data/ReferenceGenome-test.js b/frontend-js/src/test/js/map/data/ReferenceGenome-test.js index 92cac57805..c3eff93fdd 100644 --- a/frontend-js/src/test/js/map/data/ReferenceGenome-test.js +++ b/frontend-js/src/test/js/map/data/ReferenceGenome-test.js @@ -3,39 +3,42 @@ var ReferenceGenome = require('../../../../main/js/map/data/ReferenceGenome'); var assert = require('assert'); -describe('ReferenceGenome', function() { - it("contructor", function() { - var data = { - type : "TYP", - version : "v3", - localUrl : "http://google.pl/", - sourceUrl : "http://google.pl/", - }; - var genome = new ReferenceGenome(data); - assert.equal(genome.getType(), data.type); - assert.equal(genome.getVersion(), data.version); - assert.equal(genome.getUrl(), data.localUrl); - assert.equal(genome.getGeneMappings().length, 0); - }); +describe('ReferenceGenome', function () { + describe("constructor", function () { + it("full", function () { + var data = { + type: "TYP", + version: "v3", + localUrl: "http://google.pl/", + sourceUrl: "http://google.pl/", + }; + var genome = new ReferenceGenome(data); + assert.equal(genome.getType(), data.type); + assert.equal(genome.getVersion(), data.version); + assert.equal(genome.getUrl(), data.localUrl); + assert.equal(genome.getGeneMappings().length, 0); + }); + it("simple", function () { + var data = { + sourceUrl: "http://google.pl/", + geneMapping: [{}], + }; + var genome = new ReferenceGenome(data); + assert.equal(genome.getUrl(), data.sourceUrl); + assert.equal(genome.getGeneMappings().length, 1); + }); - it("contructor 2", function() { - var data = { - sourceUrl : "http://google.pl/", - geneMapping : [ {} ], - }; - var genome = new ReferenceGenome(data); - assert.equal(genome.getUrl(), data.sourceUrl); - assert.equal(genome.getGeneMappings().length, 1); - }); + it("empty argument", function () { + var genome = new ReferenceGenome(); + assert.ok(genome); + }); - it("contructor 3", function() { - var genome = new ReferenceGenome(); - assert.ok(genome); - }); + it("null argument", function () { + var genome = new ReferenceGenome(null); + assert.ok(genome); + }); - it("contructor with null arg", function() { - var genome = new ReferenceGenome(null); - assert.ok(genome); }); + }); diff --git a/frontend-js/src/test/js/map/data/ReferenceGenomeGeneMapping-test.js b/frontend-js/src/test/js/map/data/ReferenceGenomeGeneMapping-test.js index 64d68ceab5..9b05299fba 100644 --- a/frontend-js/src/test/js/map/data/ReferenceGenomeGeneMapping-test.js +++ b/frontend-js/src/test/js/map/data/ReferenceGenomeGeneMapping-test.js @@ -4,7 +4,7 @@ var ReferenceGenomeGeneMapping = require('../../../../main/js/map/data/Reference var assert = require('assert'); describe('ReferenceGenomeGeneMapping', function() { - it("contructor", function() { + it("constructor", function() { var data = { name: "TYPe", localUrl : "http://google.pl/", diff --git a/frontend-js/src/test/js/map/overlay/UserDbOverlay-test.js b/frontend-js/src/test/js/map/overlay/UserDbOverlay-test.js index 13f742cba1..ec99abe767 100644 --- a/frontend-js/src/test/js/map/overlay/UserDbOverlay-test.js +++ b/frontend-js/src/test/js/map/overlay/UserDbOverlay-test.js @@ -53,7 +53,7 @@ describe('UserDbOverlay', function() { }); describe("addMarker", function() { - it("add unexisting object", function() { + it("add non existing object", function() { var overlay; return ServerConnector.getProject().then(function(project) { var options = helper.createCustomMapOptions(project); @@ -79,7 +79,7 @@ describe('UserDbOverlay', function() { }); }); - it("add to unexisting map", function() { + it("add to non existing map", function() { var overlay; return ServerConnector.getProject().then(function(project) { var options = helper.createCustomMapOptions(project); diff --git a/frontend-js/src/test/js/map/surface/ReactionSurface-test.js b/frontend-js/src/test/js/map/surface/ReactionSurface-test.js index 52f8f5b1ce..724cf40907 100644 --- a/frontend-js/src/test/js/map/surface/ReactionSurface-test.js +++ b/frontend-js/src/test/js/map/surface/ReactionSurface-test.js @@ -55,7 +55,7 @@ describe('ReactionSurface', function() { }); - it("changedToCustimzed", function() { + it("changedToCustomized", function() { var map = helper.createCustomMap(); var reaction = helper.createReaction(map); var layoutReaction = helper.createLayoutReaction(reaction); @@ -67,12 +67,12 @@ describe('ReactionSurface', function() { customized : false }); - reactionOverlay.changedToCustimzed(); + reactionOverlay.changedToCustomized(); assert.ok(reactionOverlay.isCustomized()); }); - it("createline", function() { + it("createLine", function() { var map = helper.createAbstractCustomMap(); var line = ReactionSurface.createLine({ diff --git a/frontend-js/src/test/js/minerva-test.js b/frontend-js/src/test/js/minerva-test.js index c3cc8f9f9d..bd4f033c7e 100644 --- a/frontend-js/src/test/js/minerva-test.js +++ b/frontend-js/src/test/js/minerva-test.js @@ -14,15 +14,10 @@ var logger = require('./logger'); describe('minerva global', function () { beforeEach(function () { - global.scriptDiv = document.createElement("script"); - global.GuiConnector = undefined; global.ServerConnector = undefined; - document.body.appendChild(global.scriptDiv); }); afterEach(function () { - document.body.removeChild(global.scriptDiv); - global.GuiConnector = GuiConnectorMock; global.ServerConnector = ServerConnectorMock; }); @@ -96,7 +91,7 @@ describe('minerva global', function () { }); }); - it("constructor with GET coord param", function () { + it("constructor with GET coordinates param", function () { helper.setUrl("http://test/?x=5&y=6"); var options; return ServerConnectorMock.getProject().then(function (project) { @@ -184,7 +179,7 @@ describe('minerva global', function () { }); }); - it('create with show sumbodel GET param', function () { + it('create with show submodel GET param', function () { helper.setUrl("http://test/?submap=15781"); var project = helper.createProject(); diff --git a/frontend-js/src/test/js/mocha-config.js b/frontend-js/src/test/js/mocha-config.js index 846fc0db75..37de29a2e5 100644 --- a/frontend-js/src/test/js/mocha-config.js +++ b/frontend-js/src/test/js/mocha-config.js @@ -53,7 +53,7 @@ global.window.$ = $; var originalCreateElement = document.createElement; document.createElement = function (arg) { var result = originalCreateElement.call(this, arg); - // woraround for: https://github.com/tmpvar/jsdom/issues/961 + // workaround for: https://github.com/tmpvar/jsdom/issues/961 if ("li" === arg) { result.dataset = []; } -- GitLab