@@ -7,6 +7,29 @@ import { Collection } from '../../../core/shared/collection.model';
77let collectionListElementComponent : CollectionListElementComponent ;
88let fixture : ComponentFixture < CollectionListElementComponent > ;
99
10+ const mockCollectionWithArchivedItems : Collection = Object . assign ( new Collection ( ) , {
11+ metadata : {
12+ 'dc.title' : [
13+ {
14+ language : 'en_US' ,
15+ value : 'Test title'
16+ }
17+ ]
18+ } , archivedItems : 1
19+ } ) ;
20+
21+ const mockCollectionWithoutArchivedItems : Collection = Object . assign ( new Collection ( ) , {
22+ metadata : {
23+ 'dc.title' : [
24+ {
25+ language : 'en_US' ,
26+ value : 'Test title'
27+ }
28+ ]
29+ } , archivedItems : 0
30+ } ) ;
31+
32+
1033const mockCollectionWithAbstract : Collection = Object . assign ( new Collection ( ) , {
1134 metadata : {
1235 'dc.description.abstract' : [
@@ -15,7 +38,7 @@ const mockCollectionWithAbstract: Collection = Object.assign(new Collection(), {
1538 value : 'Short description'
1639 }
1740 ]
18- }
41+ } , archivedItems : 1
1942} ) ;
2043
2144const mockCollectionWithoutAbstract : Collection = Object . assign ( new Collection ( ) , {
@@ -26,7 +49,7 @@ const mockCollectionWithoutAbstract: Collection = Object.assign(new Collection()
2649 value : 'Test title'
2750 }
2851 ]
29- }
52+ } , archivedItems : 1
3053} ) ;
3154
3255describe ( 'CollectionListElementComponent' , ( ) => {
@@ -71,4 +94,29 @@ describe('CollectionListElementComponent', () => {
7194 expect ( collectionAbstractField ) . toBeNull ( ) ;
7295 } ) ;
7396 } ) ;
97+
98+
99+ describe ( 'When the collection has archived items' , ( ) => {
100+ beforeEach ( ( ) => {
101+ collectionListElementComponent . object = mockCollectionWithArchivedItems ;
102+ fixture . detectChanges ( ) ;
103+ } ) ;
104+
105+ it ( 'should show the archived items paragraph' , ( ) => {
106+ const field = fixture . debugElement . query ( By . css ( 'span.archived-items-lead' ) ) ;
107+ expect ( field ) . not . toBeNull ( ) ;
108+ } ) ;
109+ } ) ;
110+
111+ describe ( 'When the collection has no archived items' , ( ) => {
112+ beforeEach ( ( ) => {
113+ collectionListElementComponent . object = mockCollectionWithoutArchivedItems ;
114+ fixture . detectChanges ( ) ;
115+ } ) ;
116+
117+ it ( 'should not show the archived items paragraph' , ( ) => {
118+ const field = fixture . debugElement . query ( By . css ( 'span.archived-items-lead' ) ) ;
119+ expect ( field ) . toBeNull ( ) ;
120+ } ) ;
121+ } ) ;
74122} ) ;
0 commit comments