@@ -530,9 +530,7 @@ describe('CollectionsRepository', () => {
530530 expect ( ( actual . items [ 1 ] as CollectionPreview ) . name ) . toBe ( expectedCollectionsName )
531531 expect ( actual . facets ) . toEqual ( expectedFacetsFromCollectionAndFile )
532532
533- // Test sort and order
534-
535- // Sort by name ascending
533+ // Test Sort by name ascending
536534 const collectionSearchCriteriaNameAscending = new CollectionSearchCriteria ( )
537535 . withSort ( SortType . NAME )
538536 . withOrder ( OrderType . ASC )
@@ -549,7 +547,7 @@ describe('CollectionsRepository', () => {
549547 expect ( ( actual . items [ 1 ] as CollectionPreview ) . type ) . toBe ( CollectionItemType . COLLECTION )
550548 expect ( ( actual . items [ 2 ] as FilePreview ) . type ) . toBe ( CollectionItemType . FILE )
551549
552- // Sort by name descending
550+ // Test Sort by name descending
553551 const collectionSearchCriteriaNameDescending = new CollectionSearchCriteria ( )
554552 . withSort ( SortType . NAME )
555553 . withOrder ( OrderType . DESC )
@@ -566,7 +564,7 @@ describe('CollectionsRepository', () => {
566564 expect ( ( actual . items [ 1 ] as CollectionPreview ) . type ) . toBe ( CollectionItemType . COLLECTION )
567565 expect ( ( actual . items [ 2 ] as DatasetPreview ) . type ) . toBe ( CollectionItemType . DATASET )
568566
569- // Sort by date ascending
567+ // Test Sort by date ascending
570568 const collectionSearchCriteriaDateAscending = new CollectionSearchCriteria ( )
571569 . withSort ( SortType . DATE )
572570 . withOrder ( OrderType . ASC )
@@ -583,7 +581,7 @@ describe('CollectionsRepository', () => {
583581 expect ( ( actual . items [ 1 ] as DatasetPreview ) . type ) . toBe ( CollectionItemType . DATASET )
584582 expect ( ( actual . items [ 2 ] as FilePreview ) . type ) . toBe ( CollectionItemType . FILE )
585583
586- // Sort by date descending
584+ // Test Sort by date descending
587585 const collectionSearchCriteriaDateDescending = new CollectionSearchCriteria ( )
588586 . withSort ( SortType . DATE )
589587 . withOrder ( OrderType . DESC )
@@ -599,6 +597,54 @@ describe('CollectionsRepository', () => {
599597 expect ( ( actual . items [ 0 ] as FilePreview ) . type ) . toBe ( CollectionItemType . FILE )
600598 expect ( ( actual . items [ 1 ] as DatasetPreview ) . type ) . toBe ( CollectionItemType . DATASET )
601599 expect ( ( actual . items [ 2 ] as CollectionPreview ) . type ) . toBe ( CollectionItemType . COLLECTION )
600+
601+ // Test with Filter query related to the collection
602+ const collectionSearchCriteriaFilterQueryCollection =
603+ new CollectionSearchCriteria ( ) . withFilterQueries ( [ 'dvCategory:Laboratory' ] )
604+
605+ actual = await sut . getCollectionItems (
606+ testCollectionAlias ,
607+ undefined ,
608+ undefined ,
609+ collectionSearchCriteriaFilterQueryCollection
610+ )
611+ expect ( actual . items . length ) . toBe ( 1 )
612+ expect ( actual . totalItemCount ) . toBe ( 1 )
613+ expect ( ( actual . items [ 0 ] as CollectionPreview ) . name ) . toBe ( expectedCollectionsName )
614+ expect ( actual . facets ) . toEqual ( expectedFacetsFromCollectionOnly )
615+
616+ // Test with Filter query related to the dataset
617+ const collectionSearchCriteriaFilterQueryDataset =
618+ new CollectionSearchCriteria ( ) . withFilterQueries ( [
619+ 'subject_ss:Medicine, Health and Life Sciences'
620+ ] )
621+
622+ actual = await sut . getCollectionItems (
623+ testCollectionAlias ,
624+ undefined ,
625+ undefined ,
626+ collectionSearchCriteriaFilterQueryDataset
627+ )
628+ expect ( actual . items . length ) . toBe ( 1 )
629+ expect ( actual . totalItemCount ) . toBe ( 1 )
630+ expect ( ( actual . items [ 0 ] as DatasetPreview ) . title ) . toBe ( expectedDatasetDescription )
631+ expect ( actual . facets ) . toEqual ( expectedFacetsFromDatasetOnly )
632+
633+ // Test with Filter query related to the file
634+ const collectionSearchCriteriaFilterQuerieCollAndFile =
635+ new CollectionSearchCriteria ( ) . withFilterQueries ( [ 'fileAccess:Public' ] )
636+
637+ actual = await sut . getCollectionItems (
638+ testCollectionAlias ,
639+ undefined ,
640+ undefined ,
641+ collectionSearchCriteriaFilterQuerieCollAndFile
642+ )
643+
644+ expect ( actual . items . length ) . toBe ( 1 )
645+ expect ( actual . totalItemCount ) . toBe ( 1 )
646+ expect ( ( actual . items [ 0 ] as FilePreview ) . name ) . toBe ( expectedFileName )
647+ expect ( actual . facets ) . toEqual ( expectedFacetsFromFileOnly )
602648 } )
603649
604650 test ( 'should return error when collection does not exist' , async ( ) => {
0 commit comments