1- import {
2- ChangeDetectionStrategy ,
3- NO_ERRORS_SCHEMA ,
4- } from '@angular/core' ;
1+ import { ChangeDetectionStrategy } from '@angular/core' ;
52import {
63 ComponentFixture ,
74 fakeAsync ,
@@ -11,29 +8,31 @@ import {
118} from '@angular/core/testing' ;
129import { By } from '@angular/platform-browser' ;
1310import { ActivatedRoute } from '@angular/router' ;
14- import { provideMockStore } from '@ngrx/store/testing' ;
1511import { TranslateModule } from '@ngx-translate/core' ;
16- import { of } from 'rxjs' ;
17- import { AuthRequestService } from 'src/app/core/auth/auth-request.service' ;
18- import { CookieService } from 'src/app/core/services/cookie.service' ;
19- import { HardRedirectService } from 'src/app/core/services/hard-redirect.service' ;
20- import { XSRFService } from 'src/app/core/xsrf/xsrf.service' ;
21- import { CookieServiceMock } from 'src/app/shared/mocks/cookie.service.mock' ;
22- import { getMockThemeService } from 'src/app/shared/mocks/theme-service.mock' ;
23- import { AuthRequestServiceStub } from 'src/app/shared/testing/auth-request-service.stub' ;
2412
25- import {
26- APP_CONFIG ,
27- APP_DATA_SERVICES_MAP ,
28- } from '../../../../../config/app-config.interface ' ;
29- import { REQUEST } from '../../../../../express.tokens ' ;
13+ import { APP_CONFIG } from '../../../../../config/app-config.interface' ;
14+ import { environment } from '../../../../../environments/environment.test' ;
15+ import { AuthService } from '../../../../core/auth/auth.service' ;
16+ import { DSONameService } from '../../../../core/breadcrumbs/dso-name.service ' ;
17+ import { AuthorizationDataService } from '../../../../core/data/feature-authorization/authorization-data.service ' ;
3018import { Context } from '../../../../core/shared/context.model' ;
19+ import { FileService } from '../../../../core/shared/file.service' ;
3120import { GenericConstructor } from '../../../../core/shared/generic-constructor' ;
3221import { ListableModule } from '../../../../core/shared/listable.module' ;
3322import { ViewMode } from '../../../../core/shared/view-mode.model' ;
23+ import { XSRFService } from '../../../../core/xsrf/xsrf.service' ;
3424import { DynamicComponentLoaderDirective } from '../../../abstract-component-loader/dynamic-component-loader.directive' ;
25+ import { DSONameServiceMock } from '../../../mocks/dso-name.service.mock' ;
26+ import { getMockThemeService } from '../../../mocks/theme-service.mock' ;
3527import { ItemListElementComponent } from '../../../object-list/item-list-element/item-types/item/item-list-element.component' ;
28+ import { SearchResultListElementComponent } from '../../../object-list/search-result-list-element/search-result-list-element.component' ;
29+ import { ActivatedRouteStub } from '../../../testing/active-router.stub' ;
30+ import { AuthServiceStub } from '../../../testing/auth-service.stub' ;
31+ import { AuthorizationDataServiceStub } from '../../../testing/authorization-service.stub' ;
32+ import { FileServiceStub } from '../../../testing/file-service.stub' ;
33+ import { TruncatableServiceStub } from '../../../testing/truncatable-service.stub' ;
3634import { ThemeService } from '../../../theme-support/theme.service' ;
35+ import { TruncatableService } from '../../../truncatable/truncatable.service' ;
3736import { ListableObject } from '../listable-object.model' ;
3837import { ListableObjectComponentLoaderComponent } from './listable-object-component-loader.component' ;
3938
@@ -57,30 +56,39 @@ describe('ListableObjectComponentLoaderComponent', () => {
5756 let comp : ListableObjectComponentLoaderComponent ;
5857 let fixture : ComponentFixture < ListableObjectComponentLoaderComponent > ;
5958
59+ let activatedRoute : ActivatedRouteStub ;
60+ let authService : AuthServiceStub ;
61+ let authorizationService : AuthorizationDataServiceStub ;
62+ let fileService : FileServiceStub ;
63+ let themeService : ThemeService ;
64+ let truncatableService : TruncatableServiceStub ;
65+
6066 beforeEach ( waitForAsync ( ( ) => {
61- TestBed . configureTestingModule ( {
67+ activatedRoute = new ActivatedRouteStub ( ) ;
68+ authService = new AuthServiceStub ( ) ;
69+ authorizationService = new AuthorizationDataServiceStub ( ) ;
70+ fileService = new FileServiceStub ( ) ;
71+ themeService = getMockThemeService ( ) ;
72+ truncatableService = new TruncatableServiceStub ( ) ;
73+
74+ void TestBed . configureTestingModule ( {
6275 imports : [
6376 TranslateModule . forRoot ( ) ,
6477 ListableObjectComponentLoaderComponent ,
6578 ListableModule ,
6679 ItemListElementComponent ,
6780 DynamicComponentLoaderDirective ,
6881 ] ,
69- schemas : [ NO_ERRORS_SCHEMA ] ,
7082 providers : [
71- { provide : HardRedirectService , useValue : jasmine . createSpyObj ( 'hardRedirectService' , [ 'redirect' ] ) } ,
72- { provide : AuthRequestService , useValue : new AuthRequestServiceStub ( ) } ,
73- { provide : CookieService , useValue : new CookieServiceMock ( ) } ,
83+ { provide : APP_CONFIG , useValue : environment } ,
84+ { provide : ActivatedRoute , useValue : activatedRoute } ,
85+ { provide : AuthService , useValue : authService } ,
86+ { provide : AuthorizationDataService , useValue : authorizationService } ,
87+ { provide : DSONameService , useValue : new DSONameServiceMock ( ) } ,
88+ { provide : FileService , useValue : fileService } ,
89+ { provide : ThemeService , useValue : themeService } ,
90+ { provide : TruncatableService , useValue : truncatableService } ,
7491 { provide : XSRFService , useValue : { } } ,
75- { provide : REQUEST , useValue : { } } ,
76- {
77- provide : ActivatedRoute ,
78- useValue : { data : of ( { dso : { payload : { } } } ) , params : of ( { } ) } ,
79- } ,
80- provideMockStore ( { } ) ,
81- { provide : ThemeService , useValue : getMockThemeService ( 'dspace' ) } ,
82- { provide : APP_CONFIG , useValue : { browseBy : { showThumbnails : true } } } ,
83- { provide : APP_DATA_SERVICES_MAP , useValue : { } } ,
8492 ] ,
8593 } ) . overrideComponent ( ListableObjectComponentLoaderComponent , {
8694 set : {
@@ -95,7 +103,7 @@ describe('ListableObjectComponentLoaderComponent', () => {
95103 comp . object = new TestType ( ) ;
96104 comp . viewMode = testViewMode ;
97105 comp . context = testContext ;
98- spyOn ( comp , 'getComponent' ) . and . returnValue ( ItemListElementComponent as any ) ;
106+ spyOn ( comp , 'getComponent' ) . and . returnValue ( SearchResultListElementComponent as any ) ;
99107 spyOn ( comp as any , 'connectInputsAndOutputs' ) . and . callThrough ( ) ;
100108 fixture . detectChanges ( ) ;
101109
@@ -119,7 +127,7 @@ describe('ListableObjectComponentLoaderComponent', () => {
119127 spyOn ( comp , 'instantiateComponent' ) . and . returnValue ( null ) ;
120128 spyOn ( comp . contentChange , 'emit' ) . and . returnValue ( null ) ;
121129
122- listableComponent = fixture . debugElement . query ( By . css ( 'ds-item -list-element' ) ) . componentInstance ;
130+ listableComponent = fixture . debugElement . query ( By . css ( 'ds-search-result -list-element' ) ) . componentInstance ;
123131 reloadedObject = 'object' ;
124132 } ) ;
125133
0 commit comments