From 494e40e41664d3769b7d98a0c2439ea10be68b49 Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Mon, 3 Jul 2017 11:25:24 +0200
Subject: [PATCH] unit test for opening window for alias

---
 .../src/main/js/map/surface/AliasSurface.js    | 14 +++++++-------
 .../test/js/map/surface/AliasSurface-test.js   | 18 ++++++++++++++++++
 2 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/frontend-js/src/main/js/map/surface/AliasSurface.js b/frontend-js/src/main/js/map/surface/AliasSurface.js
index 4ded4d3fa6..a164896322 100644
--- a/frontend-js/src/main/js/map/surface/AliasSurface.js
+++ b/frontend-js/src/main/js/map/surface/AliasSurface.js
@@ -23,13 +23,9 @@ function AliasSurface(params) {
   this.aliasData = params.alias;
 
   var self = this;
-  var onclick = (function() {
-    var aliasOverlayData = self;
-    return function() {
-      self.getCustomMap()
-          .openInfoWindowForAlias(aliasOverlayData.aliasData.getId(), aliasOverlayData.getCustomMap().getId());
-    };
-  })();
+  var onclick = function() {
+    return self.onClickHandler();
+  };
   google.maps.event.addListener(this.gmapObj, 'click', onclick);
 }
 
@@ -46,6 +42,10 @@ AliasSurface.prototype.setMap = function(map) {
   this.gmapObj.setMap(map);
 };
 
+AliasSurface.prototype.onClickHandler = function() {
+  return this.getCustomMap().getTopMap().openInfoWindowForAlias(this.aliasData.getId(), this.aliasData.getModelId());
+}
+
 AliasSurface.prototype.setColor = function(color) {
   this._color = color;
   this.gmapObj.setOptions({
diff --git a/frontend-js/src/test/js/map/surface/AliasSurface-test.js b/frontend-js/src/test/js/map/surface/AliasSurface-test.js
index e2dde0afd5..7835fc84d1 100644
--- a/frontend-js/src/test/js/map/surface/AliasSurface-test.js
+++ b/frontend-js/src/test/js/map/surface/AliasSurface-test.js
@@ -42,4 +42,22 @@ describe('AliasSurface', function() {
       assert.equal(logger.getWarnings.length, 0);
     });
   });
+  describe('click', function() {
+    it("default", function() {
+      var map;
+      var alias;
+      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);
+        return AliasSurface.createFromIdentifiedElement(identifiedElement, map);
+      }).then(function(result) {
+        return result.onClickHandler();
+      });
+    });
+    
+  });
+
 });
-- 
GitLab