@@ -15,6 +15,12 @@ import { FacetValue } from '../../../search/facet-value.model';
1515import { FilterType } from '../../../search/filter-type.model' ;
1616import { SearchFilterConfig } from '../../../search/search-filter-config.model' ;
1717import { FacetSectionComponent } from './facet-section.component' ;
18+ import { SEARCH_CONFIG_SERVICE } from '../../../../my-dspace-page/my-dspace-page.component' ;
19+ import { SearchConfigurationServiceStub } from '../../../testing/search-configuration-service.stub' ;
20+ import { StoreModule } from '@ngrx/store' ;
21+ import { authReducer } from '../../../../core/auth/auth.reducer' ;
22+ import { storeModuleConfig } from '../../../../app.reducer' ;
23+ import { isNotNull } from '../../../empty.util' ;
1824
1925describe ( 'FacetSectionComponent' , ( ) => {
2026 let component : FacetSectionComponent ;
@@ -75,12 +81,43 @@ describe('FacetSectionComponent', () => {
7581 values : [ dateIssuedValue ]
7682 }
7783 } ) ;
78-
84+ const barChartFacetValue : FacetValue = {
85+ label : '2007' ,
86+ value : '2007' ,
87+ count : 13 ,
88+ _links : {
89+ self : { href : 'fa-selectedValue-self-link' } ,
90+ search : { href : '' }
91+ }
92+ } ;
93+ const mockGraphBarChartFilterConfig = Object . assign ( new SearchFilterConfig ( ) , {
94+ name : 'dateIssued' ,
95+ filterType : FilterType [ 'chart.bar' ] ,
96+ _embedded : {
97+ values : [ barChartFacetValue ]
98+ }
99+ } ) ;
100+ const pieChartFacetValue : FacetValue = {
101+ label : 'Other' ,
102+ value : 'Other' ,
103+ count : 13 ,
104+ _links : {
105+ self : { href : 'fa-selectedValue-self-link' } ,
106+ search : { href : '' }
107+ }
108+ } ;
109+ const mockGraphPieChartFilterConfig = Object . assign ( new SearchFilterConfig ( ) , {
110+ name : 'dateIssued' ,
111+ filterType : FilterType [ 'chart.pie' ] ,
112+ _embedded : {
113+ values : [ pieChartFacetValue ]
114+ }
115+ } ) ;
79116 beforeEach ( async ( ( ) => {
80117
81118 searchServiceStub = {
82119 searchFacets ( scope ?: string , configurationName ?: string ) : Observable < RemoteData < SearchFilterConfig [ ] > > {
83- return createSuccessfulRemoteDataObject$ ( [ mockAuthorFilterConfig , mockSubjectFilterConfig , mockDateIssuedFilterConfig ] ) ;
120+ return createSuccessfulRemoteDataObject$ ( [ mockAuthorFilterConfig , mockSubjectFilterConfig , mockDateIssuedFilterConfig , mockGraphBarChartFilterConfig , mockGraphPieChartFilterConfig ] ) ;
84121 } ,
85122 getSearchLink ( ) : string {
86123 return '/search' ;
@@ -89,6 +126,7 @@ describe('FacetSectionComponent', () => {
89126
90127 TestBed . configureTestingModule ( {
91128 imports : [ CommonModule , NgbModule , FormsModule , ReactiveFormsModule , BrowserModule , RouterTestingModule ,
129+ StoreModule . forRoot ( { auth : authReducer } , storeModuleConfig ) ,
92130 TranslateModule . forRoot ( {
93131 loader : {
94132 provide : TranslateLoader ,
@@ -98,7 +136,8 @@ describe('FacetSectionComponent', () => {
98136 ] ,
99137 declarations : [ FacetSectionComponent ] ,
100138 providers : [ FacetSectionComponent ,
101- { provide : SearchService , useValue : searchServiceStub } ] ,
139+ { provide : SearchService , useValue : searchServiceStub } ,
140+ { provide : SEARCH_CONFIG_SERVICE , useValue : new SearchConfigurationServiceStub ( ) } ] ,
102141 schemas : [ NO_ERRORS_SCHEMA ]
103142 } ) . compileComponents ( ) ;
104143
@@ -124,6 +163,20 @@ describe('FacetSectionComponent', () => {
124163 } ) ) ;
125164
126165 it ( 'should create a facet section foreach not empty filter configs' , ( ) => {
166+ // graph facets control
167+ const graphFacets = fixture . debugElement . queryAll ( By . css ( '.col-6.mb-4' ) ) ;
168+ expect ( graphFacets . length ) . toEqual ( 2 ) ;
169+ const barChartFacet = graphFacets [ 0 ] ;
170+ expect ( barChartFacet . name ) . toEqual ( 'div' ) ;
171+ expect ( barChartFacet . children . length ) . toEqual ( 2 ) ;
172+ const barChartComponent = barChartFacet . query ( By . css ( 'ds-search-chart' ) ) ;
173+ expect ( isNotNull ( barChartComponent ) ) . toBe ( true ) ;
174+ const pieChartFacet = graphFacets [ 1 ] ;
175+ expect ( pieChartFacet . children . length ) . toEqual ( 2 ) ;
176+ expect ( pieChartFacet . name ) . toEqual ( 'div' ) ;
177+ const pieChartComponent = pieChartFacet . query ( By . css ( 'ds-search-chart' ) ) ;
178+ expect ( isNotNull ( pieChartComponent ) ) . toBe ( true ) ;
179+
127180 const facets = fixture . debugElement . queryAll ( By . css ( '.col-3.mb-4' ) ) ;
128181 expect ( facets . length ) . toEqual ( 2 ) ;
129182
0 commit comments