Archived items moved outside initial span element(fix for tests). Tests added.

This commit is contained in:
damian
2023-05-15 20:34:46 +02:00
parent da7cb11bcb
commit 388c08b9a1
3 changed files with 52 additions and 6 deletions

View File

@@ -37,7 +37,7 @@
<a [routerLink]="node.route" class="lead">
{{node.name}}
</a>
<span>[{{node.payload.archivedItems}}]</span>
<span *ngIf="node.payload.archivedItems" class="archived-items-lead">[{{node.payload.archivedItems}}]</span>
</h5>
</div>
<ds-truncatable [id]="node.id">

View File

@@ -4,9 +4,7 @@
<span *ngIf="linkType == linkTypes.None" class="lead">
{{object.name}}
</span>
<span class="lead" *ngIf="object.archivedItems">[{{object.archivedItems}}]<span>
<span *ngIf="object.archivedItems" class="archived-items-lead">[{{object.archivedItems}}]<span>
<div *ngIf="object.shortDescription" class="text-muted abstract-text">
{{object.shortDescription}}
</div>

View File

@@ -7,6 +7,29 @@ import { Collection } from '../../../core/shared/collection.model';
let collectionListElementComponent: CollectionListElementComponent;
let fixture: ComponentFixture<CollectionListElementComponent>;
const mockCollectionWithArchivedItems: Collection = Object.assign(new Collection(), {
metadata: {
'dc.title': [
{
language: 'en_US',
value: 'Test title'
}
]
}, archivedItems: 1
});
const mockCollectionWithoutArchivedItems: Collection = Object.assign(new Collection(), {
metadata: {
'dc.title': [
{
language: 'en_US',
value: 'Test title'
}
]
}, archivedItems: 0
});
const mockCollectionWithAbstract: Collection = Object.assign(new Collection(), {
metadata: {
'dc.description.abstract': [
@@ -15,7 +38,7 @@ const mockCollectionWithAbstract: Collection = Object.assign(new Collection(), {
value: 'Short description'
}
]
}
}, archivedItems: 1
});
const mockCollectionWithoutAbstract: Collection = Object.assign(new Collection(), {
@@ -26,7 +49,7 @@ const mockCollectionWithoutAbstract: Collection = Object.assign(new Collection()
value: 'Test title'
}
]
}
}, archivedItems: 1
});
describe('CollectionListElementComponent', () => {
@@ -71,4 +94,29 @@ describe('CollectionListElementComponent', () => {
expect(collectionAbstractField).toBeNull();
});
});
describe('When the collection has archived items', () => {
beforeEach(() => {
collectionListElementComponent.object = mockCollectionWithArchivedItems;
fixture.detectChanges();
});
it('should show the archived items paragraph', () => {
const field = fixture.debugElement.query(By.css('span.archived-items-lead'));
expect(field).not.toBeNull();
});
});
describe('When the collection has no archived items', () => {
beforeEach(() => {
collectionListElementComponent.object = mockCollectionWithoutArchivedItems;
fixture.detectChanges();
});
it('should not show the archived items paragraph', () => {
const field = fixture.debugElement.query(By.css('span.archived-items-lead'));
expect(field).toBeNull();
});
});
});