mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-15 22:13:02 +00:00
46063: truncation finished, still have to fix some existing tests
This commit is contained in:
@@ -7,21 +7,23 @@
|
||||
</div>
|
||||
</a>
|
||||
<div class="card-body">
|
||||
<h4 class="card-title" [innerHTML]="dso.findMetadata('dc.title')"></h4>
|
||||
<ds-truncatable-part [fixedHeight]="true" [id]="dso.id" [minLines]="3" type="h4">
|
||||
<h4 class="card-title" [innerHTML]="dso.findMetadata('dc.title')"></h4>
|
||||
</ds-truncatable-part>
|
||||
<p *ngIf="dso.filterMetadata(['dc.contributor.author', 'dc.creator', 'dc.contributor.*'])"
|
||||
class="item-authors card-text text-muted">
|
||||
<ds-truncatable-part [id]="dso.id" [minLines]="1">
|
||||
<ds-truncatable-part [fixedHeight]="true" [id]="dso.id" [minLines]="1">
|
||||
<span *ngIf="dso.findMetadata('dc.date.issued')" class="item-list-date">{{dso.findMetadata("dc.date.issued")}}</span>
|
||||
<span *ngFor="let authorMd of dso.filterMetadata(['dc.contributor.author', 'dc.creator', 'dc.contributor.*']);">,
|
||||
<span [innerHTML]="authorMd.value"></span>
|
||||
</span>
|
||||
</ds-truncatable-part>
|
||||
</p>
|
||||
<ds-truncatable-part [id]="dso.id" [minLines]="3">
|
||||
<p class="item-abstract card-text"
|
||||
[innerHTML]="getFirstValue('dc.description.abstract')">
|
||||
</p>
|
||||
</ds-truncatable-part>
|
||||
<p class="item-abstract card-text">
|
||||
<ds-truncatable-part [fixedHeight]="true" [id]="dso.id" [minLines]="3">
|
||||
<span [innerHTML]="getFirstValue('dc.description.abstract')"></span>
|
||||
</ds-truncatable-part>
|
||||
</p>
|
||||
<div class="text-center">
|
||||
<a [routerLink]="['/items/' + dso.id]"
|
||||
class="lead btn btn-primary viewButton">View</a>
|
||||
|
@@ -7,6 +7,7 @@ import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { TruncatePipe } from '../../../utils/truncate.pipe';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { TruncatableService } from '../../../truncatable/truncatable.service';
|
||||
|
||||
let itemSearchResultGridElementComponent: ItemSearchResultGridElementComponent;
|
||||
let fixture: ComponentFixture<ItemSearchResultGridElementComponent>;
|
||||
@@ -18,6 +19,11 @@ const activatedRouteStub = {
|
||||
scope: scopeParam
|
||||
})
|
||||
};
|
||||
|
||||
const truncatableServiceStub: any = {
|
||||
isCollapsed: (id: number) => Observable.of(true),
|
||||
};
|
||||
|
||||
const mockItem: Item = Object.assign(new Item(), {
|
||||
metadata: [
|
||||
{
|
||||
@@ -31,48 +37,48 @@ const mockItem: Item = Object.assign(new Item(), {
|
||||
value: '1650-06-26'
|
||||
}]
|
||||
});
|
||||
const createdGridElementComponent:ItemSearchResultGridElementComponent= new ItemSearchResultGridElementComponent(mockItem);
|
||||
const createdGridElementComponent: ItemSearchResultGridElementComponent = new ItemSearchResultGridElementComponent(mockItem, truncatableServiceStub as TruncatableService);
|
||||
|
||||
describe('ItemSearchResultGridElementComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ ItemSearchResultGridElementComponent, TruncatePipe ],
|
||||
declarations: [ItemSearchResultGridElementComponent, TruncatePipe],
|
||||
providers: [
|
||||
{ provide: TruncatableService, useValue: truncatableServiceStub },
|
||||
{ provide: ActivatedRoute, useValue: activatedRouteStub },
|
||||
{ provide: Router, useClass: RouterStub },
|
||||
{ provide: 'objectElementProvider', useValue: (createdGridElementComponent) }
|
||||
],
|
||||
|
||||
schemas: [ NO_ERRORS_SCHEMA ]
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).compileComponents(); // compile template and css
|
||||
}));
|
||||
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(ItemSearchResultGridElementComponent);
|
||||
itemSearchResultGridElementComponent = fixture.componentInstance;
|
||||
|
||||
}));
|
||||
|
||||
it('should show the item result cards in the grid element',() => {
|
||||
it('should show the item result cards in the grid element', () => {
|
||||
expect(fixture.debugElement.query(By.css('ds-item-search-result-grid-element'))).toBeDefined();
|
||||
});
|
||||
|
||||
it('should only show the author span if the author metadata is present',() => {
|
||||
it('should only show the author span if the author metadata is present', () => {
|
||||
const itemAuthorField = expect(fixture.debugElement.query(By.css('p.item-authors')));
|
||||
|
||||
if (mockItem.filterMetadata(['dc.contributor.author', 'dc.creator', 'dc.contributor.*']).length > 0) {
|
||||
expect(itemAuthorField).toBeDefined();
|
||||
}else {
|
||||
} else {
|
||||
expect(itemAuthorField).not.toBeDefined();
|
||||
}
|
||||
});
|
||||
|
||||
it('should only show the date span if the issuedate is present',() => {
|
||||
it('should only show the date span if the issuedate is present', () => {
|
||||
const dateField = expect(fixture.debugElement.query(By.css('span.item-list-date')));
|
||||
|
||||
if (mockItem.findMetadata('dc.date.issued').length > 0) {
|
||||
expect(dateField).toBeDefined();
|
||||
}else {
|
||||
} else {
|
||||
expect(dateField).not.toBeDefined();
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user