From 110a10872928dcf4df5f9a412025d4f7a5c04173 Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Fri, 11 Nov 2016 14:14:36 +0100
Subject: [PATCH] Configuration unit tests and redundant code removed

---
 frontend-js/src/main/js/Configuration.js      | 40 -------------------
 frontend-js/src/test/js/Configuration-test.js |  7 ++++
 2 files changed, 7 insertions(+), 40 deletions(-)

diff --git a/frontend-js/src/main/js/Configuration.js b/frontend-js/src/main/js/Configuration.js
index 9f82288d7a..2a9cd677f1 100644
--- a/frontend-js/src/main/js/Configuration.js
+++ b/frontend-js/src/main/js/Configuration.js
@@ -35,46 +35,6 @@ function Configuration(data) {
 Configuration.prototype = Object.create(ObjectWithListeners.prototype);
 Configuration.prototype.constructor = Configuration;
 
-/**
- * Load configuration from file.
- */
-Configuration.prototype.loadFromFile = function(fileName, callBackFunction) {
-  var self = this;
-
-  var txtFile = new XMLHttpRequest();
-  txtFile.open("GET", fileName, true);
-  txtFile.onreadystatechange = function() {
-    // Makes sure the document is ready to parse.
-    if (txtFile.readyState === 4) {
-      // Makes sure it's found the file.
-      if (txtFile.status === 200) {
-        allText = txtFile.responseText;
-        // Will separate each line into an array
-        textLines = txtFile.responseText.split("\n");
-
-        // name of the map is the filename wthout path and extension
-        self.MAP_NAME = textLines[0].replace(/^.*[\\\/]/, '').split(".")[0];
-        self.TILE_SIZE = parseInt(textLines[3]);
-        self.PICTURE_SIZE = parseInt(textLines[4]);
-        self.MIN_ZOOM = 2;
-        self.MAX_ZOOM = self.MIN_ZOOM + parseInt(textLines[2]);
-        // read information about all maps connected with current project
-        mapCounter = parseInt(textLines[5]);
-        for (var i = 0; i < mapCounter; i++) {
-          mapDesc = {
-            id : textLines[6 + i * 2],
-            title : textLines[6 + i * 2 + 1]
-          };
-          self.MAPS.push(mapDesc);
-        }
-        callBackFunction();
-        self.callListeners("onreload");
-      }
-    }
-  };
-  txtFile.send(null);
-};
-
 /**
  * Updates configuration data from object passed from server side.
  * 
diff --git a/frontend-js/src/test/js/Configuration-test.js b/frontend-js/src/test/js/Configuration-test.js
index 70fef03c3d..ece19bf7ee 100644
--- a/frontend-js/src/test/js/Configuration-test.js
+++ b/frontend-js/src/test/js/Configuration-test.js
@@ -7,6 +7,13 @@ describe('configuration', function() {
     assert.ok(conf.SUBMODELS);
     assert.equal(conf.getId(), null);
   });
+  
+  it('constructor from json', function() {
+    var json = "{\"idObject\": 19}"
+    var conf = new Configuration(json);
+    assert.ok(conf.SUBMODELS);
+    assert.equal(conf.getId(), 19);
+  });
 
   it('Configuration onreload listener', function() {
     var conf = new Configuration();
-- 
GitLab