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