mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 02:24:11 +00:00
466063: test fixes
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
import { Collection } from '../../../core/shared/collection.model';
|
||||||
|
import { SearchResult } from '../../../+search-page/search-result.model';
|
||||||
|
|
||||||
|
export class CollectionSearchResult extends SearchResult<Collection> {
|
||||||
|
}
|
@@ -0,0 +1,5 @@
|
|||||||
|
import { SearchResult } from '../../../+search-page/search-result.model';
|
||||||
|
import { Community } from '../../../core/shared/community.model';
|
||||||
|
|
||||||
|
export class CommunitySearchResult extends SearchResult<Community> {
|
||||||
|
}
|
@@ -5,7 +5,6 @@ import { ActivatedRoute, Router } from '@angular/router';
|
|||||||
import { RouterStub } from '../../testing/router-stub';
|
import { RouterStub } from '../../testing/router-stub';
|
||||||
import { Observable } from 'rxjs/Observable';
|
import { Observable } from 'rxjs/Observable';
|
||||||
import { By } from '@angular/platform-browser';
|
import { By } from '@angular/platform-browser';
|
||||||
import { ListableObject } from '../../object-collection/shared/listable-object.model';
|
|
||||||
import { Community } from '../../../core/shared/community.model';
|
import { Community } from '../../../core/shared/community.model';
|
||||||
|
|
||||||
let communityGridElementComponent: CommunityGridElementComponent;
|
let communityGridElementComponent: CommunityGridElementComponent;
|
||||||
@@ -51,6 +50,7 @@ describe('CommunityGridElementComponent', () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
it('should show the community cards in the grid element',() => {
|
it('should show the community cards in the grid element',() => {
|
||||||
|
console.log(fixture.debugElement.query(By.css('ds-community-grid-element')));
|
||||||
expect(fixture.debugElement.query(By.css('ds-community-grid-element'))).toBeDefined();
|
expect(fixture.debugElement.query(By.css('ds-community-grid-element'))).toBeDefined();
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@@ -6,7 +6,6 @@
|
|||||||
</a>
|
</a>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h4 class="card-title">{{object.findMetadata('dc.title')}}</h4>
|
<h4 class="card-title">{{object.findMetadata('dc.title')}}</h4>
|
||||||
|
|
||||||
<p *ngIf="object.filterMetadata(['dc.contributor.author', 'dc.creator', 'dc.contributor.*']);" class="item-authors card-text text-muted">
|
<p *ngIf="object.filterMetadata(['dc.contributor.author', 'dc.creator', 'dc.contributor.*']);" class="item-authors card-text text-muted">
|
||||||
<span *ngFor="let authorMd of object.filterMetadata(['dc.contributor.author', 'dc.creator', 'dc.contributor.*']); let last=last;">{{authorMd.value}}
|
<span *ngFor="let authorMd of object.filterMetadata(['dc.contributor.author', 'dc.creator', 'dc.contributor.*']); let last=last;">{{authorMd.value}}
|
||||||
<span *ngIf="!last">; </span>
|
<span *ngIf="!last">; </span>
|
||||||
|
@@ -64,4 +64,4 @@ describe('ItemGridElementComponent', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
})
|
});
|
||||||
|
@@ -2,7 +2,7 @@ import { Component } from '@angular/core';
|
|||||||
|
|
||||||
import { renderElementsFor} from '../../../object-collection/shared/dso-element-decorator';
|
import { renderElementsFor} from '../../../object-collection/shared/dso-element-decorator';
|
||||||
|
|
||||||
import { CollectionSearchResult } from './collection-search-result.model';
|
import { CollectionSearchResult } from '../../../object-collection/shared/collection-search-result.model';
|
||||||
import { SearchResultGridElementComponent } from '../search-result-grid-element.component';
|
import { SearchResultGridElementComponent } from '../search-result-grid-element.component';
|
||||||
import { Collection } from '../../../../core/shared/collection.model';
|
import { Collection } from '../../../../core/shared/collection.model';
|
||||||
import { ViewMode } from '../../../../+search-page/search-options.model';
|
import { ViewMode } from '../../../../+search-page/search-options.model';
|
||||||
|
@@ -1,5 +0,0 @@
|
|||||||
import { SearchResult } from '../../../../+search-page/search-result.model';
|
|
||||||
import { Collection } from '../../../../core/shared/collection.model';
|
|
||||||
|
|
||||||
export class CollectionSearchResult extends SearchResult<Collection> {
|
|
||||||
}
|
|
@@ -1,10 +1,10 @@
|
|||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
|
|
||||||
import { CommunitySearchResult } from './community-search-result.model';
|
|
||||||
import { Community } from '../../../../core/shared/community.model';
|
import { Community } from '../../../../core/shared/community.model';
|
||||||
import { renderElementsFor } from '../../../object-collection/shared/dso-element-decorator';
|
import { renderElementsFor } from '../../../object-collection/shared/dso-element-decorator';
|
||||||
import { SearchResultGridElementComponent } from '../search-result-grid-element.component';
|
import { SearchResultGridElementComponent } from '../search-result-grid-element.component';
|
||||||
import { ViewMode } from '../../../../+search-page/search-options.model';
|
import { ViewMode } from '../../../../+search-page/search-options.model';
|
||||||
|
import { CommunitySearchResult } from '../../../object-collection/shared/community-search-result.model';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-community-search-result-grid-element',
|
selector: 'ds-community-search-result-grid-element',
|
||||||
|
@@ -1,5 +0,0 @@
|
|||||||
import { SearchResult } from '../../../../+search-page/search-result.model';
|
|
||||||
import { Community } from '../../../../core/shared/community.model';
|
|
||||||
|
|
||||||
export class CommunitySearchResult extends SearchResult<Community> {
|
|
||||||
}
|
|
@@ -10,10 +10,10 @@
|
|||||||
<ds-truncatable-part [fixedHeight]="true" [id]="dso.id" [minLines]="3" type="h4">
|
<ds-truncatable-part [fixedHeight]="true" [id]="dso.id" [minLines]="3" type="h4">
|
||||||
<h4 class="card-title" [innerHTML]="dso.findMetadata('dc.title')"></h4>
|
<h4 class="card-title" [innerHTML]="dso.findMetadata('dc.title')"></h4>
|
||||||
</ds-truncatable-part>
|
</ds-truncatable-part>
|
||||||
<p *ngIf="dso.filterMetadata(['dc.contributor.author', 'dc.creator', 'dc.contributor.*'])"
|
<p *ngIf="dso.filterMetadata(['dc.contributor.author', 'dc.creator', 'dc.contributor.*']).length > 0"
|
||||||
class="item-authors card-text text-muted">
|
class="item-authors card-text text-muted">
|
||||||
<ds-truncatable-part [fixedHeight]="true" [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 *ngIf="dso.findMetadata('dc.date.issued').length > 0" class="item-date">{{dso.findMetadata("dc.date.issued")}}</span>
|
||||||
<span *ngFor="let authorMd of dso.filterMetadata(['dc.contributor.author', 'dc.creator', 'dc.contributor.*']);">,
|
<span *ngFor="let authorMd of dso.filterMetadata(['dc.contributor.author', 'dc.creator', 'dc.contributor.*']);">,
|
||||||
<span [innerHTML]="authorMd.value"></span>
|
<span [innerHTML]="authorMd.value"></span>
|
||||||
</span>
|
</span>
|
||||||
|
@@ -3,11 +3,13 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
|||||||
import { Observable } from 'rxjs/Observable';
|
import { Observable } from 'rxjs/Observable';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { RouterStub } from '../../../testing/router-stub';
|
import { RouterStub } from '../../../testing/router-stub';
|
||||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
import { NO_ERRORS_SCHEMA, ChangeDetectionStrategy } from '@angular/core';
|
||||||
import { By } from '@angular/platform-browser';
|
import { By } from '@angular/platform-browser';
|
||||||
import { TruncatePipe } from '../../../utils/truncate.pipe';
|
import { TruncatePipe } from '../../../utils/truncate.pipe';
|
||||||
import { Item } from '../../../../core/shared/item.model';
|
import { Item } from '../../../../core/shared/item.model';
|
||||||
import { TruncatableService } from '../../../truncatable/truncatable.service';
|
import { TruncatableService } from '../../../truncatable/truncatable.service';
|
||||||
|
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||||
|
import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model';
|
||||||
|
|
||||||
let itemSearchResultGridElementComponent: ItemSearchResultGridElementComponent;
|
let itemSearchResultGridElementComponent: ItemSearchResultGridElementComponent;
|
||||||
let fixture: ComponentFixture<ItemSearchResultGridElementComponent>;
|
let fixture: ComponentFixture<ItemSearchResultGridElementComponent>;
|
||||||
@@ -24,7 +26,10 @@ const truncatableServiceStub: any = {
|
|||||||
isCollapsed: (id: number) => Observable.of(true),
|
isCollapsed: (id: number) => Observable.of(true),
|
||||||
};
|
};
|
||||||
|
|
||||||
const mockItem: Item = Object.assign(new Item(), {
|
const mockItemWithAuthorAndDate: ItemSearchResult = new ItemSearchResult();
|
||||||
|
mockItemWithAuthorAndDate.hitHighlights = [];
|
||||||
|
mockItemWithAuthorAndDate.dspaceObject = Object.assign(new Item(), {
|
||||||
|
bitstreams: Observable.of({}),
|
||||||
metadata: [
|
metadata: [
|
||||||
{
|
{
|
||||||
key: 'dc.contributor.author',
|
key: 'dc.contributor.author',
|
||||||
@@ -34,14 +39,33 @@ const mockItem: Item = Object.assign(new Item(), {
|
|||||||
{
|
{
|
||||||
key: 'dc.date.issued',
|
key: 'dc.date.issued',
|
||||||
language: null,
|
language: null,
|
||||||
value: '1650-06-26'
|
value: '2015-06-26'
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
const createdGridElementComponent: ItemSearchResultGridElementComponent = new ItemSearchResultGridElementComponent(mockItem, truncatableServiceStub as TruncatableService);
|
|
||||||
|
const mockItemWithoutAuthorAndDate: ItemSearchResult = new ItemSearchResult();
|
||||||
|
mockItemWithoutAuthorAndDate.hitHighlights = [];
|
||||||
|
mockItemWithoutAuthorAndDate.dspaceObject = Object.assign(new Item(), {
|
||||||
|
bitstream: Observable.of({}),
|
||||||
|
metadata: [
|
||||||
|
{
|
||||||
|
key: 'dc.title',
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'This is just another title'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'dc.type',
|
||||||
|
language: null,
|
||||||
|
value: 'Article'
|
||||||
|
}]
|
||||||
|
});
|
||||||
|
|
||||||
|
const createdGridElementComponent: ItemSearchResultGridElementComponent = new ItemSearchResultGridElementComponent(mockItemWithAuthorAndDate, truncatableServiceStub as TruncatableService);
|
||||||
|
|
||||||
describe('ItemSearchResultGridElementComponent', () => {
|
describe('ItemSearchResultGridElementComponent', () => {
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
|
imports: [NoopAnimationsModule],
|
||||||
declarations: [ItemSearchResultGridElementComponent, TruncatePipe],
|
declarations: [ItemSearchResultGridElementComponent, TruncatePipe],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: TruncatableService, useValue: truncatableServiceStub },
|
{ provide: TruncatableService, useValue: truncatableServiceStub },
|
||||||
@@ -49,9 +73,10 @@ describe('ItemSearchResultGridElementComponent', () => {
|
|||||||
{ provide: Router, useClass: RouterStub },
|
{ provide: Router, useClass: RouterStub },
|
||||||
{ provide: 'objectElementProvider', useValue: (createdGridElementComponent) }
|
{ provide: 'objectElementProvider', useValue: (createdGridElementComponent) }
|
||||||
],
|
],
|
||||||
|
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
}).compileComponents(); // compile template and css
|
}).overrideComponent(ItemSearchResultGridElementComponent, {
|
||||||
|
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||||
|
}).compileComponents();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
@@ -59,28 +84,48 @@ describe('ItemSearchResultGridElementComponent', () => {
|
|||||||
itemSearchResultGridElementComponent = fixture.componentInstance;
|
itemSearchResultGridElementComponent = fixture.componentInstance;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should show the item result cards in the grid element', () => {
|
fdescribe('When the item has an author', () => {
|
||||||
expect(fixture.debugElement.query(By.css('ds-item-search-result-grid-element'))).toBeDefined();
|
beforeEach(() => {
|
||||||
|
itemSearchResultGridElementComponent.dso = mockItemWithAuthorAndDate.dspaceObject;
|
||||||
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should only show the author span if the author metadata is present', () => {
|
it('should show the author paragraph', () => {
|
||||||
const itemAuthorField = expect(fixture.debugElement.query(By.css('p.item-authors')));
|
const itemAuthorField = fixture.debugElement.query(By.css('p.item-authors'));
|
||||||
|
expect(itemAuthorField).not.toBeNull();
|
||||||
if (mockItem.filterMetadata(['dc.contributor.author', 'dc.creator', 'dc.contributor.*']).length > 0) {
|
});
|
||||||
expect(itemAuthorField).toBeDefined();
|
|
||||||
} else {
|
|
||||||
expect(itemAuthorField).not.toBeDefined();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should only show the date span if the issuedate is present', () => {
|
describe('When the item has no author', () => {
|
||||||
const dateField = expect(fixture.debugElement.query(By.css('span.item-list-date')));
|
beforeEach(() => {
|
||||||
|
itemSearchResultGridElementComponent.dso = mockItemWithoutAuthorAndDate.dspaceObject;
|
||||||
if (mockItem.findMetadata('dc.date.issued').length > 0) {
|
|
||||||
expect(dateField).toBeDefined();
|
|
||||||
} else {
|
|
||||||
expect(dateField).not.toBeDefined();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not show the author paragraph', () => {
|
||||||
|
const itemAuthorField = fixture.debugElement.query(By.css('p.item-authors'));
|
||||||
|
expect(itemAuthorField).toBeNull();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('When the item has an issuedate', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
itemSearchResultGridElementComponent.dso = mockItemWithAuthorAndDate.dspaceObject;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should show the issuedate span', () => {
|
||||||
|
const itemAuthorField = fixture.debugElement.query(By.css('span.item-date'));
|
||||||
|
expect(itemAuthorField).not.toBeNull();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('When the item has no issuedate', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
itemSearchResultGridElementComponent.dso = mockItemWithoutAuthorAndDate.dspaceObject;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not show the issuedate span', () => {
|
||||||
|
const dateField = fixture.debugElement.query(By.css('span.item-date'));
|
||||||
|
expect(dateField).toBeNull();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -20,6 +20,7 @@ export class SearchResultGridElementComponent<T extends SearchResult<K>, K exten
|
|||||||
public constructor(@Inject('objectElementProvider') public gridable: ListableObject, private truncatableService: TruncatableService) {
|
public constructor(@Inject('objectElementProvider') public gridable: ListableObject, private truncatableService: TruncatableService) {
|
||||||
super(gridable);
|
super(gridable);
|
||||||
this.dso = this.object.dspaceObject;
|
this.dso = this.object.dspaceObject;
|
||||||
|
console.log(JSON.stringify(this.object.hitHighlights));
|
||||||
}
|
}
|
||||||
|
|
||||||
getValues(keys: string[]): string[] {
|
getValues(keys: string[]): string[] {
|
||||||
@@ -43,6 +44,7 @@ export class SearchResultGridElementComponent<T extends SearchResult<K>, K exten
|
|||||||
|
|
||||||
getFirstValue(key: string): string {
|
getFirstValue(key: string): string {
|
||||||
let result: string;
|
let result: string;
|
||||||
|
console.log(JSON.stringify(this.object.hitHighlights));
|
||||||
this.object.hitHighlights.some(
|
this.object.hitHighlights.some(
|
||||||
(md: Metadatum) => {
|
(md: Metadatum) => {
|
||||||
if (key === md.key) {
|
if (key === md.key) {
|
||||||
|
@@ -56,4 +56,4 @@ describe('CollectionListElementComponent', () => {
|
|||||||
expect(descriptionText).not.toBeDefined();
|
expect(descriptionText).not.toBeDefined();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
});
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
|
|
||||||
import { renderElementsFor } from '../../../object-collection/shared/dso-element-decorator';
|
import { renderElementsFor } from '../../../object-collection/shared/dso-element-decorator';
|
||||||
import { CollectionSearchResult } from './collection-search-result.model';
|
|
||||||
import { SearchResultListElementComponent } from '../search-result-list-element.component';
|
import { SearchResultListElementComponent } from '../search-result-list-element.component';
|
||||||
import { Collection } from '../../../../core/shared/collection.model';
|
import { Collection } from '../../../../core/shared/collection.model';
|
||||||
import { ViewMode } from '../../../../+search-page/search-options.model';
|
import { ViewMode } from '../../../../+search-page/search-options.model';
|
||||||
|
import { CollectionSearchResult } from '../../../object-collection/shared/collection-search-result.model';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-collection-search-result-list-element',
|
selector: 'ds-collection-search-result-list-element',
|
||||||
|
@@ -1,5 +0,0 @@
|
|||||||
import { SearchResult } from '../../../../+search-page/search-result.model';
|
|
||||||
import { Collection } from '../../../../core/shared/collection.model';
|
|
||||||
|
|
||||||
export class CollectionSearchResult extends SearchResult<Collection> {
|
|
||||||
}
|
|
@@ -1,7 +1,7 @@
|
|||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
|
|
||||||
import { renderElementsFor } from '../../../object-collection/shared/dso-element-decorator';
|
import { renderElementsFor } from '../../../object-collection/shared/dso-element-decorator';
|
||||||
import { CommunitySearchResult } from './community-search-result.model';
|
import { CommunitySearchResult } from '../../../object-collection/shared/community-search-result.model';
|
||||||
import { SearchResultListElementComponent } from '../search-result-list-element.component';
|
import { SearchResultListElementComponent } from '../search-result-list-element.component';
|
||||||
import { Community } from '../../../../core/shared/community.model';
|
import { Community } from '../../../../core/shared/community.model';
|
||||||
import { ViewMode } from '../../../../+search-page/search-options.model';
|
import { ViewMode } from '../../../../+search-page/search-options.model';
|
||||||
|
@@ -1,5 +0,0 @@
|
|||||||
import { SearchResult } from '../../../../+search-page/search-result.model';
|
|
||||||
import { Community } from '../../../../core/shared/community.model';
|
|
||||||
|
|
||||||
export class CommunitySearchResult extends SearchResult<Community> {
|
|
||||||
}
|
|
@@ -1,4 +1,4 @@
|
|||||||
<div class="clamp-{{lines}} {{type}} {{fixedHeight ? 'fixedHeight' : ''}}">
|
<div class="clamp-{{lines}} min-{{minLines}} {{type}} {{fixedHeight ? 'fixedHeight' : ''}}">
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<ng-content></ng-content>
|
<ng-content></ng-content>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -25,7 +25,11 @@
|
|||||||
background: linear-gradient(to right, rgba(255, 255, 255, 0), $body-bg 70%);
|
background: linear-gradient(to right, rgba(255, 255, 255, 0), $body-bg 70%);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@mixin min($lines, $size-factor: 1, $line-height: $line-height-base) {
|
||||||
|
$height: $line-height * $font-size-base * $size-factor;
|
||||||
|
min-height: $lines * $height;
|
||||||
}
|
}
|
||||||
|
|
||||||
$h4-factor: strip-unit($h4-font-size);
|
$h4-factor: strip-unit($h4-font-size);
|
||||||
@@ -42,7 +46,18 @@ $h4-factor: strip-unit($h4-font-size);
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.clamp-none {
|
.clamp-none {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
@for $i from 1 through 15 {
|
||||||
|
&.min-#{$i} {
|
||||||
|
transition: height 1s;
|
||||||
|
@include min($i);
|
||||||
|
&.title {
|
||||||
|
@include min($i, 1.25);
|
||||||
|
}
|
||||||
|
&.h4 {
|
||||||
|
@include min($i, $h4-factor, $headings-line-height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user