Skip to content

Commit 388c08b

Browse files
committed
Archived items moved outside initial span element(fix for tests). Tests added.
1 parent da7cb11 commit 388c08b

3 files changed

Lines changed: 52 additions & 6 deletions

File tree

src/app/community-list-page/community-list/community-list.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ <h5 class="align-middle pt-2">
3737
<a [routerLink]="node.route" class="lead">
3838
{{node.name}}
3939
</a>
40-
<span>[{{node.payload.archivedItems}}]</span>
40+
<span *ngIf="node.payload.archivedItems" class="archived-items-lead">[{{node.payload.archivedItems}}]</span>
4141
</h5>
4242
</div>
4343
<ds-truncatable [id]="node.id">

src/app/shared/object-list/collection-list-element/collection-list-element.component.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
<span *ngIf="linkType == linkTypes.None" class="lead">
55
{{object.name}}
66
</span>
7-
8-
<span class="lead" *ngIf="object.archivedItems">[{{object.archivedItems}}]<span>
9-
7+
<span *ngIf="object.archivedItems" class="archived-items-lead">[{{object.archivedItems}}]<span>
108
<div *ngIf="object.shortDescription" class="text-muted abstract-text">
119
{{object.shortDescription}}
1210
</div>

src/app/shared/object-list/collection-list-element/collection-list-element.component.spec.ts

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,29 @@ import { Collection } from '../../../core/shared/collection.model';
77
let collectionListElementComponent: CollectionListElementComponent;
88
let 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+
1033
const 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

2144
const 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

3255
describe('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

Comments
 (0)