11import { ComponentFixture , fakeAsync , TestBed , tick , waitForAsync } from '@angular/core/testing' ;
2- import { ChangeDetectionStrategy , NO_ERRORS_SCHEMA } from '@angular/core' ;
32import { ListableObjectComponentLoaderComponent } from './listable-object-component-loader.component' ;
43import { ListableObject } from '../listable-object.model' ;
54import { GenericConstructor } from '../../../../core/shared/generic-constructor' ;
65import { Context } from '../../../../core/shared/context.model' ;
76import { ViewMode } from '../../../../core/shared/view-mode.model' ;
8- import {
9- ItemListElementComponent
10- } from '../../../object-list/item-list-element/item-types/item/item-list-element.component' ;
117import { ListableObjectDirective } from './listable-object.directive' ;
128import { TranslateModule } from '@ngx-translate/core' ;
139import { By } from '@angular/platform-browser' ;
14- import { provideMockStore } from '@ngrx/store/testing' ;
1510import { ThemeService } from '../../../theme-support/theme.service' ;
11+ import { ItemSearchResultListElementComponent } from '../../../object-list/search-result-list-element/item-search-result/item-types/item/item-search-result-list-element.component' ;
12+ import { ActivatedRouteStub } from '../../../testing/active-router.stub' ;
13+ import { AuthServiceStub } from '../../../testing/auth-service.stub' ;
14+ import { AuthorizationDataServiceStub } from '../../../testing/authorization-service.stub' ;
15+ import { FileServiceStub } from '../../../testing/file-service.stub' ;
16+ import { TruncatableServiceStub } from '../../../testing/truncatable-service.stub' ;
17+ import { getMockThemeService } from '../../../mocks/theme-service.mock' ;
18+ import { APP_CONFIG } from '../../../../../config/app-config.interface' ;
19+ import { environment } from '../../../../../environments/environment.test' ;
20+ import { ActivatedRoute } from '@angular/router' ;
21+ import { AuthService } from '../../../../core/auth/auth.service' ;
22+ import { AuthorizationDataService } from '../../../../core/data/feature-authorization/authorization-data.service' ;
23+ import { DSONameService } from '../../../../core/breadcrumbs/dso-name.service' ;
24+ import { DSONameServiceMock } from '../../../mocks/dso-name.service.mock' ;
25+ import { FileService } from '../../../../core/shared/file.service' ;
26+ import { TruncatableService } from '../../../truncatable/truncatable.service' ;
27+ import { ChangeDetectionStrategy } from '@angular/core' ;
28+ import { SearchResultListElementComponent } from '../../../object-list/search-result-list-element/search-result-list-element.component' ;
1629
1730const testType = 'TestType' ;
1831const testContext = Context . Search ;
@@ -28,24 +41,41 @@ describe('ListableObjectComponentLoaderComponent', () => {
2841 let comp : ListableObjectComponentLoaderComponent ;
2942 let fixture : ComponentFixture < ListableObjectComponentLoaderComponent > ;
3043
44+ let activatedRoute : ActivatedRouteStub ;
45+ let authService : AuthServiceStub ;
46+ let authorizationService : AuthorizationDataServiceStub ;
47+ let fileService : FileServiceStub ;
3148 let themeService : ThemeService ;
49+ let truncatableService : TruncatableServiceStub ;
3250
3351 beforeEach ( waitForAsync ( ( ) => {
34- themeService = jasmine . createSpyObj ( 'themeService' , {
35- getThemeName : 'dspace' ,
36- } ) ;
37- TestBed . configureTestingModule ( {
52+ activatedRoute = new ActivatedRouteStub ( ) ;
53+ authService = new AuthServiceStub ( ) ;
54+ authorizationService = new AuthorizationDataServiceStub ( ) ;
55+ fileService = new FileServiceStub ( ) ;
56+ themeService = getMockThemeService ( ) ;
57+ truncatableService = new TruncatableServiceStub ( ) ;
58+
59+ void TestBed . configureTestingModule ( {
3860 imports : [ TranslateModule . forRoot ( ) ] ,
39- declarations : [ ListableObjectComponentLoaderComponent , ItemListElementComponent , ListableObjectDirective ] ,
40- schemas : [ NO_ERRORS_SCHEMA ] ,
61+ declarations : [
62+ ItemSearchResultListElementComponent ,
63+ ListableObjectComponentLoaderComponent ,
64+ ListableObjectDirective ,
65+ ] ,
4166 providers : [
42- provideMockStore ( { } ) ,
67+ { provide : APP_CONFIG , useValue : environment } ,
68+ { provide : ActivatedRoute , useValue : activatedRoute } ,
69+ { provide : AuthService , useValue : authService } ,
70+ { provide : AuthorizationDataService , useValue : authorizationService } ,
71+ { provide : DSONameService , useValue : new DSONameServiceMock ( ) } ,
72+ { provide : FileService , useValue : fileService } ,
4373 { provide : ThemeService , useValue : themeService } ,
74+ { provide : TruncatableService , useValue : truncatableService } ,
4475 ]
4576 } ) . overrideComponent ( ListableObjectComponentLoaderComponent , {
4677 set : {
4778 changeDetection : ChangeDetectionStrategy . Default ,
48- entryComponents : [ ItemListElementComponent ]
4979 }
5080 } ) . compileComponents ( ) ;
5181 } ) ) ;
@@ -57,7 +87,7 @@ describe('ListableObjectComponentLoaderComponent', () => {
5787 comp . object = new TestType ( ) ;
5888 comp . viewMode = testViewMode ;
5989 comp . context = testContext ;
60- spyOn ( comp , 'getComponent' ) . and . returnValue ( ItemListElementComponent as any ) ;
90+ spyOn ( comp , 'getComponent' ) . and . returnValue ( SearchResultListElementComponent as any ) ;
6191 spyOn ( comp as any , 'connectInputsAndOutputs' ) . and . callThrough ( ) ;
6292 fixture . detectChanges ( ) ;
6393
@@ -81,7 +111,7 @@ describe('ListableObjectComponentLoaderComponent', () => {
81111 spyOn ( ( comp as any ) , 'instantiateComponent' ) . and . returnValue ( null ) ;
82112 spyOn ( ( comp as any ) . contentChange , 'emit' ) . and . returnValue ( null ) ;
83113
84- listableComponent = fixture . debugElement . query ( By . css ( 'ds-item -list-element' ) ) . componentInstance ;
114+ listableComponent = fixture . debugElement . query ( By . css ( 'ds-search-result -list-element' ) ) . componentInstance ;
85115 reloadedObject = 'object' ;
86116 } ) ;
87117
0 commit comments