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

LayoutAlias throws errors insted logging them

parent 181a5fe6
No related branches found
No related tags found
1 merge request!5Frontend refactor
...@@ -21,7 +21,7 @@ function LayoutAlias(javaObject) { ...@@ -21,7 +21,7 @@ function LayoutAlias(javaObject) {
} else if (javaObject.type === LayoutAlias.GENERIC) { } else if (javaObject.type === LayoutAlias.GENERIC) {
this.setType(LayoutAlias.GENERIC); this.setType(LayoutAlias.GENERIC);
} else { } else {
logger.error("Unknown type: ", javaObject.type); throw new Error("Unknown type: ", javaObject.type);
} }
this.setGeneVariants([]); this.setGeneVariants([]);
...@@ -78,7 +78,7 @@ LayoutAlias.prototype.setGeneVariants = function(newGeneVariants) { ...@@ -78,7 +78,7 @@ LayoutAlias.prototype.setGeneVariants = function(newGeneVariants) {
LayoutAlias.prototype.update = function(alias) { LayoutAlias.prototype.update = function(alias) {
if (!(alias instanceof LayoutAlias)) { if (!(alias instanceof LayoutAlias)) {
logger.error("Unknown paramter type: " + alias); throw new Error("Unknown paramter type: " + alias);
return; return;
} }
......
"use strict"; "use strict";
var Helper = require('../../Helper');
require("../../mocha-config.js");
var LayoutAlias = require('../../../../main/js/map/data/LayoutAlias'); var LayoutAlias = require('../../../../main/js/map/data/LayoutAlias');
var assert = require('assert'); var assert = require('assert');
var logger = require('../../logger'); var logger = require('../../logger');
describe('LayoutAlias', function() { describe('LayoutAlias', function() {
var helper;
beforeEach(function() { beforeEach(function() {
logger.flushBuffer(); helper = new Helper();
}); });
it("constructor", function() { it("constructor", function() {
...@@ -66,21 +71,13 @@ describe('LayoutAlias', function() { ...@@ -66,21 +71,13 @@ describe('LayoutAlias', function() {
}); });
it("invalid update", function() { it("invalid update", function() {
var aliasId = 908; var alias = helper.createLayoutAlias();
var val = 0.2; try {
var colorVal = { alias.update("invalid data");
a : 23 assert.ok(false);
}; } catch (exception) {
var javaObj = { assert.ok(exception.message.indexOf("Unknown paramter type") >= 0);
idObject : aliasId, }
value : val,
color : colorVal,
geneVariations : [ {} ]
};
var alias = new LayoutAlias(javaObj);
alias.update("invalid data");
assert.equal(logger.getErrors().length, 1);
}); });
...@@ -127,8 +124,12 @@ describe('LayoutAlias', function() { ...@@ -127,8 +124,12 @@ describe('LayoutAlias', function() {
color : colorVal, color : colorVal,
type : "some strange val" type : "some strange val"
}; };
new LayoutAlias(javaObj); try {
assert.equal(logger.getErrors().length, 1); new LayoutAlias(javaObj);
assert.ok(false);
} catch (exception) {
assert.ok(exception.message.indexOf("Unknown type") >= 0);
}
}); });
}); });
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