Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
minerva
core
Commits
5df77cb3
Commit
5df77cb3
authored
8 years ago
by
Piotr Gawron
Browse files
Options
Downloads
Patches
Plain Diff
tests for layout data
parent
579131a2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!5
Frontend refactor
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontend-js/src/main/js/map/data/LayoutData.js
+14
-6
14 additions, 6 deletions
frontend-js/src/main/js/map/data/LayoutData.js
frontend-js/src/test/js/map/data/LayoutData-test.js
+60
-0
60 additions, 0 deletions
frontend-js/src/test/js/map/data/LayoutData-test.js
with
74 additions
and
6 deletions
frontend-js/src/main/js/map/data/LayoutData.js
+
14
−
6
View file @
5df77cb3
...
...
@@ -17,18 +17,18 @@ function LayoutData(layoutId, name) {
* Adds alias to the {@link LayoutData}
*
* @param layoutAlias
*
information about alias in a layout
* information about alias in a layout
*/
LayoutData
.
prototype
.
addAlias
=
function
(
layoutAlias
)
{
this
.
aliases
.
push
(
layoutAlias
);
this
.
aliasById
[
layoutAlias
.
id
]
=
layoutAlias
;
this
.
aliasById
[
layoutAlias
.
getId
()
]
=
layoutAlias
;
};
/**
* Adds reaction to the {@link LayoutData}
*
* @param layoutReaction
*
information about reaction in a layout
* information about reaction in a layout
*/
LayoutData
.
prototype
.
addReaction
=
function
(
layoutReaction
)
{
this
.
reactions
.
push
(
layoutReaction
);
...
...
@@ -38,13 +38,21 @@ LayoutData.prototype.getId = function() {
return
this
.
id
;
};
LayoutData
.
prototype
.
getName
=
function
()
{
return
this
.
name
;
};
LayoutData
.
prototype
.
updateAlias
=
function
(
layoutAlias
)
{
if
(
this
.
aliasById
[
layoutAlias
.
getId
()]
===
undefined
)
{
logger
.
warn
(
"
Cannot update alias, it doesn't exist. Alias:
"
+
layoutAlias
);
logger
.
warn
(
"
Cannot update alias, it doesn't exist. Alias:
"
+
layoutAlias
);
}
else
{
this
.
aliasById
[
layoutAlias
.
id
].
update
(
layoutAlias
);
this
.
aliasById
[
layoutAlias
.
getId
()
].
update
(
layoutAlias
);
}
};
module
.
exports
=
LayoutData
;
LayoutData
.
prototype
.
getAliasById
=
function
(
id
)
{
return
this
.
aliasById
[
id
];
};
module
.
exports
=
LayoutData
;
This diff is collapsed.
Click to expand it.
frontend-js/src/test/js/map/data/LayoutData-test.js
0 → 100644
+
60
−
0
View file @
5df77cb3
"
use strict
"
;
var
LayoutAlias
=
require
(
'
../../../../main/js/map/data/LayoutAlias
'
);
var
LayoutData
=
require
(
'
../../../../main/js/map/data/LayoutData
'
);
var
chai
=
require
(
'
chai
'
);
var
assert
=
chai
.
assert
;
var
logger
=
require
(
'
../../logger
'
);
describe
(
'
LayoutData
'
,
function
()
{
it
(
"
contructor
"
,
function
()
{
var
layoutId
=
3
;
var
name
=
"
nm
"
;
var
overlay
=
new
LayoutData
(
layoutId
,
name
);
assert
.
equal
(
overlay
.
getId
(),
layoutId
);
assert
.
equal
(
overlay
.
getName
(),
name
);
});
it
(
"
updateAlias
"
,
function
()
{
var
layoutId
=
3
;
var
name
=
"
nm
"
;
var
overlay
=
new
LayoutData
(
layoutId
,
name
);
var
aliasId
=
4
;
var
alias
=
new
LayoutAlias
({
idObject
:
aliasId
,
});
overlay
.
addAlias
(
alias
);
assert
.
equal
(
overlay
.
getAliasById
(
aliasId
).
getValue
(),
null
);
var
val
=
5
;
var
alias2
=
new
LayoutAlias
({
idObject
:
aliasId
,
value
:
val
,
});
overlay
.
updateAlias
(
alias2
);
assert
.
equal
(
overlay
.
getAliasById
(
aliasId
).
getValue
(),
val
);
assert
.
equal
(
logger
.
getWarnings
().
length
,
0
);
});
it
(
"
update invalid alias
"
,
function
()
{
var
layoutId
=
3
;
var
name
=
"
nm
"
;
var
overlay
=
new
LayoutData
(
layoutId
,
name
);
var
aliasId
=
4
;
var
alias
=
new
LayoutAlias
({
idObject
:
aliasId
,
});
overlay
.
updateAlias
(
alias
);
assert
.
equal
(
logger
.
getWarnings
().
length
,
1
);
});
});
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment