Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
anis-next
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
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
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
anis
anis-next
Commits
2987e333
Commit
2987e333
authored
3 years ago
by
Tifenn Guillas
Browse files
Options
Downloads
Patches
Plain Diff
WIP: Tests with dom
parent
9e535a9b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!29
Develop
,
!17
Resolve "Add tests for instance module"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
client/src/app/instance/instance.component.spec.ts
+12
-1
12 additions, 1 deletion
client/src/app/instance/instance.component.spec.ts
client/src/app/instance/instance.component.ts
+0
-1
0 additions, 1 deletion
client/src/app/instance/instance.component.ts
with
12 additions
and
2 deletions
client/src/app/instance/instance.component.spec.ts
+
12
−
1
View file @
2987e333
...
@@ -46,6 +46,9 @@ describe('InstanceComponent', () => {
...
@@ -46,6 +46,9 @@ describe('InstanceComponent', () => {
fixture
=
TestBed
.
createComponent
(
InstanceComponent
);
fixture
=
TestBed
.
createComponent
(
InstanceComponent
);
component
=
fixture
.
componentInstance
;
component
=
fixture
.
componentInstance
;
store
=
TestBed
.
inject
(
MockStore
);
store
=
TestBed
.
inject
(
MockStore
);
document
.
body
.
innerHTML
=
'
<title id="title">Default title</title>
'
+
'
<link id="favicon" href="">
'
;
}));
}));
it
(
'
should create the component
'
,
()
=>
{
it
(
'
should create the component
'
,
()
=>
{
...
@@ -87,14 +90,22 @@ describe('InstanceComponent', () => {
...
@@ -87,14 +90,22 @@ describe('InstanceComponent', () => {
nb_datasets
:
2
nb_datasets
:
2
};
};
component
.
instance
=
of
(
instance
);
component
.
instance
=
of
(
instance
);
component
.
title
=
'
<title id="title">Default instance</title>
'
as
HTMLLinkElement
;
const
spy
=
jest
.
spyOn
(
store
,
'
dispatch
'
);
const
spy
=
jest
.
spyOn
(
store
,
'
dispatch
'
);
const
expectedLinks
=
[
{
label
:
'
Home
'
,
icon
:
'
fas fa-home
'
,
routerLink
:
'
home
'
},
{
label
:
'
Search
'
,
icon
:
'
fas fa-search
'
,
routerLink
:
'
search
'
},
{
label
:
'
Search multiple
'
,
icon
:
'
fas fa-search-plus
'
,
routerLink
:
'
search-multiple
'
},
{
label
:
'
Documentation
'
,
icon
:
'
fas fa-question
'
,
routerLink
:
'
documentation
'
}
];
component
.
ngOnInit
();
component
.
ngOnInit
();
Promise
.
resolve
(
null
).
then
(
function
()
{
Promise
.
resolve
(
null
).
then
(
function
()
{
expect
(
spy
).
toHaveBeenCalledTimes
(
3
);
expect
(
spy
).
toHaveBeenCalledTimes
(
3
);
expect
(
spy
).
toHaveBeenCalledWith
(
datasetFamilyActions
.
loadDatasetFamilyList
());
expect
(
spy
).
toHaveBeenCalledWith
(
datasetFamilyActions
.
loadDatasetFamilyList
());
expect
(
spy
).
toHaveBeenCalledWith
(
datasetActions
.
loadDatasetList
());
expect
(
spy
).
toHaveBeenCalledWith
(
datasetActions
.
loadDatasetList
());
expect
(
spy
).
toHaveBeenCalledWith
(
surveyActions
.
loadSurveyList
());
expect
(
spy
).
toHaveBeenCalledWith
(
surveyActions
.
loadSurveyList
());
expect
(
component
.
links
).
toEqual
(
expectedLinks
);
expect
(
component
.
favIcon
.
href
).
toEqual
(
'
http://localhost/undefined/download-instance-file/myInstance/path/to/favicon
'
);
expect
(
component
.
title
.
textContent
).
toEqual
(
'
My Instance
'
);
done
();
done
();
});
});
});
});
...
...
This diff is collapsed.
Click to expand it.
client/src/app/instance/instance.component.ts
+
0
−
1
View file @
2987e333
...
@@ -51,7 +51,6 @@ export class InstanceComponent implements OnInit, OnDestroy {
...
@@ -51,7 +51,6 @@ export class InstanceComponent implements OnInit, OnDestroy {
}
}
ngOnInit
()
{
ngOnInit
()
{
console
.
log
(
this
.
title
);
// Create a micro task that is processed after the current synchronous code
// Create a micro task that is processed after the current synchronous code
// This micro task prevent the expression has changed after view init error
// This micro task prevent the expression has changed after view init error
Promise
.
resolve
(
null
).
then
(()
=>
this
.
store
.
dispatch
(
datasetFamilyActions
.
loadDatasetFamilyList
()));
Promise
.
resolve
(
null
).
then
(()
=>
this
.
store
.
dispatch
(
datasetFamilyActions
.
loadDatasetFamilyList
()));
...
...
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