Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
verona-modules-aspect
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
IQB
verona-modules-aspect
Commits
16f161c3
Commit
16f161c3
authored
2 years ago
by
jojohoch
Browse files
Options
Downloads
Patches
Plain Diff
[player] Add tests for UnitStateService
parent
440d9bc2
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
projects/player/src/app/services/unit-state.service.spec.ts
+134
-0
134 additions, 0 deletions
projects/player/src/app/services/unit-state.service.spec.ts
with
134 additions
and
0 deletions
projects/player/src/app/services/unit-state.service.spec.ts
0 → 100644
+
134
−
0
View file @
16f161c3
import
{
TestBed
}
from
'
@angular/core/testing
'
;
import
{
UnitStateService
}
from
'
./unit-state.service
'
;
import
{
ElementCode
}
from
'
verona/models/verona
'
;
describe
(
'
UnitStateService
'
,
()
=>
{
let
service
:
UnitStateService
;
beforeEach
(()
=>
{
TestBed
.
configureTestingModule
({});
service
=
TestBed
.
inject
(
UnitStateService
);
});
it
(
'
should be created
'
,
()
=>
{
expect
(
service
).
toBeTruthy
();
});
it
(
'
should get element by id
'
,
()
=>
{
const
element1
:
ElementCode
=
{
id
:
'
element_1
'
,
status
:
'
DISPLAYED
'
,
value
:
'
TEST1
'
};
const
element2
:
ElementCode
=
{
id
:
'
element_2
'
,
status
:
'
DISPLAYED
'
,
value
:
'
TEST2
'
};
service
.
elementCodes
=
[
element1
,
element2
];
expect
(
service
.
getElementCodeById
(
'
element_1
'
)).
toEqual
(
element1
);
});
it
(
'
should return undefined for a not registered element id
'
,
()
=>
{
const
element1
:
ElementCode
=
{
id
:
'
element_1
'
,
status
:
'
DISPLAYED
'
,
value
:
'
TEST1
'
};
const
element2
:
ElementCode
=
{
id
:
'
element_2
'
,
status
:
'
DISPLAYED
'
,
value
:
'
TEST2
'
};
service
.
elementCodes
=
[
element1
,
element2
];
expect
(
service
.
getElementCodeById
(
'
element_3
'
)).
toBeUndefined
();
});
it
(
'
should verify that element is registered
'
,
()
=>
{
const
element1
:
ElementCode
=
{
id
:
'
element_1
'
,
status
:
'
DISPLAYED
'
,
value
:
'
TEST1
'
};
const
element2
:
ElementCode
=
{
id
:
'
element_2
'
,
status
:
'
DISPLAYED
'
,
value
:
'
TEST2
'
};
service
.
elementCodes
=
[
element1
,
element2
];
expect
(
service
.
isRegistered
(
'
element_1
'
)).
toBeTruthy
();
});
it
(
'
should verify that element is registered
'
,
()
=>
{
const
element1
:
ElementCode
=
{
id
:
'
element_1
'
,
status
:
'
DISPLAYED
'
,
value
:
'
TEST1
'
};
const
element2
:
ElementCode
=
{
id
:
'
element_2
'
,
status
:
'
DISPLAYED
'
,
value
:
'
TEST2
'
};
service
.
elementCodes
=
[
element1
,
element2
];
expect
(
service
.
isRegistered
(
'
element_3
'
)).
toBeFalse
();
});
it
(
'
should register an element
'
,
()
=>
{
service
.
elementCodes
=
[];
const
element
=
document
.
createElement
(
'
div
'
);
service
.
registerElement
(
'
element
'
,
'
TEST
'
,
element
,
1
);
expect
(
service
.
elementCodes
).
toEqual
([
{
id
:
'
element
'
,
status
:
'
NOT_REACHED
'
,
value
:
'
TEST
'
}
]);
});
it
(
'
elementCode of an element should change
'
,
()
=>
{
service
.
elementCodes
=
[{
id
:
'
element_1
'
,
status
:
'
NOT_REACHED
'
,
value
:
'
TEST1
'
}];
service
.
elementCodeChanged
.
subscribe
(
code
=>
expect
(
code
.
status
).
toEqual
(
'
DISPLAYED
'
));
service
.
changeElementCodeStatus
({
id
:
'
element_1
'
,
status
:
'
DISPLAYED
'
});
});
it
(
'
elementCode of an element should change
'
,
()
=>
{
service
.
elementCodes
=
[{
id
:
'
element_1
'
,
status
:
'
NOT_REACHED
'
,
value
:
'
TEST1
'
}];
service
.
elementCodeChanged
.
subscribe
(
code
=>
{
expect
(
code
.
status
).
toEqual
(
'
VALUE_CHANGED
'
);
expect
(
code
.
value
).
toEqual
(
'
NEU
'
);
})
;
service
.
changeElementCodeValue
({
id
:
'
element_1
'
,
value
:
'
NEU
'
});
});
it
(
'
presentedPagesProgress should be complete
'
,
()
=>
{
service
.
elementCodes
=
[];
expect
(
service
.
presentedPagesProgress
).
toEqual
(
'
complete
'
);
});
it
(
'
presentedPagesProgress should be none
'
,
()
=>
{
service
.
elementCodes
=
[];
const
element
=
document
.
createElement
(
'
div
'
);
service
.
registerElement
(
'
element
'
,
'
TEST
'
,
element
,
1
);
expect
(
service
.
presentedPagesProgress
).
toEqual
(
'
none
'
);
});
it
(
'
presentedPagesProgress should be complete
'
,
()
=>
{
service
.
elementCodes
=
[];
const
element
=
document
.
createElement
(
'
div
'
);
service
.
registerElement
(
'
element
'
,
'
TEST
'
,
element
,
1
);
service
.
changeElementCodeStatus
({
id
:
'
element
'
,
status
:
'
DISPLAYED
'
});
expect
(
service
.
presentedPagesProgress
).
toEqual
(
'
complete
'
);
});
it
(
'
presentedPagesProgress should be none
'
,
()
=>
{
service
.
elementCodes
=
[];
const
element
=
document
.
createElement
(
'
div
'
);
service
.
registerElement
(
'
element_1
'
,
'
TEST1
'
,
element
,
1
);
service
.
registerElement
(
'
element_2
'
,
'
TEST2
'
,
element
,
1
);
service
.
changeElementCodeStatus
({
id
:
'
element_1
'
,
status
:
'
DISPLAYED
'
});
expect
(
service
.
presentedPagesProgress
).
toEqual
(
'
none
'
);
});
it
(
'
presentedPagesProgress should be some
'
,
()
=>
{
service
.
elementCodes
=
[];
const
element
=
document
.
createElement
(
'
div
'
);
service
.
registerElement
(
'
element_1
'
,
'
TEST1
'
,
element
,
1
);
service
.
registerElement
(
'
element_2
'
,
'
TEST2
'
,
element
,
2
);
service
.
changeElementCodeStatus
({
id
:
'
element_1
'
,
status
:
'
DISPLAYED
'
});
expect
(
service
.
presentedPagesProgress
).
toEqual
(
'
some
'
);
});
it
(
'
presentedPagesProgress should be complete
'
,
()
=>
{
service
.
elementCodes
=
[];
const
element
=
document
.
createElement
(
'
div
'
);
service
.
registerElement
(
'
element_1
'
,
'
TEST1
'
,
element
,
1
);
service
.
registerElement
(
'
element_2
'
,
'
TEST2
'
,
element
,
2
);
service
.
changeElementCodeStatus
({
id
:
'
element_1
'
,
status
:
'
DISPLAYED
'
});
service
.
changeElementCodeStatus
({
id
:
'
element_2
'
,
status
:
'
DISPLAYED
'
});
expect
(
service
.
presentedPagesProgress
).
toEqual
(
'
complete
'
);
});
it
(
'
presented page with index 1 should be added
'
,
()
=>
{
service
.
elementCodes
=
[];
const
element
=
document
.
createElement
(
'
div
'
);
service
.
registerElement
(
'
element_1
'
,
'
TEST1
'
,
element
,
1
);
service
.
presentedPageAdded
.
subscribe
(
index
=>
expect
(
index
).
toEqual
(
1
));
service
.
changeElementCodeStatus
({
id
:
'
element_1
'
,
status
:
'
DISPLAYED
'
});
});
it
(
'
presented page with index 1 should be added
'
,
()
=>
{
service
.
elementCodes
=
[];
const
element
=
document
.
createElement
(
'
div
'
);
service
.
registerElement
(
'
element_1
'
,
'
TEST1
'
,
element
,
1
);
service
.
presentedPageAdded
.
subscribe
(
index
=>
expect
(
index
).
toEqual
(
1
));
service
.
changeElementCodeValue
({
id
:
'
element_1
'
,
value
:
'
NEU
'
});
});
});
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