From 6ccbf06e989eae208207c025a74995417f598743 Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Fri, 20 Jul 2018 13:31:19 +0200
Subject: [PATCH] unit test for creating chart for alias with submap links

---
 .../js/map/window/AliasInfoWindow-test.js     | 117 +++++++++---------
 1 file changed, 61 insertions(+), 56 deletions(-)

diff --git a/frontend-js/src/test/js/map/window/AliasInfoWindow-test.js b/frontend-js/src/test/js/map/window/AliasInfoWindow-test.js
index c7dec871f2..85c8f1ca15 100644
--- a/frontend-js/src/test/js/map/window/AliasInfoWindow-test.js
+++ b/frontend-js/src/test/js/map/window/AliasInfoWindow-test.js
@@ -257,41 +257,6 @@ describe('AliasInfoWindow', function () {
 
     });
 
-    it("on submap map", function () {
-      helper.setUrl("http://test/?id=complex_model_with_submaps");
-
-      var map, submap, overlay, win, alias;
-
-      return ServerConnector.getProject().then(function (project) {
-        map = helper.createCustomMap(project);
-        submap = map.getSubmapById(16731);
-        overlay = new DataOverlay(18077, "xxx");
-        overlay.setInitialized(true);
-        return map.openSubmap(submap.getId());
-      }).then(function () {
-        return submap.getModel().getAliasById(345337);
-      }).then(function (data) {
-        alias = data;
-        win = new AliasInfoWindow({
-          alias: alias,
-          map: submap,
-          marker: helper.createMarker({element: alias, map: submap})
-        });
-        return win.init();
-      }).then(function () {
-        var layoutAlias = helper.createLayoutAlias(alias);
-        layoutAlias.setType(LayoutAlias.GENETIC_VARIANT);
-        var overlay = helper.createOverlay();
-        overlay.addAlias(layoutAlias);
-        return win.createGenomicDiv({overlays: [overlay]});
-      }).then(function (div) {
-        assert.ok(div);
-        win.destroy();
-        return map.destroy();
-      });
-
-    });
-
     it("with no genetic data", function () {
       var map;
 
@@ -376,30 +341,70 @@ describe('AliasInfoWindow', function () {
     assert.ok(functions.isDomElement(aliasWindow.createWaitingContentDiv()));
   });
 
-  it("createChartDiv ", function () {
-    var map, ie, aliasWindow;
-    return ServerConnector.getProject().then(function (project) {
-      map = helper.createCustomMap(project);
-      ie = new IdentifiedElement({
-        id: 329170,
-        modelId: map.getId(),
-        type: "ALIAS"
-      });
+  describe("createChartDiv ", function () {
+    it("on submap map", function () {
+      helper.setUrl("http://test/?id=complex_model_with_submaps");
 
-      return map.getModel().getByIdentifiedElement(ie, true);
-    }).then(function (alias) {
-      aliasWindow = new AliasInfoWindow({
-        alias: alias,
-        map: map,
-        marker: helper.createMarker({element: alias, map: map})
+      var map, submap, overlay, win, aliasOnSubmap, alias;
+
+      return ServerConnector.getProject().then(function (project) {
+        map = helper.createCustomMap(project);
+        submap = map.getSubmapById(16731);
+        overlay = new DataOverlay(18077, "xxx");
+        overlay.setInitialized(true);
+        return map.openSubmap(submap.getId());
+      }).then(function () {
+        return map.getModel().getAliasById(345339);
+      }).then(function (data) {
+        alias = data;
+        return submap.getModel().getAliasById(345337);
+      }).then(function (data) {
+        aliasOnSubmap = data;
+        win = new AliasInfoWindow({
+          alias: alias,
+          map: map,
+          marker: helper.createMarker({element: alias, map: map})
+        });
+        return win.init();
+      }).then(function () {
+        var layoutAlias = helper.createLayoutAlias(aliasOnSubmap);
+        layoutAlias.setType(LayoutAlias.GENERIC);
+        var overlay = helper.createOverlay();
+        overlay.addAlias(layoutAlias);
+        return win.createChartDiv({overlays: [overlay]});
+      }).then(function (div) {
+        assert.ok(div);
+        win.destroy();
+        return map.destroy();
       });
-      var overlay = helper.createOverlay();
-      overlay.addAlias(helper.createLayoutAlias(alias, LayoutAlias.GENERIC));
-      var overlays = [overlay, helper.createOverlay()];
 
-      return aliasWindow.createChartDiv({overlays: overlays});
-    }).then(function (div) {
-      assert.ok(div);
+    });
+
+    it("default ", function () {
+      var map, ie, aliasWindow;
+      return ServerConnector.getProject().then(function (project) {
+        map = helper.createCustomMap(project);
+        ie = new IdentifiedElement({
+          id: 329170,
+          modelId: map.getId(),
+          type: "ALIAS"
+        });
+
+        return map.getModel().getByIdentifiedElement(ie, true);
+      }).then(function (alias) {
+        aliasWindow = new AliasInfoWindow({
+          alias: alias,
+          map: map,
+          marker: helper.createMarker({element: alias, map: map})
+        });
+        var overlay = helper.createOverlay();
+        overlay.addAlias(helper.createLayoutAlias(alias, LayoutAlias.GENERIC));
+        var overlays = [overlay, helper.createOverlay()];
+
+        return aliasWindow.createChartDiv({overlays: overlays});
+      }).then(function (div) {
+        assert.ok(div);
+      });
     });
   });
 
-- 
GitLab