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

ServerConnector getOverlayElements wrong url fixed

and unit test added
parent 371bbb0d
No related branches found
No related tags found
1 merge request!5Frontend refactor
......@@ -857,7 +857,7 @@ ServerConnector.getOverlayByIdUrl = function(overlayId, projectId, token) {
ServerConnector.getOverlayElementsUrl = function(overlayId, projectId, token) {
return this.getApiUrl({type:"overlay",
method: "getOverlayElementsUrl",
method: "getOverlayElements",
params: {
projectId: projectId,
token: token,
......@@ -1006,7 +1006,7 @@ ServerConnector.getOverlays = function(projectId) {
ServerConnector.getOverlayElements = function(layoutId, projectId) {
var self = this;
if (layoutId === undefined) {
throw "Layout id must be defined";
throw new Error("Layout id must be defined");
}
return new Promise(function(resolve, reject) {
self.getToken().then(function(token) {
......
......@@ -12,6 +12,7 @@ function LayoutAlias(javaObject) {
this.setId(javaObject.idObject);
this.setValue(javaObject.value);
this.setColor(javaObject.color);
this.setModelId(javaObject.modelId);
if (javaObject.type === undefined) {
this.setType(LayoutAlias.LIGTH);
} else if (javaObject.type === LayoutAlias.GENETIC_VARIANT) {
......@@ -42,6 +43,14 @@ LayoutAlias.prototype.setId = function(id) {
this.id = parseInt(id);
};
LayoutAlias.prototype.getModelId = function() {
return this._modelId;
};
LayoutAlias.prototype.setModelId = function(modelId) {
this._modelId = parseInt(modelId);
};
LayoutAlias.prototype.getValue = function() {
return this.value;
};
......
......@@ -3,6 +3,7 @@
require("./mocha-config.js");
var Alias = require('../../main/js/map/data/Alias');
var LayoutAlias = require('../../main/js/map/data/LayoutAlias');
var Project = require('../../main/js/map/data/Project');
var Reaction = require('../../main/js/map/data/Reaction');
var ServerConnector = require('../../main/js/ServerConnector');
......@@ -49,5 +50,16 @@ describe('ServerConnector', function() {
assert.equal(reaction.getModelId(), 15781);
});
});
it('getOverlayElements', function() {
return ServerConnector.getOverlayElements(101).then(function(result) {
assert.equal(result.length, 1);
var layoutAlias = result[0];
assert.ok(layoutAlias instanceof LayoutAlias);
assert.equal(1.0, layoutAlias.getValue());
assert.equal(15781, layoutAlias.getModelId());
assert.equal(329173, layoutAlias.getId());
});
});
});
[{"type":"ALIAS","overlayContent":{"value":1.0,"modelId":15781,"idObject":"329173"}}]
\ No newline at end of file
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