Skip to content
Snippets Groups Projects
Commit 110a1087 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Configuration unit tests and redundant code removed

parent 647d48a8
No related branches found
No related tags found
1 merge request!5Frontend refactor
......@@ -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.
*
......
......@@ -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();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment