Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Dspace7 Angular
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
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
vtechworks
Dspace7 Angular
Commits
e1c734e1
Commit
e1c734e1
authored
6 years ago
by
Kristof De Langhe
Browse files
Options
Downloads
Patches
Plain Diff
55693: CollectionItemMapperComponent test intermediate
parent
0a8a6bb7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/app/+collection-page/collection-item-mapper/collection-item-mapper.component.spec.ts
+83
-0
83 additions, 0 deletions
...tion-item-mapper/collection-item-mapper.component.spec.ts
src/app/shared/testing/active-router-stub.ts
+19
-1
19 additions, 1 deletion
src/app/shared/testing/active-router-stub.ts
with
102 additions
and
1 deletion
src/app/+collection-page/collection-item-mapper/collection-item-mapper.component.spec.ts
+
83
−
0
View file @
e1c734e1
import
{
CollectionItemMapperComponent
}
from
'
./collection-item-mapper.component
'
;
import
{
async
,
ComponentFixture
,
TestBed
}
from
'
@angular/core/testing
'
;
import
{
RouterTestingModule
}
from
'
@angular/router/testing
'
;
import
{
NgbModule
}
from
'
@ng-bootstrap/ng-bootstrap
'
;
import
{
CommonModule
}
from
'
@angular/common
'
;
import
{
TranslateModule
,
TranslateService
}
from
'
@ngx-translate/core
'
;
import
{
SearchFormComponent
}
from
'
../../shared/search-form/search-form.component
'
;
import
{
SearchPageModule
}
from
'
../../+search-page/search-page.module
'
;
import
{
ObjectCollectionComponent
}
from
'
../../shared/object-collection/object-collection.component
'
;
import
{
ItemSelectComponent
}
from
'
../../shared/item-select/item-select.component
'
;
import
{
ActivatedRoute
,
Router
}
from
'
@angular/router
'
;
import
{
ActivatedRouteStub
}
from
'
../../shared/testing/active-router-stub
'
;
import
{
RouterStub
}
from
'
../../shared/testing/router-stub
'
;
import
{
SearchConfigurationService
}
from
'
../../+search-page/search-service/search-configuration.service
'
;
import
{
SearchService
}
from
'
../../+search-page/search-service/search.service
'
;
import
{
SearchServiceStub
}
from
'
../../shared/testing/search-service-stub
'
;
import
{
NotificationsService
}
from
'
../../shared/notifications/notifications.service
'
;
import
{
NotificationsServiceStub
}
from
'
../../shared/testing/notifications-service-stub
'
;
import
{
ItemDataService
}
from
'
../../core/data/item-data.service
'
;
import
{
FormsModule
}
from
'
@angular/forms
'
;
import
{
SharedModule
}
from
'
../../shared/shared.module
'
;
import
{
Collection
}
from
'
../../core/shared/collection.model
'
;
fdescribe
(
'
CollectionItemMapperComponent
'
,
()
=>
{
let
comp
:
CollectionItemMapperComponent
;
let
fixture
:
ComponentFixture
<
CollectionItemMapperComponent
>
;
let
route
:
ActivatedRoute
;
let
router
:
Router
;
let
searchConfigService
:
SearchConfigurationService
;
let
searchService
:
SearchService
;
let
notificationsService
:
NotificationsService
;
let
itemDataService
:
ItemDataService
;
const
searchConfigServiceStub
=
{
};
const
itemDataServiceStub
=
{
};
const
mockCollection
:
Collection
=
Object
.
assign
(
new
Collection
(),
{
metadata
:
[
{
key
:
'
dc.title
'
,
language
:
'
en_US
'
,
value
:
'
Test title
'
}]
});
const
activatedRouteStub
=
new
ActivatedRouteStub
({},
{
collection
:
mockCollection
});
beforeEach
(
async
(()
=>
{
TestBed
.
configureTestingModule
({
imports
:
[
CommonModule
,
FormsModule
,
SharedModule
,
RouterTestingModule
.
withRoutes
([]),
TranslateModule
.
forRoot
(),
NgbModule
.
forRoot
()],
declarations
:
[
CollectionItemMapperComponent
],
providers
:
[
{
provide
:
ActivatedRoute
,
useValue
:
activatedRouteStub
},
{
provide
:
Router
,
useValue
:
new
RouterStub
()
},
{
provide
:
SearchConfigurationService
,
useValue
:
searchConfigServiceStub
},
{
provide
:
SearchService
,
useValue
:
new
SearchServiceStub
()
},
{
provide
:
NotificationsService
,
useValue
:
new
NotificationsServiceStub
()
},
{
provide
:
ItemDataService
,
useValue
:
itemDataServiceStub
},
{
provide
:
TranslateService
,
useValue
:
{}
}
]
}).
compileComponents
();
}));
beforeEach
(()
=>
{
fixture
=
TestBed
.
createComponent
(
CollectionItemMapperComponent
);
comp
=
fixture
.
componentInstance
;
fixture
.
detectChanges
();
route
=
(
comp
as
any
).
route
;
router
=
(
comp
as
any
).
router
;
searchConfigService
=
(
comp
as
any
).
searchConfigService
;
searchService
=
(
comp
as
any
).
searchService
;
notificationsService
=
(
comp
as
any
).
notificationsService
;
itemDataService
=
(
comp
as
any
).
itemDataService
;
});
it
(
'
should test
'
,
()
=>
{
});
});
This diff is collapsed.
Click to expand it.
src/app/shared/testing/active-router-stub.ts
+
19
−
1
View file @
e1c734e1
...
...
@@ -5,19 +5,27 @@ import { BehaviorSubject } from 'rxjs/BehaviorSubject';
export
class
ActivatedRouteStub
{
private
_testParams
?:
any
;
private
_testData
?:
any
;
// ActivatedRoute.params is Observable
private
subject
?:
BehaviorSubject
<
any
>
=
new
BehaviorSubject
(
this
.
testParams
);
private
dataSubject
?:
BehaviorSubject
<
any
>
=
new
BehaviorSubject
(
this
.
testData
);
params
=
this
.
subject
.
asObservable
();
queryParams
=
this
.
subject
.
asObservable
();
queryParamMap
=
this
.
subject
.
asObservable
().
map
((
params
:
Params
)
=>
convertToParamMap
(
params
));
data
=
this
.
dataSubject
.
asObservable
();
constructor
(
params
?:
Params
)
{
constructor
(
params
?:
Params
,
data
?:
any
)
{
if
(
params
)
{
this
.
testParams
=
params
;
}
else
{
this
.
testParams
=
{};
}
if
(
data
)
{
this
.
testData
=
data
;
}
else
{
this
.
testData
=
{};
}
}
// Test parameters
...
...
@@ -30,6 +38,16 @@ export class ActivatedRouteStub {
this
.
subject
.
next
(
params
);
}
// Test data
get
testData
()
{
return
this
.
_testParams
;
}
set
testData
(
data
:
{})
{
this
.
_testData
=
data
;
this
.
dataSubject
.
next
(
data
);
}
// ActivatedRoute.snapshot.params
get
snapshot
()
{
return
{
...
...
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