@@ -5,7 +5,6 @@ import { By } from '@angular/platform-browser';
55import { Component , NO_ERRORS_SCHEMA } from '@angular/core' ;
66import { of as observableOf } from 'rxjs' ;
77import { CommonModule } from '@angular/common' ;
8- import { Item } from '../../core/shared/item.model' ;
98import { buildPaginatedList } from '../../core/data/paginated-list.model' ;
109import { PageInfo } from '../../core/shared/page-info.model' ;
1110import { NgbModule } from '@ng-bootstrap/ng-bootstrap' ;
@@ -48,10 +47,10 @@ import { SharedModule } from '../shared.module';
4847import { BrowseByRoutingModule } from '../../browse-by/browse-by-routing.module' ;
4948import { AccessControlRoutingModule } from '../../access-control/access-control-routing.module' ;
5049
51- @listableObjectComponent ( BrowseEntry , ViewMode . ListElement , DEFAULT_CONTEXT , 'custom ' )
50+ @listableObjectComponent ( BrowseEntry , ViewMode . ListElement , DEFAULT_CONTEXT , 'dspace ' )
5251@Component ( {
5352 // eslint-disable-next-line @angular-eslint/component-selector
54- selector : '' ,
53+ selector : 'ds-browse-entry-list-element ' ,
5554 template : ''
5655} )
5756class MockThemedBrowseEntryListElementComponent {
@@ -61,28 +60,6 @@ describe('BrowseByComponent', () => {
6160 let comp : BrowseByComponent ;
6261 let fixture : ComponentFixture < BrowseByComponent > ;
6362
64- const mockItems = [
65- Object . assign ( new Item ( ) , {
66- id : 'fakeId-1' ,
67- metadata : [
68- {
69- key : 'dc.title' ,
70- value : 'First Fake Title'
71- }
72- ]
73- } ) ,
74- Object . assign ( new Item ( ) , {
75- id : 'fakeId-2' ,
76- metadata : [
77- {
78- key : 'dc.title' ,
79- value : 'Second Fake Title'
80- }
81- ]
82- } )
83- ] ;
84- const mockItemsRD$ = createSuccessfulRemoteDataObject$ ( buildPaginatedList ( new PageInfo ( ) , mockItems ) ) ;
85-
8663 const groupDataService = jasmine . createSpyObj ( 'groupsDataService' , {
8764 findListByHref : createSuccessfulRemoteDataObject$ ( createPaginatedList ( [ ] ) ) ,
8865 getGroupRegistryRouterLink : '' ,
@@ -113,8 +90,8 @@ describe('BrowseByComponent', () => {
11390 let themeService ;
11491
11592 beforeEach ( waitForAsync ( ( ) => {
116- themeService = getMockThemeService ( 'dspace ' ) ;
117- TestBed . configureTestingModule ( {
93+ themeService = getMockThemeService ( 'base ' ) ;
94+ void TestBed . configureTestingModule ( {
11895 imports : [
11996 BrowseByRoutingModule ,
12097 AccessControlRoutingModule ,
@@ -200,40 +177,40 @@ describe('BrowseByComponent', () => {
200177 } ) ;
201178
202179 describe ( 'when theme is base' , ( ) => {
203- beforeEach ( ( ) => {
180+ beforeEach ( async ( ) => {
204181 themeService . getThemeName . and . returnValue ( 'base' ) ;
205182 themeService . getThemeName$ . and . returnValue ( observableOf ( 'base' ) ) ;
206183 fixture . detectChanges ( ) ;
184+ await fixture . whenStable ( ) ;
185+ fixture . detectChanges ( ) ;
207186 } ) ;
208187
209188 it ( 'should use the base component to render browse entries' , ( ) => {
210- waitForAsync ( ( ) => {
211- const componentLoaders = fixture . debugElement . queryAll ( By . directive ( ListableObjectComponentLoaderComponent ) ) ;
212- expect ( componentLoaders . length ) . toEqual ( browseEntries . length ) ;
213- componentLoaders . forEach ( ( componentLoader ) => {
214- const browseEntry = componentLoader . query ( By . css ( 'ds-browse-entry-list-element' ) ) ;
215- expect ( browseEntry . componentInstance ) . toBeInstanceOf ( BrowseEntryListElementComponent ) ;
216- } ) ;
189+ const componentLoaders = fixture . debugElement . queryAll ( By . directive ( ListableObjectComponentLoaderComponent ) ) ;
190+ expect ( componentLoaders . length ) . toEqual ( browseEntries . length ) ;
191+ componentLoaders . forEach ( ( componentLoader ) => {
192+ const browseEntry = componentLoader . query ( By . css ( 'ds-browse-entry-list-element' ) ) ;
193+ expect ( browseEntry . componentInstance ) . toBeInstanceOf ( BrowseEntryListElementComponent ) ;
217194 } ) ;
218195 } ) ;
219196 } ) ;
220197
221- describe ( 'when theme is custom' , ( ) => {
222- beforeEach ( ( ) => {
223- themeService . getThemeName . and . returnValue ( 'custom' ) ;
224- themeService . getThemeName$ . and . returnValue ( observableOf ( 'custom' ) ) ;
198+ describe ( 'when theme is dspace' , ( ) => {
199+ beforeEach ( async ( ) => {
200+ themeService . getThemeName . and . returnValue ( 'dspace' ) ;
201+ themeService . getThemeName$ . and . returnValue ( observableOf ( 'dspace' ) ) ;
202+ fixture . detectChanges ( ) ;
203+ await fixture . whenStable ( ) ;
225204 fixture . detectChanges ( ) ;
226205 } ) ;
227206
228207 it ( 'should use the themed component to render browse entries' , ( ) => {
229- waitForAsync ( ( ) => {
230208 const componentLoaders = fixture . debugElement . queryAll ( By . directive ( ListableObjectComponentLoaderComponent ) ) ;
231209 expect ( componentLoaders . length ) . toEqual ( browseEntries . length ) ;
232210 componentLoaders . forEach ( ( componentLoader ) => {
233211 const browseEntry = componentLoader . query ( By . css ( 'ds-browse-entry-list-element' ) ) ;
234212 expect ( browseEntry . componentInstance ) . toBeInstanceOf ( MockThemedBrowseEntryListElementComponent ) ;
235213 } ) ;
236- } ) ;
237214 } ) ;
238215 } ) ;
239216 } ) ;
0 commit comments