mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-12 04:23:04 +00:00
62741: Entities grid templates tests
This commit is contained in:
@@ -11,12 +11,12 @@
|
|||||||
<ds-truncatable-part [id]="dso.id" [minLines]="3" type="h4">
|
<ds-truncatable-part [id]="dso.id" [minLines]="3" type="h4">
|
||||||
<h4 class="card-title" [innerHTML]="dso.firstMetadataValue('dc.title')"></h4>
|
<h4 class="card-title" [innerHTML]="dso.firstMetadataValue('dc.title')"></h4>
|
||||||
</ds-truncatable-part>
|
</ds-truncatable-part>
|
||||||
<p class="item-date card-text text-muted">
|
<p *ngIf="dso.hasMetadata('journalissue.issuedate')" class="item-date card-text text-muted">
|
||||||
<ds-truncatable-part [id]="dso.id" [minLines]="1">
|
<ds-truncatable-part [id]="dso.id" [minLines]="1">
|
||||||
<span [innerHTML]="firstMetadataValue('journalissue.issuedate')"></span>
|
<span [innerHTML]="firstMetadataValue('journalissue.issuedate')"></span>
|
||||||
</ds-truncatable-part>
|
</ds-truncatable-part>
|
||||||
</p>
|
</p>
|
||||||
<p class="item-journal-title card-text">
|
<p *ngIf="dso.hasMetadata('journal.title')" class="item-journal-title card-text">
|
||||||
<ds-truncatable-part [id]="dso.id" [minLines]="3">
|
<ds-truncatable-part [id]="dso.id" [minLines]="3">
|
||||||
<span [innerHTML]="firstMetadataValue('journal.title')"></span>
|
<span [innerHTML]="firstMetadataValue('journal.title')"></span>
|
||||||
</ds-truncatable-part>
|
</ds-truncatable-part>
|
||||||
|
@@ -0,0 +1,47 @@
|
|||||||
|
import { ItemSearchResult } from '../../../../shared/object-collection/shared/item-search-result.model';
|
||||||
|
import { Item } from '../../../../core/shared/item.model';
|
||||||
|
import { of as observableOf } from 'rxjs/internal/observable/of';
|
||||||
|
import { getEntityGridElementTestComponent } from '../../../../shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec';
|
||||||
|
import { JournalIssueGridElementComponent } from './journal-issue-grid-element.component';
|
||||||
|
|
||||||
|
const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult();
|
||||||
|
mockItemWithMetadata.hitHighlights = {};
|
||||||
|
mockItemWithMetadata.indexableObject = Object.assign(new Item(), {
|
||||||
|
bitstreams: observableOf({}),
|
||||||
|
metadata: {
|
||||||
|
'dc.title': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'This is just another title'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'journalissue.issuedate': [
|
||||||
|
{
|
||||||
|
language: null,
|
||||||
|
value: '2015-06-26'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'journal.title': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'The journal title'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const mockItemWithoutMetadata: ItemSearchResult = new ItemSearchResult();
|
||||||
|
mockItemWithoutMetadata.hitHighlights = {};
|
||||||
|
mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), {
|
||||||
|
bitstreams: observableOf({}),
|
||||||
|
metadata: {
|
||||||
|
'dc.title': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'This is just another title'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('JournalIssueGridElementComponent', getEntityGridElementTestComponent(JournalIssueGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['date', 'journal-title']));
|
||||||
|
@@ -11,12 +11,12 @@
|
|||||||
<ds-truncatable-part [id]="dso.id" [minLines]="3" type="h4">
|
<ds-truncatable-part [id]="dso.id" [minLines]="3" type="h4">
|
||||||
<h4 class="card-title" [innerHTML]="dso.firstMetadataValue('dc.title')"></h4>
|
<h4 class="card-title" [innerHTML]="dso.firstMetadataValue('dc.title')"></h4>
|
||||||
</ds-truncatable-part>
|
</ds-truncatable-part>
|
||||||
<p class="item-date card-text text-muted">
|
<p *ngIf="dso.hasMetadata('journalvolume.issuedate')" class="item-date card-text text-muted">
|
||||||
<ds-truncatable-part [id]="dso.id" [minLines]="1">
|
<ds-truncatable-part [id]="dso.id" [minLines]="1">
|
||||||
<span [innerHTML]="firstMetadataValue('journalvolume.issuedate')"></span>
|
<span [innerHTML]="firstMetadataValue('journalvolume.issuedate')"></span>
|
||||||
</ds-truncatable-part>
|
</ds-truncatable-part>
|
||||||
</p>
|
</p>
|
||||||
<p class="item-description card-text">
|
<p *ngIf="dso.hasMetadata('journalvolume.identifier.description')" class="item-description card-text">
|
||||||
<ds-truncatable-part [id]="dso.id" [minLines]="3">
|
<ds-truncatable-part [id]="dso.id" [minLines]="3">
|
||||||
<span [innerHTML]="firstMetadataValue('journalvolume.identifier.description')"></span>
|
<span [innerHTML]="firstMetadataValue('journalvolume.identifier.description')"></span>
|
||||||
</ds-truncatable-part>
|
</ds-truncatable-part>
|
||||||
|
@@ -0,0 +1,47 @@
|
|||||||
|
import { ItemSearchResult } from '../../../../shared/object-collection/shared/item-search-result.model';
|
||||||
|
import { Item } from '../../../../core/shared/item.model';
|
||||||
|
import { of as observableOf } from 'rxjs/internal/observable/of';
|
||||||
|
import { getEntityGridElementTestComponent } from '../../../../shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec';
|
||||||
|
import { JournalVolumeGridElementComponent } from './journal-volume-grid-element.component';
|
||||||
|
|
||||||
|
const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult();
|
||||||
|
mockItemWithMetadata.hitHighlights = {};
|
||||||
|
mockItemWithMetadata.indexableObject = Object.assign(new Item(), {
|
||||||
|
bitstreams: observableOf({}),
|
||||||
|
metadata: {
|
||||||
|
'dc.title': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'This is just another title'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'journalvolume.issuedate': [
|
||||||
|
{
|
||||||
|
language: null,
|
||||||
|
value: '2015-06-26'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'journalvolume.identifier.description': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'A description for the journal volume'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const mockItemWithoutMetadata: ItemSearchResult = new ItemSearchResult();
|
||||||
|
mockItemWithoutMetadata.hitHighlights = {};
|
||||||
|
mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), {
|
||||||
|
bitstreams: observableOf({}),
|
||||||
|
metadata: {
|
||||||
|
'dc.title': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'This is just another title'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('JournalVolumeGridElementComponent', getEntityGridElementTestComponent(JournalVolumeGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['date', 'description']));
|
||||||
|
@@ -14,12 +14,12 @@
|
|||||||
<p *ngIf="dso.hasMetadata('journal.contributor.editor')"
|
<p *ngIf="dso.hasMetadata('journal.contributor.editor')"
|
||||||
class="item-publisher card-text text-muted">
|
class="item-publisher card-text text-muted">
|
||||||
<ds-truncatable-part [id]="dso.id" [minLines]="1">
|
<ds-truncatable-part [id]="dso.id" [minLines]="1">
|
||||||
<span *ngIf="dso.hasMetadata('journal.contributor.editor')" class="item-date">{{dso.firstMetadataValue('journal.contributor.editor')}}</span>
|
<span *ngIf="dso.hasMetadata('journal.contributor.editor')" class="item-editor">{{dso.firstMetadataValue('journal.contributor.editor')}}</span>
|
||||||
<span>, </span>
|
<span>, </span>
|
||||||
<span *ngIf="dso.hasMetadata('journal.publisher')" class="item-date">{{dso.firstMetadataValue('journal.publisher')}}</span>
|
<span *ngIf="dso.hasMetadata('journal.publisher')" class="item-publisher">{{dso.firstMetadataValue('journal.publisher')}}</span>
|
||||||
</ds-truncatable-part>
|
</ds-truncatable-part>
|
||||||
</p>
|
</p>
|
||||||
<p class="item-description card-text">
|
<p *ngIf="dso.hasMetadata('journal.identifier.description')" class="item-description card-text">
|
||||||
<ds-truncatable-part [id]="dso.id" [minLines]="3">
|
<ds-truncatable-part [id]="dso.id" [minLines]="3">
|
||||||
<span [innerHTML]="firstMetadataValue('journal.identifier.description')"></span>
|
<span [innerHTML]="firstMetadataValue('journal.identifier.description')"></span>
|
||||||
</ds-truncatable-part>
|
</ds-truncatable-part>
|
||||||
|
@@ -0,0 +1,53 @@
|
|||||||
|
import { ItemSearchResult } from '../../../../shared/object-collection/shared/item-search-result.model';
|
||||||
|
import { Item } from '../../../../core/shared/item.model';
|
||||||
|
import { of as observableOf } from 'rxjs/internal/observable/of';
|
||||||
|
import { getEntityGridElementTestComponent } from '../../../../shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec';
|
||||||
|
import { JournalGridElementComponent } from './journal-grid-element.component';
|
||||||
|
|
||||||
|
const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult();
|
||||||
|
mockItemWithMetadata.hitHighlights = {};
|
||||||
|
mockItemWithMetadata.indexableObject = Object.assign(new Item(), {
|
||||||
|
bitstreams: observableOf({}),
|
||||||
|
metadata: {
|
||||||
|
'dc.title': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'This is just another title'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'journal.contributor.editor': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'Smith, Donald'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'journal.publisher': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'A company'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'journal.identifier.description': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'This is the description'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const mockItemWithoutMetadata: ItemSearchResult = new ItemSearchResult();
|
||||||
|
mockItemWithoutMetadata.hitHighlights = {};
|
||||||
|
mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), {
|
||||||
|
bitstreams: observableOf({}),
|
||||||
|
metadata: {
|
||||||
|
'dc.title': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'This is just another title'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('JournalGridElementComponent', getEntityGridElementTestComponent(JournalGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['editor', 'publisher', 'description']));
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
<ds-truncatable-part [id]="dso.id" [minLines]="3" type="h4">
|
<ds-truncatable-part [id]="dso.id" [minLines]="3" type="h4">
|
||||||
<h4 class="card-title" [innerHTML]="dso.firstMetadataValue('dc.title')"></h4>
|
<h4 class="card-title" [innerHTML]="dso.firstMetadataValue('dc.title')"></h4>
|
||||||
</ds-truncatable-part>
|
</ds-truncatable-part>
|
||||||
<p class="item-date card-text text-muted">
|
<p *ngIf="dso.hasMetadata('orgunit.identifier.dateestablished')" class="item-date card-text text-muted">
|
||||||
<ds-truncatable-part [id]="dso.id" [minLines]="1">
|
<ds-truncatable-part [id]="dso.id" [minLines]="1">
|
||||||
<span [innerHTML]="firstMetadataValue('orgunit.identifier.dateestablished')"></span>
|
<span [innerHTML]="firstMetadataValue('orgunit.identifier.dateestablished')"></span>
|
||||||
</ds-truncatable-part>
|
</ds-truncatable-part>
|
||||||
@@ -19,9 +19,9 @@
|
|||||||
<p *ngIf="dso.hasMetadata('orgunit.identifier.country')"
|
<p *ngIf="dso.hasMetadata('orgunit.identifier.country')"
|
||||||
class="item-location card-text">
|
class="item-location card-text">
|
||||||
<ds-truncatable-part [id]="dso.id" [minLines]="3">
|
<ds-truncatable-part [id]="dso.id" [minLines]="3">
|
||||||
<span *ngIf="dso.hasMetadata('orgunit.identifier.country')" class="item-date">{{dso.firstMetadataValue('orgunit.identifier.country')}}</span>
|
<span *ngIf="dso.hasMetadata('orgunit.identifier.country')" class="item-country">{{dso.firstMetadataValue('orgunit.identifier.country')}}</span>
|
||||||
<span>, </span>
|
<span>, </span>
|
||||||
<span *ngIf="dso.hasMetadata('orgunit.identifier.city')" class="item-date">{{dso.firstMetadataValue('orgunit.identifier.city')}}</span>
|
<span *ngIf="dso.hasMetadata('orgunit.identifier.city')" class="item-city">{{dso.firstMetadataValue('orgunit.identifier.city')}}</span>
|
||||||
</ds-truncatable-part>
|
</ds-truncatable-part>
|
||||||
</p>
|
</p>
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
|
@@ -0,0 +1,53 @@
|
|||||||
|
import { ItemSearchResult } from '../../../../shared/object-collection/shared/item-search-result.model';
|
||||||
|
import { Item } from '../../../../core/shared/item.model';
|
||||||
|
import { of as observableOf } from 'rxjs/internal/observable/of';
|
||||||
|
import { getEntityGridElementTestComponent } from '../../../../shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec';
|
||||||
|
import { OrgunitGridElementComponent } from './orgunit-grid-element.component';
|
||||||
|
|
||||||
|
const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult();
|
||||||
|
mockItemWithMetadata.hitHighlights = {};
|
||||||
|
mockItemWithMetadata.indexableObject = Object.assign(new Item(), {
|
||||||
|
bitstreams: observableOf({}),
|
||||||
|
metadata: {
|
||||||
|
'dc.title': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'This is just another title'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'orgunit.identifier.dateestablished': [
|
||||||
|
{
|
||||||
|
language: null,
|
||||||
|
value: '2015-06-26'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'orgunit.identifier.country': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'Belgium'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'orgunit.identifier.city': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'Brussels'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const mockItemWithoutMetadata: ItemSearchResult = new ItemSearchResult();
|
||||||
|
mockItemWithoutMetadata.hitHighlights = {};
|
||||||
|
mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), {
|
||||||
|
bitstreams: observableOf({}),
|
||||||
|
metadata: {
|
||||||
|
'dc.title': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'This is just another title'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('OrgunitGridElementComponent', getEntityGridElementTestComponent(OrgunitGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['date', 'country', 'city']));
|
||||||
|
@@ -11,12 +11,12 @@
|
|||||||
<ds-truncatable-part [id]="dso.id" [minLines]="3" type="h4">
|
<ds-truncatable-part [id]="dso.id" [minLines]="3" type="h4">
|
||||||
<h4 class="card-title" [innerHTML]="dso.firstMetadataValue('dc.title')"></h4>
|
<h4 class="card-title" [innerHTML]="dso.firstMetadataValue('dc.title')"></h4>
|
||||||
</ds-truncatable-part>
|
</ds-truncatable-part>
|
||||||
<p class="item-email card-text text-muted">
|
<p *ngIf="dso.hasMetadata('person.identifier.email')" class="item-email card-text text-muted">
|
||||||
<ds-truncatable-part [id]="dso.id" [minLines]="1">
|
<ds-truncatable-part [id]="dso.id" [minLines]="1">
|
||||||
<span *ngIf="dso.hasMetadata('person.identifier.email')">{{dso.firstMetadataValue('person.identifier.email')}}</span>
|
<span [innerHTML]="firstMetadataValue('person.identifier.email')"></span>
|
||||||
</ds-truncatable-part>
|
</ds-truncatable-part>
|
||||||
</p>
|
</p>
|
||||||
<p class="item-jobtitle card-text">
|
<p *ngIf="dso.hasMetadata('person.identifier.jobtitle')" class="item-jobtitle card-text">
|
||||||
<ds-truncatable-part [id]="dso.id" [minLines]="3">
|
<ds-truncatable-part [id]="dso.id" [minLines]="3">
|
||||||
<span [innerHTML]="firstMetadataValue('person.identifier.jobtitle')"></span>
|
<span [innerHTML]="firstMetadataValue('person.identifier.jobtitle')"></span>
|
||||||
</ds-truncatable-part>
|
</ds-truncatable-part>
|
||||||
|
@@ -0,0 +1,47 @@
|
|||||||
|
import { ItemSearchResult } from '../../../../shared/object-collection/shared/item-search-result.model';
|
||||||
|
import { Item } from '../../../../core/shared/item.model';
|
||||||
|
import { of as observableOf } from 'rxjs/internal/observable/of';
|
||||||
|
import { getEntityGridElementTestComponent } from '../../../../shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec';
|
||||||
|
import { PersonGridElementComponent } from './person-grid-element.component';
|
||||||
|
|
||||||
|
const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult();
|
||||||
|
mockItemWithMetadata.hitHighlights = {};
|
||||||
|
mockItemWithMetadata.indexableObject = Object.assign(new Item(), {
|
||||||
|
bitstreams: observableOf({}),
|
||||||
|
metadata: {
|
||||||
|
'dc.title': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'This is just another title'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'person.identifier.email': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'Smith-Donald@gmail.com'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'person.identifier.jobtitle': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'Web Developer'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const mockItemWithoutMetadata: ItemSearchResult = new ItemSearchResult();
|
||||||
|
mockItemWithoutMetadata.hitHighlights = {};
|
||||||
|
mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), {
|
||||||
|
bitstreams: observableOf({}),
|
||||||
|
metadata: {
|
||||||
|
'dc.title': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'This is just another title'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('PersonGridElementComponent', getEntityGridElementTestComponent(PersonGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['email', 'jobtitle']));
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
<ds-truncatable-part [id]="dso.id" [minLines]="3" type="h4">
|
<ds-truncatable-part [id]="dso.id" [minLines]="3" type="h4">
|
||||||
<h4 class="card-title" [innerHTML]="dso.firstMetadataValue('dc.title')"></h4>
|
<h4 class="card-title" [innerHTML]="dso.firstMetadataValue('dc.title')"></h4>
|
||||||
</ds-truncatable-part>
|
</ds-truncatable-part>
|
||||||
<p class="item-funder card-text text-muted">
|
<p *ngIf="dso.hasMetadata('project.identifier.funder')" class="item-funder card-text text-muted">
|
||||||
<ds-truncatable-part [id]="dso.id" [minLines]="3">
|
<ds-truncatable-part [id]="dso.id" [minLines]="3">
|
||||||
<span [innerHTML]="firstMetadataValue('project.identifier.funder')"></span>
|
<span [innerHTML]="firstMetadataValue('project.identifier.funder')"></span>
|
||||||
</ds-truncatable-part>
|
</ds-truncatable-part>
|
||||||
|
@@ -0,0 +1,41 @@
|
|||||||
|
import { ItemSearchResult } from '../../../../shared/object-collection/shared/item-search-result.model';
|
||||||
|
import { Item } from '../../../../core/shared/item.model';
|
||||||
|
import { of as observableOf } from 'rxjs/internal/observable/of';
|
||||||
|
import { getEntityGridElementTestComponent } from '../../../../shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.spec';
|
||||||
|
import { ProjectGridElementComponent } from './project-grid-element.component';
|
||||||
|
|
||||||
|
const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult();
|
||||||
|
mockItemWithMetadata.hitHighlights = {};
|
||||||
|
mockItemWithMetadata.indexableObject = Object.assign(new Item(), {
|
||||||
|
bitstreams: observableOf({}),
|
||||||
|
metadata: {
|
||||||
|
'dc.title': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'This is just another title'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'project.identifier.funder': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'The project funder'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const mockItemWithoutMetadata: ItemSearchResult = new ItemSearchResult();
|
||||||
|
mockItemWithoutMetadata.hitHighlights = {};
|
||||||
|
mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), {
|
||||||
|
bitstreams: observableOf({}),
|
||||||
|
metadata: {
|
||||||
|
'dc.title': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'This is just another title'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('ProjectGridElementComponent', getEntityGridElementTestComponent(ProjectGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['funder']));
|
||||||
|
@@ -6,7 +6,7 @@ import { GridThumbnailComponent } from './grid-thumbnail.component';
|
|||||||
import { Bitstream } from '../../../core/shared/bitstream.model';
|
import { Bitstream } from '../../../core/shared/bitstream.model';
|
||||||
import { SafeUrlPipe } from '../../utils/safe-url-pipe';
|
import { SafeUrlPipe } from '../../utils/safe-url-pipe';
|
||||||
|
|
||||||
describe('ThumbnailComponent', () => {
|
describe('GridThumbnailComponent', () => {
|
||||||
let comp: GridThumbnailComponent;
|
let comp: GridThumbnailComponent;
|
||||||
let fixture: ComponentFixture<GridThumbnailComponent>;
|
let fixture: ComponentFixture<GridThumbnailComponent>;
|
||||||
let de: DebugElement;
|
let de: DebugElement;
|
||||||
@@ -36,7 +36,7 @@ describe('ThumbnailComponent', () => {
|
|||||||
it('should display placeholder', () => {
|
it('should display placeholder', () => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
const image: HTMLElement = de.query(By.css('img')).nativeElement;
|
const image: HTMLElement = de.query(By.css('img')).nativeElement;
|
||||||
expect(image.getAttribute('src')).toBe(comp.holderSource);
|
expect(image.getAttribute('src')).toBe(comp.defaultImage);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@@ -20,7 +20,7 @@
|
|||||||
</span>
|
</span>
|
||||||
</ds-truncatable-part>
|
</ds-truncatable-part>
|
||||||
</p>
|
</p>
|
||||||
<p class="item-abstract card-text">
|
<p *ngIf="dso.hasMetadata('dc.description.abstract')" class="item-abstract card-text">
|
||||||
<ds-truncatable-part [id]="dso.id" [minLines]="3">
|
<ds-truncatable-part [id]="dso.id" [minLines]="3">
|
||||||
<span [innerHTML]="firstMetadataValue('dc.description.abstract')"></span>
|
<span [innerHTML]="firstMetadataValue('dc.description.abstract')"></span>
|
||||||
</ds-truncatable-part>
|
</ds-truncatable-part>
|
||||||
|
@@ -0,0 +1,124 @@
|
|||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||||
|
import { TruncatePipe } from '../../../../utils/truncate.pipe';
|
||||||
|
import { TruncatableService } from '../../../../truncatable/truncatable.service';
|
||||||
|
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
|
import { By } from '@angular/platform-browser';
|
||||||
|
import { PublicationGridElementComponent } from './publication-grid-element.component';
|
||||||
|
import { of as observableOf } from 'rxjs/internal/observable/of';
|
||||||
|
import { ItemSearchResult } from '../../../../object-collection/shared/item-search-result.model';
|
||||||
|
import { Item } from '../../../../../core/shared/item.model';
|
||||||
|
import { ITEM } from '../../../../items/switcher/item-type-switcher.component';
|
||||||
|
|
||||||
|
const mockItemWithMetadata: ItemSearchResult = new ItemSearchResult();
|
||||||
|
mockItemWithMetadata.hitHighlights = {};
|
||||||
|
mockItemWithMetadata.indexableObject = Object.assign(new Item(), {
|
||||||
|
bitstreams: observableOf({}),
|
||||||
|
metadata: {
|
||||||
|
'dc.title': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'This is just another title'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'dc.contributor.author': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'Smith, Donald'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'dc.date.issued': [
|
||||||
|
{
|
||||||
|
language: null,
|
||||||
|
value: '2015-06-26'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'dc.description.abstract': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'This is an abstract'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const mockItemWithoutMetadata: ItemSearchResult = new ItemSearchResult();
|
||||||
|
mockItemWithoutMetadata.hitHighlights = {};
|
||||||
|
mockItemWithoutMetadata.indexableObject = Object.assign(new Item(), {
|
||||||
|
bitstreams: observableOf({}),
|
||||||
|
metadata: {
|
||||||
|
'dc.title': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'This is just another title'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('PublicationGridElementComponent', getEntityGridElementTestComponent(PublicationGridElementComponent, mockItemWithMetadata, mockItemWithoutMetadata, ['authors', 'date', 'abstract']));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create test cases for a grid component of an entity.
|
||||||
|
* @param component The component's class
|
||||||
|
* @param searchResultWithMetadata An ItemSearchResult containing an item with metadata that should be displayed in the grid element
|
||||||
|
* @param searchResultWithoutMetadata An ItemSearchResult containing an item that's missing the metadata that should be displayed in the grid element
|
||||||
|
* @param fieldsToCheck A list of fields to check. The tests expect to find html elements with class ".item-${field}", so make sure they exist in the html template of the grid element.
|
||||||
|
* For example: If one of the fields to check is labeled "authors", the html template should contain at least one element with class ".item-authors" that's
|
||||||
|
* present when the author metadata is available.
|
||||||
|
*/
|
||||||
|
export function getEntityGridElementTestComponent(component, searchResultWithMetadata: ItemSearchResult, searchResultWithoutMetadata: ItemSearchResult, fieldsToCheck: string[]) {
|
||||||
|
return () => {
|
||||||
|
let comp;
|
||||||
|
let fixture;
|
||||||
|
|
||||||
|
const truncatableServiceStub: any = {
|
||||||
|
isCollapsed: (id: number) => observableOf(true),
|
||||||
|
};
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
imports: [NoopAnimationsModule],
|
||||||
|
declarations: [component, TruncatePipe],
|
||||||
|
providers: [
|
||||||
|
{ provide: TruncatableService, useValue: truncatableServiceStub },
|
||||||
|
{provide: ITEM, useValue: searchResultWithoutMetadata}
|
||||||
|
],
|
||||||
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
|
}).overrideComponent(component, {
|
||||||
|
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||||
|
}).compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
fixture = TestBed.createComponent(component);
|
||||||
|
comp = fixture.componentInstance;
|
||||||
|
}));
|
||||||
|
|
||||||
|
fieldsToCheck.forEach((field) => {
|
||||||
|
describe(`when the item has "${field}" metadata`, () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
comp.dso = searchResultWithMetadata.indexableObject;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should show the "${field}" field`, () => {
|
||||||
|
const itemAuthorField = fixture.debugElement.query(By.css(`.item-${field}`));
|
||||||
|
expect(itemAuthorField).not.toBeNull();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe(`when the item has no "${field}" metadata`, () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
comp.dso = searchResultWithoutMetadata.indexableObject;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should not show the "${field}" field`, () => {
|
||||||
|
const itemAuthorField = fixture.debugElement.query(By.css(`.item-${field}`));
|
||||||
|
expect(itemAuthorField).toBeNull();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -0,0 +1,83 @@
|
|||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
import { TruncatePipe } from '../../../utils/truncate.pipe';
|
||||||
|
import { TruncatableService } from '../../../truncatable/truncatable.service';
|
||||||
|
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
|
import { Item } from '../../../../core/shared/item.model';
|
||||||
|
import { RemoteData } from '../../../../core/data/remote-data';
|
||||||
|
import { PaginatedList } from '../../../../core/data/paginated-list';
|
||||||
|
import { PageInfo } from '../../../../core/shared/page-info.model';
|
||||||
|
import { ITEM } from '../../../items/switcher/item-type-switcher.component';
|
||||||
|
import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model';
|
||||||
|
import { createRelationshipsObservable } from '../../../../+item-page/simple/item-types/shared/item.component.spec';
|
||||||
|
import { of as observableOf } from 'rxjs';
|
||||||
|
import { MetadataMap } from '../../../../core/shared/metadata.models';
|
||||||
|
import { TypedItemSearchResultGridElementComponent } from './typed-item-search-result-grid-element.component';
|
||||||
|
|
||||||
|
const mockItem: Item = Object.assign(new Item(), {
|
||||||
|
bitstreams: observableOf(new RemoteData(false, false, true, null, new PaginatedList(new PageInfo(), []))),
|
||||||
|
metadata: [],
|
||||||
|
relationships: createRelationshipsObservable()
|
||||||
|
});
|
||||||
|
const mockSearchResult = {
|
||||||
|
indexableObject: mockItem as Item,
|
||||||
|
hitHighlights: new MetadataMap()
|
||||||
|
} as ItemSearchResult;
|
||||||
|
|
||||||
|
describe('TypedItemSearchResultGridElementComponent', () => {
|
||||||
|
let comp: TypedItemSearchResultGridElementComponent;
|
||||||
|
let fixture: ComponentFixture<TypedItemSearchResultGridElementComponent>;
|
||||||
|
|
||||||
|
describe('when injecting an Item', () => {
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [TypedItemSearchResultGridElementComponent, TruncatePipe],
|
||||||
|
providers: [
|
||||||
|
{provide: TruncatableService, useValue: {}},
|
||||||
|
{provide: ITEM, useValue: mockItem}
|
||||||
|
],
|
||||||
|
|
||||||
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
|
}).overrideComponent(TypedItemSearchResultGridElementComponent, {
|
||||||
|
set: {changeDetection: ChangeDetectionStrategy.Default}
|
||||||
|
}).compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
fixture = TestBed.createComponent(TypedItemSearchResultGridElementComponent);
|
||||||
|
comp = fixture.componentInstance;
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should initiate item, object and dso correctly', () => {
|
||||||
|
expect(comp.item).toBe(mockItem);
|
||||||
|
expect(comp.dso).toBe(mockItem);
|
||||||
|
expect(comp.object.indexableObject).toBe(mockItem);
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when injecting an ItemSearchResult', () => {
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [TypedItemSearchResultGridElementComponent, TruncatePipe],
|
||||||
|
providers: [
|
||||||
|
{provide: TruncatableService, useValue: {}},
|
||||||
|
{provide: ITEM, useValue: mockSearchResult}
|
||||||
|
],
|
||||||
|
|
||||||
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
|
}).overrideComponent(TypedItemSearchResultGridElementComponent, {
|
||||||
|
set: {changeDetection: ChangeDetectionStrategy.Default}
|
||||||
|
}).compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
fixture = TestBed.createComponent(TypedItemSearchResultGridElementComponent);
|
||||||
|
comp = fixture.componentInstance;
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should initiate item, object and dso correctly', () => {
|
||||||
|
expect(comp.item).toBe(mockItem);
|
||||||
|
expect(comp.dso).toBe(mockItem);
|
||||||
|
expect(comp.object.indexableObject).toBe(mockItem);
|
||||||
|
})
|
||||||
|
});
|
||||||
|
});
|
||||||
|
@@ -8,6 +8,7 @@ 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 { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||||
import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model';
|
import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model';
|
||||||
|
import { ItemViewMode } from '../../../items/item-type-decorator';
|
||||||
|
|
||||||
let itemSearchResultGridElementComponent: ItemSearchResultGridElementComponent;
|
let itemSearchResultGridElementComponent: ItemSearchResultGridElementComponent;
|
||||||
let fixture: ComponentFixture<ItemSearchResultGridElementComponent>;
|
let fixture: ComponentFixture<ItemSearchResultGridElementComponent>;
|
||||||
@@ -16,41 +17,17 @@ const truncatableServiceStub: any = {
|
|||||||
isCollapsed: (id: number) => observableOf(true),
|
isCollapsed: (id: number) => observableOf(true),
|
||||||
};
|
};
|
||||||
|
|
||||||
const mockItemWithAuthorAndDate: ItemSearchResult = new ItemSearchResult();
|
const type = 'authorOfPublication';
|
||||||
mockItemWithAuthorAndDate.hitHighlights = {};
|
|
||||||
mockItemWithAuthorAndDate.indexableObject = Object.assign(new Item(), {
|
|
||||||
bitstreams: observableOf({}),
|
|
||||||
metadata: {
|
|
||||||
'dc.contributor.author': [
|
|
||||||
{
|
|
||||||
language: 'en_US',
|
|
||||||
value: 'Smith, Donald'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
'dc.date.issued': [
|
|
||||||
{
|
|
||||||
language: null,
|
|
||||||
value: '2015-06-26'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const mockItemWithoutAuthorAndDate: ItemSearchResult = new ItemSearchResult();
|
const mockItemWithRelationshipType: ItemSearchResult = new ItemSearchResult();
|
||||||
mockItemWithoutAuthorAndDate.hitHighlights = {};
|
mockItemWithRelationshipType.hitHighlights = {};
|
||||||
mockItemWithoutAuthorAndDate.indexableObject = Object.assign(new Item(), {
|
mockItemWithRelationshipType.indexableObject = Object.assign(new Item(), {
|
||||||
bitstreams: observableOf({}),
|
bitstreams: observableOf({}),
|
||||||
metadata: {
|
metadata: {
|
||||||
'dc.title': [
|
'relationship.type': [
|
||||||
{
|
{
|
||||||
language: 'en_US',
|
language: 'en_US',
|
||||||
value: 'This is just another title'
|
value: type
|
||||||
}
|
|
||||||
],
|
|
||||||
'dc.type': [
|
|
||||||
{
|
|
||||||
language: null,
|
|
||||||
value: 'Article'
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -63,7 +40,7 @@ describe('ItemSearchResultGridElementComponent', () => {
|
|||||||
declarations: [ItemSearchResultGridElementComponent, TruncatePipe],
|
declarations: [ItemSearchResultGridElementComponent, TruncatePipe],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: TruncatableService, useValue: truncatableServiceStub },
|
{ provide: TruncatableService, useValue: truncatableServiceStub },
|
||||||
{ provide: 'objectElementProvider', useValue: (mockItemWithoutAuthorAndDate) }
|
{ provide: 'objectElementProvider', useValue: (mockItemWithRelationshipType) }
|
||||||
],
|
],
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
}).overrideComponent(ItemSearchResultGridElementComponent, {
|
}).overrideComponent(ItemSearchResultGridElementComponent, {
|
||||||
@@ -76,51 +53,9 @@ describe('ItemSearchResultGridElementComponent', () => {
|
|||||||
itemSearchResultGridElementComponent = fixture.componentInstance;
|
itemSearchResultGridElementComponent = fixture.componentInstance;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe('When the item has an author', () => {
|
it('should show send the object to item-type-switcher using viewMode "Card"', () => {
|
||||||
beforeEach(() => {
|
const itemTypeSwitcherComp = fixture.debugElement.query(By.css('ds-item-type-switcher')).componentInstance;
|
||||||
itemSearchResultGridElementComponent.dso = mockItemWithAuthorAndDate.indexableObject;
|
expect(itemTypeSwitcherComp.object).toBe(mockItemWithRelationshipType);
|
||||||
fixture.detectChanges();
|
expect(itemTypeSwitcherComp.viewMode).toEqual(ItemViewMode.Card);
|
||||||
});
|
|
||||||
|
|
||||||
it('should show the author paragraph', () => {
|
|
||||||
const itemAuthorField = fixture.debugElement.query(By.css('p.item-authors'));
|
|
||||||
expect(itemAuthorField).not.toBeNull();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('When the item has no author', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
itemSearchResultGridElementComponent.dso = mockItemWithoutAuthorAndDate.indexableObject;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
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.indexableObject;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
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.indexableObject;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not show the issuedate span', () => {
|
|
||||||
const dateField = fixture.debugElement.query(By.css('span.item-date'));
|
|
||||||
expect(dateField).toBeNull();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -23,7 +23,7 @@ const mockSearchResult = {
|
|||||||
hitHighlights: new MetadataMap()
|
hitHighlights: new MetadataMap()
|
||||||
} as ItemSearchResult;
|
} as ItemSearchResult;
|
||||||
|
|
||||||
describe('ItemSearchResultComponent', () => {
|
describe('TypedItemSearchResultListElementComponent', () => {
|
||||||
let comp: TypedItemSearchResultListElementComponent;
|
let comp: TypedItemSearchResultListElementComponent;
|
||||||
let fixture: ComponentFixture<TypedItemSearchResultListElementComponent>;
|
let fixture: ComponentFixture<TypedItemSearchResultListElementComponent>;
|
||||||
|
|
||||||
|
@@ -0,0 +1,83 @@
|
|||||||
|
import { ItemSearchResult } from '../../object-collection/shared/item-search-result.model';
|
||||||
|
import { Item } from '../../../core/shared/item.model';
|
||||||
|
import { of as observableOf } from 'rxjs/internal/observable/of';
|
||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
|
import { TruncatePipe } from '../../utils/truncate.pipe';
|
||||||
|
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
|
import { ItemTypeBadgeComponent } from './item-type-badge.component';
|
||||||
|
import { By } from '@angular/platform-browser';
|
||||||
|
|
||||||
|
let comp: ItemTypeBadgeComponent;
|
||||||
|
let fixture: ComponentFixture<ItemTypeBadgeComponent>;
|
||||||
|
|
||||||
|
const type = 'authorOfPublication';
|
||||||
|
|
||||||
|
const mockItemWithRelationshipType: ItemSearchResult = new ItemSearchResult();
|
||||||
|
mockItemWithRelationshipType.hitHighlights = {};
|
||||||
|
mockItemWithRelationshipType.indexableObject = Object.assign(new Item(), {
|
||||||
|
bitstreams: observableOf({}),
|
||||||
|
metadata: {
|
||||||
|
'relationship.type': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: type
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const mockItemWithoutRelationshipType: ItemSearchResult = new ItemSearchResult();
|
||||||
|
mockItemWithoutRelationshipType.hitHighlights = {};
|
||||||
|
mockItemWithoutRelationshipType.indexableObject = Object.assign(new Item(), {
|
||||||
|
bitstreams: observableOf({}),
|
||||||
|
metadata: {
|
||||||
|
'dc.title': [
|
||||||
|
{
|
||||||
|
language: 'en_US',
|
||||||
|
value: 'This is just another title'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('ItemTypeBadgeComponent', () => {
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
imports: [TranslateModule.forRoot()],
|
||||||
|
declarations: [ItemTypeBadgeComponent, TruncatePipe],
|
||||||
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
|
}).overrideComponent(ItemTypeBadgeComponent, {
|
||||||
|
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||||
|
}).compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
fixture = TestBed.createComponent(ItemTypeBadgeComponent);
|
||||||
|
comp = fixture.componentInstance;
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe('When the item has a relationship type', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
comp.object = mockItemWithRelationshipType;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should show the relationship type badge', () => {
|
||||||
|
const badge = fixture.debugElement.query(By.css('span.badge'));
|
||||||
|
expect(badge.nativeElement.textContent).toContain(type.toLowerCase());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('When the item has no relationship type', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
comp.object = mockItemWithoutRelationshipType;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not show a badge', () => {
|
||||||
|
const badge = fixture.debugElement.query(By.css('span.badge'));
|
||||||
|
expect(badge).toBeNull();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@@ -33,20 +33,6 @@ mockItemWithRelationshipType.indexableObject = Object.assign(new Item(), {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const mockItemWithoutRelationshipType: ItemSearchResult = new ItemSearchResult();
|
|
||||||
mockItemWithoutRelationshipType.hitHighlights = {};
|
|
||||||
mockItemWithoutRelationshipType.indexableObject = Object.assign(new Item(), {
|
|
||||||
bitstreams: observableOf({}),
|
|
||||||
metadata: {
|
|
||||||
'dc.title': [
|
|
||||||
{
|
|
||||||
language: 'en_US',
|
|
||||||
value: 'This is just another title'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('ItemSearchResultListElementComponent', () => {
|
describe('ItemSearchResultListElementComponent', () => {
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
@@ -54,7 +40,7 @@ describe('ItemSearchResultListElementComponent', () => {
|
|||||||
declarations: [ItemSearchResultListElementComponent, TruncatePipe],
|
declarations: [ItemSearchResultListElementComponent, TruncatePipe],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: TruncatableService, useValue: truncatableServiceStub },
|
{ provide: TruncatableService, useValue: truncatableServiceStub },
|
||||||
{ provide: 'objectElementProvider', useValue: (mockItemWithoutRelationshipType) }
|
{ provide: 'objectElementProvider', useValue: (mockItemWithRelationshipType) }
|
||||||
],
|
],
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
}).overrideComponent(ItemSearchResultListElementComponent, {
|
}).overrideComponent(ItemSearchResultListElementComponent, {
|
||||||
@@ -67,27 +53,8 @@ describe('ItemSearchResultListElementComponent', () => {
|
|||||||
itemSearchResultListElementComponent = fixture.componentInstance;
|
itemSearchResultListElementComponent = fixture.componentInstance;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe('When the item has a relationship type', () => {
|
it('should show a badge on top of the list element', () => {
|
||||||
beforeEach(() => {
|
const badge = fixture.debugElement.query(By.css('ds-item-type-badge')).componentInstance;
|
||||||
itemSearchResultListElementComponent.object = mockItemWithRelationshipType;
|
expect(badge.object).toBe(mockItemWithRelationshipType);
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should show the relationship type badge', () => {
|
|
||||||
const badge = fixture.debugElement.query(By.css('span.badge'));
|
|
||||||
expect(badge.nativeElement.textContent).toContain(type.toLowerCase());
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('When the item has no relationship type', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
itemSearchResultListElementComponent.object = mockItemWithoutRelationshipType;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not show a badge', () => {
|
|
||||||
const badge = fixture.debugElement.query(By.css('span.badge'));
|
|
||||||
expect(badge).toBeNull();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user