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
9e535a9b
Commit
9e535a9b
authored
3 years ago
by
Tifenn Guillas
Browse files
Options
Downloads
Patches
Plain Diff
WIP: Tests on instance
parent
d9633875
No related branches found
No related tags found
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
+49
-9
49 additions, 9 deletions
client/src/app/instance/instance.component.spec.ts
client/src/app/instance/instance.component.ts
+1
-0
1 addition, 0 deletions
client/src/app/instance/instance.component.ts
with
50 additions
and
9 deletions
client/src/app/instance/instance.component.spec.ts
+
49
−
9
View file @
9e535a9b
...
@@ -10,6 +10,9 @@ import * as authActions from 'src/app/auth/auth.actions';
...
@@ -10,6 +10,9 @@ import * as authActions from 'src/app/auth/auth.actions';
import
{
Component
,
EventEmitter
,
Input
,
Output
}
from
'
@angular/core
'
;
import
{
Component
,
EventEmitter
,
Input
,
Output
}
from
'
@angular/core
'
;
import
{
Attribute
,
Instance
}
from
'
../metamodel/models
'
;
import
{
Attribute
,
Instance
}
from
'
../metamodel/models
'
;
import
{
UserProfile
}
from
'
../auth/user-profile.model
'
;
import
{
UserProfile
}
from
'
../auth/user-profile.model
'
;
import
*
as
datasetFamilyActions
from
'
../metamodel/actions/dataset-family.actions
'
;
import
*
as
datasetActions
from
'
../metamodel/actions/dataset.actions
'
;
import
*
as
surveyActions
from
'
../metamodel/actions/survey.actions
'
;
describe
(
'
InstanceComponent
'
,
()
=>
{
describe
(
'
InstanceComponent
'
,
()
=>
{
@
Component
({
selector
:
'
app-navbar
'
,
template
:
''
})
@
Component
({
selector
:
'
app-navbar
'
,
template
:
''
})
...
@@ -49,15 +52,52 @@ describe('InstanceComponent', () => {
...
@@ -49,15 +52,52 @@ describe('InstanceComponent', () => {
expect
(
component
).
toBeDefined
();
expect
(
component
).
toBeDefined
();
});
});
// it('should execute ngOnInit lifecycle', (done) => {
it
(
'
should execute ngOnInit lifecycle
'
,
(
done
)
=>
{
// const spy = jest.spyOn(store, 'dispatch');
const
instance
:
Instance
=
{
// component.ngOnInit();
name
:
'
myInstance
'
,
// Promise.resolve(null).then(function() {
label
:
'
My Instance
'
,
// expect(spy).toHaveBeenCalledTimes(1);
data_path
:
'
data/path
'
,
// expect(spy).toHaveBeenCalledWith(instanceActions.loadInstanceList());
config
:
{
// done();
design
:
{
// });
design_color
:
'
green
'
,
// });
design_background_color
:
'
darker green
'
,
design_logo
:
'
path/to/logo
'
,
design_favicon
:
'
path/to/favicon
'
},
home
:
{
home_component
:
'
HomeComponent
'
,
home_config
:
{
home_component_text
:
'
Description
'
,
home_component_logo
:
'
path/to/logo
'
}
},
search
:
{
search_by_criteria_allowed
:
true
,
search_by_criteria_label
:
'
Search
'
,
search_multiple_allowed
:
true
,
search_multiple_label
:
'
Search multiple
'
,
search_multiple_all_datasets_selected
:
false
},
documentation
:
{
documentation_allowed
:
true
,
documentation_label
:
'
Documentation
'
}
},
nb_dataset_families
:
1
,
nb_datasets
:
2
};
component
.
instance
=
of
(
instance
);
component
.
title
=
'
<title id="title">Default instance</title>
'
as
HTMLLinkElement
;
const
spy
=
jest
.
spyOn
(
store
,
'
dispatch
'
);
component
.
ngOnInit
();
Promise
.
resolve
(
null
).
then
(
function
()
{
expect
(
spy
).
toHaveBeenCalledTimes
(
3
);
expect
(
spy
).
toHaveBeenCalledWith
(
datasetFamilyActions
.
loadDatasetFamilyList
());
expect
(
spy
).
toHaveBeenCalledWith
(
datasetActions
.
loadDatasetList
());
expect
(
spy
).
toHaveBeenCalledWith
(
surveyActions
.
loadSurveyList
());
done
();
});
});
it
(
'
#getBaseHref() should return base href config key value
'
,
()
=>
{
it
(
'
#getBaseHref() should return base href config key value
'
,
()
=>
{
appConfigServiceStub
.
baseHref
=
'
/my-project
'
;
appConfigServiceStub
.
baseHref
=
'
/my-project
'
;
...
...
This diff is collapsed.
Click to expand it.
client/src/app/instance/instance.component.ts
+
1
−
0
View file @
9e535a9b
...
@@ -51,6 +51,7 @@ export class InstanceComponent implements OnInit, OnDestroy {
...
@@ -51,6 +51,7 @@ 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