@@ -3,7 +3,7 @@ import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
33import { DebugElement , EventEmitter , NO_ERRORS_SCHEMA } from '@angular/core' ;
44import { By } from '@angular/platform-browser' ;
55import { VocabularyService } from '../../../../../core/submission/vocabularies/vocabulary.service' ;
6- import { of as observableOf , BehaviorSubject } from 'rxjs' ;
6+ import { BehaviorSubject , of as observableOf } from 'rxjs' ;
77import { RemoteData } from '../../../../../core/data/remote-data' ;
88import { RequestEntryState } from '../../../../../core/data/request-entry-state.model' ;
99import { TranslateModule } from '@ngx-translate/core' ;
@@ -15,21 +15,24 @@ import { SearchService } from '../../../../../core/shared/search/search.service'
1515import {
1616 FILTER_CONFIG ,
1717 IN_PLACE_SEARCH ,
18- SearchFilterService ,
19- REFRESH_FILTER
18+ REFRESH_FILTER ,
19+ SearchFilterService
2020} from '../../../../../core/shared/search/search-filter.service' ;
2121import { RemoteDataBuildService } from '../../../../../core/cache/builders/remote-data-build.service' ;
2222import { Router } from '@angular/router' ;
2323import { NgbModal , NgbModule } from '@ng-bootstrap/ng-bootstrap' ;
2424import { SEARCH_CONFIG_SERVICE } from '../../../../../my-dspace-page/my-dspace-page.component' ;
2525import { SearchConfigurationServiceStub } from '../../../../testing/search-configuration-service.stub' ;
26- import { VocabularyEntryDetail } from '../../../../../core/submission/vocabularies/models/vocabulary-entry-detail.model' ;
27- import { FacetValue } from '../../../models/facet-value.model' ;
26+ import {
27+ VocabularyEntryDetail
28+ } from '../../../../../core/submission/vocabularies/models/vocabulary-entry-detail.model' ;
29+ import { FacetValue } from '../../../models/facet-value.model' ;
2830import { SearchFilterConfig } from '../../../models/search-filter-config.model' ;
2931
3032describe ( 'SearchHierarchyFilterComponent' , ( ) => {
3133
3234 let fixture : ComponentFixture < SearchHierarchyFilterComponent > ;
35+ let component : SearchHierarchyFilterComponent ;
3336 let showVocabularyTreeLink : DebugElement ;
3437
3538 const testSearchLink = 'test-search' ;
@@ -55,7 +58,7 @@ describe('SearchHierarchyFilterComponent', () => {
5558 searchTopEntries : ( ) => undefined ,
5659 } ;
5760
58- beforeEach ( ( ) => {
61+ beforeEach ( waitForAsync ( ( ) => {
5962 TestBed . configureTestingModule ( {
6063 imports : [
6164 CommonModule ,
@@ -79,21 +82,22 @@ describe('SearchHierarchyFilterComponent', () => {
7982 ] ,
8083 schemas : [ NO_ERRORS_SCHEMA ] ,
8184 } ) . compileComponents ( ) ;
82- } ) ;
85+ } ) ) ;
8386
8487 function init ( ) {
8588 fixture = TestBed . createComponent ( SearchHierarchyFilterComponent ) ;
86- fixture . detectChanges ( ) ;
87- showVocabularyTreeLink = fixture . debugElement . query ( By . css ( 'a#show-test-search-filter-tree' ) ) ;
89+ component = fixture . componentInstance ;
8890 }
8991
9092 describe ( 'if the vocabulary doesn\'t exist' , ( ) => {
9193
9294 beforeEach ( ( ) => {
95+ init ( ) ;
9396 spyOn ( vocabularyService , 'searchTopEntries' ) . and . returnValue ( observableOf ( new RemoteData (
9497 undefined , 0 , 0 , RequestEntryState . Error , undefined , undefined , 404
9598 ) ) ) ;
96- init ( ) ;
99+ fixture . detectChanges ( ) ;
100+ showVocabularyTreeLink = fixture . debugElement . query ( By . css ( 'a#show-test-search-filter-tree' ) ) ;
97101 } ) ;
98102
99103 it ( 'should not show the vocabulary tree link' , ( ) => {
@@ -104,10 +108,19 @@ describe('SearchHierarchyFilterComponent', () => {
104108 describe ( 'if the vocabulary exists' , ( ) => {
105109
106110 beforeEach ( ( ) => {
111+ init ( ) ;
112+ const pageInfo = new PageInfo ( {
113+ elementsPerPage : 1 ,
114+ totalElements : 1 ,
115+ totalPages : 1 ,
116+ currentPage : 1
117+ } ) ;
118+ spyOn ( component , 'getVocabularyEntry' ) . and . returnValue ( 'test' ) ;
107119 spyOn ( vocabularyService , 'searchTopEntries' ) . and . returnValue ( observableOf ( new RemoteData (
108- undefined , 0 , 0 , RequestEntryState . Success , undefined , buildPaginatedList ( new PageInfo ( ) , [ ] ) , 200
120+ undefined , 0 , 0 , RequestEntryState . Success , undefined , buildPaginatedList ( pageInfo , [ new VocabularyEntryDetail ( ) ] ) , 200
109121 ) ) ) ;
110- init ( ) ;
122+ fixture . detectChanges ( ) ;
123+ showVocabularyTreeLink = fixture . debugElement . query ( By . css ( '[data-test="btn-more"]' ) ) ;
111124 } ) ;
112125
113126 it ( 'should show the vocabulary tree link' , ( ) => {
0 commit comments