mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-13 04:53:06 +00:00
56434: Fixed existing tests and added entity-list-element component tests
This commit is contained in:
@@ -21,6 +21,7 @@ import { SearchSidebarService } from './search-sidebar/search-sidebar.service';
|
||||
import { SearchFilterService } from './search-filters/search-filter/search-filter.service';
|
||||
import { SearchConfigurationService } from './search-service/search-configuration.service';
|
||||
import { RemoteData } from '../core/data/remote-data';
|
||||
import { RouteService } from '../shared/services/route.service';
|
||||
|
||||
describe('SearchPageComponent', () => {
|
||||
let comp: SearchPageComponent;
|
||||
@@ -62,6 +63,11 @@ describe('SearchPageComponent', () => {
|
||||
collapse: () => this.isCollapsed = Observable.of(true),
|
||||
expand: () => this.isCollapsed = Observable.of(false)
|
||||
};
|
||||
const routeServiceStub = {
|
||||
getRouteParameterValue: () => {
|
||||
return Observable.of('');
|
||||
}
|
||||
};
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
@@ -92,7 +98,8 @@ describe('SearchPageComponent', () => {
|
||||
{
|
||||
provide: SearchFilterService,
|
||||
useValue: {}
|
||||
}, {
|
||||
},
|
||||
{
|
||||
provide: SearchConfigurationService,
|
||||
useValue: {
|
||||
paginatedSearchOptions: hot('a', {
|
||||
@@ -101,6 +108,10 @@ describe('SearchPageComponent', () => {
|
||||
getCurrentScope: (a) => Observable.of('test-id')
|
||||
}
|
||||
},
|
||||
{
|
||||
provide: RouteService,
|
||||
useValue: routeServiceStub
|
||||
}
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).overrideComponent(SearchPageComponent, {
|
||||
|
@@ -25,7 +25,8 @@ describe('SearchConfigurationService', () => {
|
||||
|
||||
const routeService = jasmine.createSpyObj('RouteService', {
|
||||
getQueryParameterValue: Observable.of(value1),
|
||||
getQueryParamsWithPrefix: Observable.of(prefixFilter)
|
||||
getQueryParamsWithPrefix: Observable.of(prefixFilter),
|
||||
getRouteParameterValue: Observable.of('')
|
||||
});
|
||||
|
||||
const fixedFilterService = jasmine.createSpyObj('SearchFixedFilterService', {
|
||||
|
@@ -14,7 +14,7 @@ import { getSucceededRemoteData } from '../../core/shared/operators';
|
||||
import { SearchFilter } from '../search-filter.model';
|
||||
import { DSpaceObjectType } from '../../core/shared/dspace-object-type.model';
|
||||
import { SearchFixedFilterService } from '../search-filters/search-filter/search-fixed-filter.service';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { flatMap, map } from 'rxjs/operators';
|
||||
|
||||
/**
|
||||
* Service that performs all actions that have to do with the current search configuration
|
||||
@@ -173,8 +173,9 @@ export class SearchConfigurationService implements OnDestroy {
|
||||
* @returns {Observable<string>} Emits the current fixed filter as a string
|
||||
*/
|
||||
getCurrentFixedFilter(): Observable<string> {
|
||||
const fixedFilter: Observable<string> = this.routeService.getRouteParameterValue('filter');
|
||||
return fixedFilter.flatMap((f) => this.fixedFilterService.getQueryByFilterName(f));
|
||||
return this.routeService.getRouteParameterValue('filter').pipe(
|
||||
flatMap((f) => this.fixedFilterService.getQueryByFilterName(f))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,108 +0,0 @@
|
||||
import { EntityListElementComponent } from './entity-list-element.component';
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ChangeDetectionStrategy, 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 { Observable } from 'rxjs/Observable';
|
||||
|
||||
let itemListElementComponent: EntityListElementComponent;
|
||||
let fixture: ComponentFixture<EntityListElementComponent>;
|
||||
|
||||
const mockItemWithAuthorAndDate: Item = Object.assign(new Item(), {
|
||||
bitstreams: Observable.of({}),
|
||||
metadata: [
|
||||
{
|
||||
key: 'dc.contributor.author',
|
||||
language: 'en_US',
|
||||
value: 'Smith, Donald'
|
||||
},
|
||||
{
|
||||
key: 'dc.date.issued',
|
||||
language: null,
|
||||
value: '2015-06-26'
|
||||
}]
|
||||
});
|
||||
const mockItemWithoutAuthorAndDate: Item = Object.assign(new Item(), {
|
||||
bitstreams: Observable.of({}),
|
||||
metadata: [
|
||||
{
|
||||
key: 'dc.title',
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
},
|
||||
{
|
||||
key: 'dc.type',
|
||||
language: null,
|
||||
value: 'Article'
|
||||
}]
|
||||
});
|
||||
|
||||
describe('EntityListElementComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ EntityListElementComponent , TruncatePipe],
|
||||
providers: [
|
||||
{ provide: 'objectElementProvider', useValue: {mockItemWithAuthorAndDate}}
|
||||
],
|
||||
|
||||
schemas: [ NO_ERRORS_SCHEMA ]
|
||||
}).overrideComponent(EntityListElementComponent, {
|
||||
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(EntityListElementComponent);
|
||||
itemListElementComponent = fixture.componentInstance;
|
||||
|
||||
}));
|
||||
|
||||
describe('When the item has an author', () => {
|
||||
beforeEach(() => {
|
||||
itemListElementComponent.object = mockItemWithAuthorAndDate;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should show the author paragraph', () => {
|
||||
const itemAuthorField = fixture.debugElement.query(By.css('span.item-list-authors'));
|
||||
expect(itemAuthorField).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('When the item has no author', () => {
|
||||
beforeEach(() => {
|
||||
itemListElementComponent.object = mockItemWithoutAuthorAndDate;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should not show the author paragraph', () => {
|
||||
const itemAuthorField = fixture.debugElement.query(By.css('span.item-list-authors'));
|
||||
expect(itemAuthorField).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('When the item has an issuedate', () => {
|
||||
beforeEach(() => {
|
||||
itemListElementComponent.object = mockItemWithAuthorAndDate;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should show the issuedate span', () => {
|
||||
const itemAuthorField = fixture.debugElement.query(By.css('span.item-list-date'));
|
||||
expect(itemAuthorField).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('When the item has no issuedate', () => {
|
||||
beforeEach(() => {
|
||||
itemListElementComponent.object = mockItemWithoutAuthorAndDate;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should not show the issuedate span', () => {
|
||||
const dateField = fixture.debugElement.query(By.css('span.item-list-date'));
|
||||
expect(dateField).toBeNull();
|
||||
});
|
||||
});
|
||||
});
|
@@ -9,7 +9,8 @@
|
||||
<span *ngFor="let value of getValues(['journalvolume.identifier.volume']); let last=last;">
|
||||
<span [innerHTML]="value"><span [innerHTML]="value"></span></span>
|
||||
</span>
|
||||
<span *ngIf="item.filterMetadata(['journalissue.identifier.number']).length > 0">
|
||||
<span *ngIf="item.filterMetadata(['journalissue.identifier.number']).length > 0"
|
||||
class="item-list-journal-issue-numbers">
|
||||
<span *ngFor="let value of getValues(['journalissue.identifier.number']); let last=last;">
|
||||
<span> - </span><span [innerHTML]="value"><span [innerHTML]="value"></span></span>
|
||||
</span>
|
||||
|
@@ -0,0 +1,111 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { Item } from '../../../../../core/shared/item.model';
|
||||
import { TruncatePipe } from '../../../../utils/truncate.pipe';
|
||||
import { TruncatableService } from '../../../../truncatable/truncatable.service';
|
||||
import { ITEM } from '../../../../entities/switcher/entity-type-switcher.component';
|
||||
import { JournalIssueListElementComponent } from './journal-issue-list-element.component';
|
||||
|
||||
let journalIssueListElementComponent: JournalIssueListElementComponent;
|
||||
let fixture: ComponentFixture<JournalIssueListElementComponent>;
|
||||
|
||||
const mockItemWithMetadata: Item = Object.assign(new Item(), {
|
||||
bitstreams: Observable.of({}),
|
||||
metadata: [
|
||||
{
|
||||
key: 'dc.title',
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
},
|
||||
{
|
||||
key: 'journalvolume.identifier.volume',
|
||||
language: 'en_US',
|
||||
value: '1234'
|
||||
},
|
||||
{
|
||||
key: 'journalissue.identifier.number',
|
||||
language: 'en_US',
|
||||
value: '5678'
|
||||
}]
|
||||
});
|
||||
const mockItemWithoutMetadata: Item = Object.assign(new Item(), {
|
||||
bitstreams: Observable.of({}),
|
||||
metadata: [
|
||||
{
|
||||
key: 'dc.title',
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
}]
|
||||
});
|
||||
|
||||
describe('JournalIssueListElementComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ JournalIssueListElementComponent , TruncatePipe],
|
||||
providers: [
|
||||
{ provide: ITEM, useValue: mockItemWithMetadata},
|
||||
{ provide: TruncatableService, useValue: {} }
|
||||
],
|
||||
|
||||
schemas: [ NO_ERRORS_SCHEMA ]
|
||||
}).overrideComponent(JournalIssueListElementComponent, {
|
||||
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(JournalIssueListElementComponent);
|
||||
journalIssueListElementComponent = fixture.componentInstance;
|
||||
|
||||
}));
|
||||
|
||||
describe('When the item has a journal identifier', () => {
|
||||
beforeEach(() => {
|
||||
journalIssueListElementComponent.item = mockItemWithMetadata;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should show the journal issues span', () => {
|
||||
const journalIdentifierField = fixture.debugElement.query(By.css('span.item-list-journal-issues'));
|
||||
expect(journalIdentifierField).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('When the item has no journal identifier', () => {
|
||||
beforeEach(() => {
|
||||
journalIssueListElementComponent.item = mockItemWithoutMetadata;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should not show the journal issues span', () => {
|
||||
const journalIdentifierField = fixture.debugElement.query(By.css('span.item-list-journal-issues'));
|
||||
expect(journalIdentifierField).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('When the item has a journal number', () => {
|
||||
beforeEach(() => {
|
||||
journalIssueListElementComponent.item = mockItemWithMetadata;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should show the journal issue numbers span', () => {
|
||||
const journalNumberField = fixture.debugElement.query(By.css('span.item-list-journal-issue-numbers'));
|
||||
expect(journalNumberField).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('When the item has no journal number', () => {
|
||||
beforeEach(() => {
|
||||
journalIssueListElementComponent.item = mockItemWithoutMetadata;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should not show the journal issue numbers span', () => {
|
||||
const journalNumberField = fixture.debugElement.query(By.css('span.item-list-journal-issue-numbers'));
|
||||
expect(journalNumberField).toBeNull();
|
||||
});
|
||||
});
|
||||
});
|
@@ -10,7 +10,8 @@
|
||||
<span [innerHTML]="value"><span [innerHTML]="value"></span></span>
|
||||
</span>
|
||||
</span>
|
||||
<span *ngIf="item.filterMetadata(['journalvolume.identifier.volume']).length > 0">
|
||||
<span *ngIf="item.filterMetadata(['journalvolume.identifier.volume']).length > 0"
|
||||
class="item-list-journal-volume-identifiers">
|
||||
<span *ngFor="let value of getValues(['journalvolume.identifier.volume']); let last=last;">
|
||||
<span> (</span><span [innerHTML]="value"><span [innerHTML]="value"></span></span><span>)</span>
|
||||
</span>
|
||||
|
@@ -0,0 +1,111 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { Item } from '../../../../../core/shared/item.model';
|
||||
import { TruncatePipe } from '../../../../utils/truncate.pipe';
|
||||
import { TruncatableService } from '../../../../truncatable/truncatable.service';
|
||||
import { ITEM } from '../../../../entities/switcher/entity-type-switcher.component';
|
||||
import { JournalVolumeListElementComponent } from './journal-volume-list-element.component';
|
||||
|
||||
let journalVolumeListElementComponent: JournalVolumeListElementComponent;
|
||||
let fixture: ComponentFixture<JournalVolumeListElementComponent>;
|
||||
|
||||
const mockItemWithMetadata: Item = Object.assign(new Item(), {
|
||||
bitstreams: Observable.of({}),
|
||||
metadata: [
|
||||
{
|
||||
key: 'dc.title',
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
},
|
||||
{
|
||||
key: 'journal.title',
|
||||
language: 'en_US',
|
||||
value: 'This is just another journal title'
|
||||
},
|
||||
{
|
||||
key: 'journalvolume.identifier.volume',
|
||||
language: 'en_US',
|
||||
value: '1234'
|
||||
}]
|
||||
});
|
||||
const mockItemWithoutMetadata: Item = Object.assign(new Item(), {
|
||||
bitstreams: Observable.of({}),
|
||||
metadata: [
|
||||
{
|
||||
key: 'dc.title',
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
}]
|
||||
});
|
||||
|
||||
describe('JournalVolumeListElementComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ JournalVolumeListElementComponent , TruncatePipe],
|
||||
providers: [
|
||||
{ provide: ITEM, useValue: mockItemWithMetadata},
|
||||
{ provide: TruncatableService, useValue: {} }
|
||||
],
|
||||
|
||||
schemas: [ NO_ERRORS_SCHEMA ]
|
||||
}).overrideComponent(JournalVolumeListElementComponent, {
|
||||
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(JournalVolumeListElementComponent);
|
||||
journalVolumeListElementComponent = fixture.componentInstance;
|
||||
|
||||
}));
|
||||
|
||||
describe('When the item has a journal title', () => {
|
||||
beforeEach(() => {
|
||||
journalVolumeListElementComponent.item = mockItemWithMetadata;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should show the journal title span', () => {
|
||||
const journalTitleField = fixture.debugElement.query(By.css('span.item-list-journal-volumes'));
|
||||
expect(journalTitleField).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('When the item has no journal title', () => {
|
||||
beforeEach(() => {
|
||||
journalVolumeListElementComponent.item = mockItemWithoutMetadata;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should not show the journal title span', () => {
|
||||
const journalTitleField = fixture.debugElement.query(By.css('span.item-list-journal-volumes'));
|
||||
expect(journalTitleField).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('When the item has a journal identifier', () => {
|
||||
beforeEach(() => {
|
||||
journalVolumeListElementComponent.item = mockItemWithMetadata;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should show the journal identifiers span', () => {
|
||||
const journalIdentifierField = fixture.debugElement.query(By.css('span.item-list-journal-volume-identifiers'));
|
||||
expect(journalIdentifierField).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('When the item has no journal identifier', () => {
|
||||
beforeEach(() => {
|
||||
journalVolumeListElementComponent.item = mockItemWithoutMetadata;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should not show the journal identifiers span', () => {
|
||||
const journalIdentifierField = fixture.debugElement.query(By.css('span.item-list-journal-volume-identifiers'));
|
||||
expect(journalIdentifierField).toBeNull();
|
||||
});
|
||||
});
|
||||
});
|
@@ -0,0 +1,82 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { Item } from '../../../../../core/shared/item.model';
|
||||
import { TruncatePipe } from '../../../../utils/truncate.pipe';
|
||||
import { TruncatableService } from '../../../../truncatable/truncatable.service';
|
||||
import { ITEM } from '../../../../entities/switcher/entity-type-switcher.component';
|
||||
import { JournalListElementComponent } from './journal-list-element.component';
|
||||
|
||||
let journalListElementComponent: JournalListElementComponent;
|
||||
let fixture: ComponentFixture<JournalListElementComponent>;
|
||||
|
||||
const mockItemWithMetadata: Item = Object.assign(new Item(), {
|
||||
bitstreams: Observable.of({}),
|
||||
metadata: [
|
||||
{
|
||||
key: 'dc.title',
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
},
|
||||
{
|
||||
key: 'journal.identifier.issn',
|
||||
language: 'en_US',
|
||||
value: '1234'
|
||||
}]
|
||||
});
|
||||
const mockItemWithoutMetadata: Item = Object.assign(new Item(), {
|
||||
bitstreams: Observable.of({}),
|
||||
metadata: [
|
||||
{
|
||||
key: 'dc.title',
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
}]
|
||||
});
|
||||
|
||||
describe('JournalListElementComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ JournalListElementComponent , TruncatePipe],
|
||||
providers: [
|
||||
{ provide: ITEM, useValue: mockItemWithMetadata},
|
||||
{ provide: TruncatableService, useValue: {} }
|
||||
],
|
||||
|
||||
schemas: [ NO_ERRORS_SCHEMA ]
|
||||
}).overrideComponent(JournalListElementComponent, {
|
||||
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(JournalListElementComponent);
|
||||
journalListElementComponent = fixture.componentInstance;
|
||||
|
||||
}));
|
||||
|
||||
describe('When the item has an issn', () => {
|
||||
beforeEach(() => {
|
||||
journalListElementComponent.item = mockItemWithMetadata;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should show the journals span', () => {
|
||||
const issnField = fixture.debugElement.query(By.css('span.item-list-journals'));
|
||||
expect(issnField).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('When the item has no issn', () => {
|
||||
beforeEach(() => {
|
||||
journalListElementComponent.item = mockItemWithoutMetadata;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should not show the journals span', () => {
|
||||
const issnField = fixture.debugElement.query(By.css('span.item-list-journals'));
|
||||
expect(issnField).toBeNull();
|
||||
});
|
||||
});
|
||||
});
|
@@ -5,7 +5,7 @@
|
||||
<span class="text-muted">
|
||||
<ds-truncatable-part [id]="item.id" [minLines]="3">
|
||||
<span *ngIf="item.filterMetadata(['orgunit.identifier.description']).length > 0"
|
||||
class="item-list-authors">
|
||||
class="item-list-orgunit-description">
|
||||
<ds-truncatable-part [id]="item.id" [minLines]="3"><span
|
||||
[innerHTML]="getFirstValue('orgunit.identifier.description')"></span>
|
||||
</ds-truncatable-part>
|
||||
|
@@ -0,0 +1,82 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { Item } from '../../../../../core/shared/item.model';
|
||||
import { TruncatePipe } from '../../../../utils/truncate.pipe';
|
||||
import { TruncatableService } from '../../../../truncatable/truncatable.service';
|
||||
import { ITEM } from '../../../../entities/switcher/entity-type-switcher.component';
|
||||
import { OrgUnitListElementComponent } from './orgunit-list-element.component';
|
||||
|
||||
let orgUnitListElementComponent: OrgUnitListElementComponent;
|
||||
let fixture: ComponentFixture<OrgUnitListElementComponent>;
|
||||
|
||||
const mockItemWithMetadata: Item = Object.assign(new Item(), {
|
||||
bitstreams: Observable.of({}),
|
||||
metadata: [
|
||||
{
|
||||
key: 'dc.title',
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
},
|
||||
{
|
||||
key: 'orgunit.identifier.description',
|
||||
language: 'en_US',
|
||||
value: 'A description about the OrgUnit'
|
||||
}]
|
||||
});
|
||||
const mockItemWithoutMetadata: Item = Object.assign(new Item(), {
|
||||
bitstreams: Observable.of({}),
|
||||
metadata: [
|
||||
{
|
||||
key: 'dc.title',
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
}]
|
||||
});
|
||||
|
||||
describe('OrgUnitListElementComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ OrgUnitListElementComponent , TruncatePipe],
|
||||
providers: [
|
||||
{ provide: ITEM, useValue: mockItemWithMetadata},
|
||||
{ provide: TruncatableService, useValue: {} }
|
||||
],
|
||||
|
||||
schemas: [ NO_ERRORS_SCHEMA ]
|
||||
}).overrideComponent(OrgUnitListElementComponent, {
|
||||
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(OrgUnitListElementComponent);
|
||||
orgUnitListElementComponent = fixture.componentInstance;
|
||||
|
||||
}));
|
||||
|
||||
describe('When the item has an orgunit description', () => {
|
||||
beforeEach(() => {
|
||||
orgUnitListElementComponent.item = mockItemWithMetadata;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should show the description span', () => {
|
||||
const orgunitDescriptionField = fixture.debugElement.query(By.css('span.item-list-orgunit-description'));
|
||||
expect(orgunitDescriptionField).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('When the item has no orgunit description', () => {
|
||||
beforeEach(() => {
|
||||
orgUnitListElementComponent.item = mockItemWithoutMetadata;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should not show the description span', () => {
|
||||
const orgunitDescriptionField = fixture.debugElement.query(By.css('span.item-list-orgunit-description'));
|
||||
expect(orgunitDescriptionField).toBeNull();
|
||||
});
|
||||
});
|
||||
});
|
@@ -5,7 +5,7 @@
|
||||
<span class="text-muted">
|
||||
<ds-truncatable-part [id]="item.id" [minLines]="1">
|
||||
<span *ngIf="item.filterMetadata(['person.identifier.jobtitle']).length > 0"
|
||||
class="item-list-authors">
|
||||
class="item-list-job-title">
|
||||
<span *ngFor="let value of getValues(['person.identifier.jobtitle']); let last=last;">
|
||||
<span [innerHTML]="value"><span [innerHTML]="value"></span></span>
|
||||
</span>
|
||||
|
@@ -0,0 +1,82 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { Item } from '../../../../../core/shared/item.model';
|
||||
import { TruncatePipe } from '../../../../utils/truncate.pipe';
|
||||
import { TruncatableService } from '../../../../truncatable/truncatable.service';
|
||||
import { ITEM } from '../../../../entities/switcher/entity-type-switcher.component';
|
||||
import { PersonListElementComponent } from './person-list-element.component';
|
||||
|
||||
let personListElementComponent: PersonListElementComponent;
|
||||
let fixture: ComponentFixture<PersonListElementComponent>;
|
||||
|
||||
const mockItemWithMetadata: Item = Object.assign(new Item(), {
|
||||
bitstreams: Observable.of({}),
|
||||
metadata: [
|
||||
{
|
||||
key: 'dc.title',
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
},
|
||||
{
|
||||
key: 'person.identifier.jobtitle',
|
||||
language: 'en_US',
|
||||
value: 'Developer'
|
||||
}]
|
||||
});
|
||||
const mockItemWithoutMetadata: Item = Object.assign(new Item(), {
|
||||
bitstreams: Observable.of({}),
|
||||
metadata: [
|
||||
{
|
||||
key: 'dc.title',
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
}]
|
||||
});
|
||||
|
||||
describe('PersonListElementComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ PersonListElementComponent , TruncatePipe],
|
||||
providers: [
|
||||
{ provide: ITEM, useValue: mockItemWithMetadata},
|
||||
{ provide: TruncatableService, useValue: {} }
|
||||
],
|
||||
|
||||
schemas: [ NO_ERRORS_SCHEMA ]
|
||||
}).overrideComponent(PersonListElementComponent, {
|
||||
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(PersonListElementComponent);
|
||||
personListElementComponent = fixture.componentInstance;
|
||||
|
||||
}));
|
||||
|
||||
describe('When the item has a job title', () => {
|
||||
beforeEach(() => {
|
||||
personListElementComponent.item = mockItemWithMetadata;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should show the job title span', () => {
|
||||
const jobTitleField = fixture.debugElement.query(By.css('span.item-list-job-title'));
|
||||
expect(jobTitleField).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('When the item has no job title', () => {
|
||||
beforeEach(() => {
|
||||
personListElementComponent.item = mockItemWithoutMetadata;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should not show the job title span', () => {
|
||||
const jobTitleField = fixture.debugElement.query(By.css('span.item-list-job-title'));
|
||||
expect(jobTitleField).toBeNull();
|
||||
});
|
||||
});
|
||||
});
|
@@ -5,7 +5,7 @@
|
||||
<span class="text-muted">
|
||||
<ds-truncatable-part [id]="item.id" [minLines]="1">
|
||||
<span *ngIf="item.filterMetadata(['project.identifier.status']).length > 0"
|
||||
class="item-list-authors">
|
||||
class="item-list-status">
|
||||
<span *ngFor="let value of getValues(['project.identifier.status']); let last=last;">
|
||||
<span [innerHTML]="value"><span [innerHTML]="value"></span></span>
|
||||
</span>
|
||||
|
@@ -0,0 +1,82 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { Item } from '../../../../../core/shared/item.model';
|
||||
import { TruncatePipe } from '../../../../utils/truncate.pipe';
|
||||
import { TruncatableService } from '../../../../truncatable/truncatable.service';
|
||||
import { ITEM } from '../../../../entities/switcher/entity-type-switcher.component';
|
||||
import { ProjectListElementComponent } from './project-list-element.component';
|
||||
|
||||
let projectListElementComponent: ProjectListElementComponent;
|
||||
let fixture: ComponentFixture<ProjectListElementComponent>;
|
||||
|
||||
const mockItemWithMetadata: Item = Object.assign(new Item(), {
|
||||
bitstreams: Observable.of({}),
|
||||
metadata: [
|
||||
{
|
||||
key: 'dc.title',
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
},
|
||||
{
|
||||
key: 'project.identifier.status',
|
||||
language: 'en_US',
|
||||
value: 'A status about the project'
|
||||
}]
|
||||
});
|
||||
const mockItemWithoutMetadata: Item = Object.assign(new Item(), {
|
||||
bitstreams: Observable.of({}),
|
||||
metadata: [
|
||||
{
|
||||
key: 'dc.title',
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
}]
|
||||
});
|
||||
|
||||
describe('ProjectListElementComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ ProjectListElementComponent , TruncatePipe],
|
||||
providers: [
|
||||
{ provide: ITEM, useValue: mockItemWithMetadata},
|
||||
{ provide: TruncatableService, useValue: {} }
|
||||
],
|
||||
|
||||
schemas: [ NO_ERRORS_SCHEMA ]
|
||||
}).overrideComponent(ProjectListElementComponent, {
|
||||
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(ProjectListElementComponent);
|
||||
projectListElementComponent = fixture.componentInstance;
|
||||
|
||||
}));
|
||||
|
||||
describe('When the item has a status', () => {
|
||||
beforeEach(() => {
|
||||
projectListElementComponent.item = mockItemWithMetadata;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should show the status span', () => {
|
||||
const statusField = fixture.debugElement.query(By.css('span.item-list-status'));
|
||||
expect(statusField).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('When the item has no status', () => {
|
||||
beforeEach(() => {
|
||||
projectListElementComponent.item = mockItemWithoutMetadata;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should not show the status span', () => {
|
||||
const statusField = fixture.debugElement.query(By.css('span.item-list-status'));
|
||||
expect(statusField).toBeNull();
|
||||
});
|
||||
});
|
||||
});
|
@@ -0,0 +1,169 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { PublicationListElementComponent } from './publication-list-element.component';
|
||||
import { Item } from '../../../../../core/shared/item.model';
|
||||
import { TruncatePipe } from '../../../../utils/truncate.pipe';
|
||||
import { TruncatableService } from '../../../../truncatable/truncatable.service';
|
||||
import { ITEM } from '../../../../entities/switcher/entity-type-switcher.component';
|
||||
|
||||
let publicationListElementComponent: PublicationListElementComponent;
|
||||
let fixture: ComponentFixture<PublicationListElementComponent>;
|
||||
|
||||
const mockItemWithMetadata: Item = Object.assign(new Item(), {
|
||||
bitstreams: Observable.of({}),
|
||||
metadata: [
|
||||
{
|
||||
key: 'dc.title',
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
},
|
||||
{
|
||||
key: 'dc.contributor.author',
|
||||
language: 'en_US',
|
||||
value: 'Smith, Donald'
|
||||
},
|
||||
{
|
||||
key: 'dc.publisher',
|
||||
language: 'en_US',
|
||||
value: 'Atmire'
|
||||
},
|
||||
{
|
||||
key: 'dc.date.issued',
|
||||
language: null,
|
||||
value: '2015-06-26'
|
||||
},
|
||||
{
|
||||
key: 'dc.description.abstract',
|
||||
language: 'en_US',
|
||||
value: 'This is the abstract'
|
||||
}]
|
||||
});
|
||||
const mockItemWithoutMetadata: Item = Object.assign(new Item(), {
|
||||
bitstreams: Observable.of({}),
|
||||
metadata: [
|
||||
{
|
||||
key: 'dc.title',
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
}]
|
||||
});
|
||||
|
||||
describe('PublicationListElementComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ PublicationListElementComponent , TruncatePipe],
|
||||
providers: [
|
||||
{ provide: ITEM, useValue: mockItemWithMetadata},
|
||||
{ provide: TruncatableService, useValue: {} }
|
||||
],
|
||||
|
||||
schemas: [ NO_ERRORS_SCHEMA ]
|
||||
}).overrideComponent(PublicationListElementComponent, {
|
||||
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(PublicationListElementComponent);
|
||||
publicationListElementComponent = fixture.componentInstance;
|
||||
|
||||
}));
|
||||
|
||||
describe('When the item has an author', () => {
|
||||
beforeEach(() => {
|
||||
publicationListElementComponent.item = mockItemWithMetadata;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should show the author paragraph', () => {
|
||||
const itemAuthorField = fixture.debugElement.query(By.css('span.item-list-authors'));
|
||||
expect(itemAuthorField).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('When the item has no author', () => {
|
||||
beforeEach(() => {
|
||||
publicationListElementComponent.item = mockItemWithoutMetadata;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should not show the author paragraph', () => {
|
||||
const itemAuthorField = fixture.debugElement.query(By.css('span.item-list-authors'));
|
||||
expect(itemAuthorField).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('When the item has a publisher', () => {
|
||||
beforeEach(() => {
|
||||
publicationListElementComponent.item = mockItemWithMetadata;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should show the publisher span', () => {
|
||||
const publisherField = fixture.debugElement.query(By.css('span.item-list-publisher'));
|
||||
expect(publisherField).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('When the item has no publisher', () => {
|
||||
beforeEach(() => {
|
||||
publicationListElementComponent.item = mockItemWithoutMetadata;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should not show the publisher span', () => {
|
||||
const publisherField = fixture.debugElement.query(By.css('span.item-list-publisher'));
|
||||
expect(publisherField).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('When the item has an issuedate', () => {
|
||||
beforeEach(() => {
|
||||
publicationListElementComponent.item = mockItemWithMetadata;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should show the issuedate span', () => {
|
||||
const dateField = fixture.debugElement.query(By.css('span.item-list-date'));
|
||||
expect(dateField).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('When the item has no issuedate', () => {
|
||||
beforeEach(() => {
|
||||
publicationListElementComponent.item = mockItemWithoutMetadata;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should not show the issuedate span', () => {
|
||||
const dateField = fixture.debugElement.query(By.css('span.item-list-date'));
|
||||
expect(dateField).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('When the item has an abstract', () => {
|
||||
beforeEach(() => {
|
||||
publicationListElementComponent.item = mockItemWithMetadata;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should show the abstract span', () => {
|
||||
const abstractField = fixture.debugElement.query(By.css('div.item-list-abstract'));
|
||||
expect(abstractField).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('When the item has no abstract', () => {
|
||||
beforeEach(() => {
|
||||
publicationListElementComponent.item = mockItemWithoutMetadata;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should not show the abstract span', () => {
|
||||
const abstractField = fixture.debugElement.query(By.css('div.item-list-abstract'));
|
||||
expect(abstractField).toBeNull();
|
||||
});
|
||||
});
|
||||
});
|
@@ -1,120 +0,0 @@
|
||||
import { ItemSearchResultListElementComponent } from './item-search-result-list-element.component';
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { NO_ERRORS_SCHEMA, ChangeDetectionStrategy } 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';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model';
|
||||
|
||||
let itemSearchResultListElementComponent: ItemSearchResultListElementComponent;
|
||||
let fixture: ComponentFixture<ItemSearchResultListElementComponent>;
|
||||
|
||||
const truncatableServiceStub: any = {
|
||||
isCollapsed: (id: number) => Observable.of(true),
|
||||
};
|
||||
|
||||
const mockItemWithAuthorAndDate: ItemSearchResult = new ItemSearchResult();
|
||||
mockItemWithAuthorAndDate.hitHighlights = [];
|
||||
mockItemWithAuthorAndDate.dspaceObject = Object.assign(new Item(), {
|
||||
bitstreams: Observable.of({}),
|
||||
metadata: [
|
||||
{
|
||||
key: 'dc.contributor.author',
|
||||
language: 'en_US',
|
||||
value: 'Smith, Donald'
|
||||
},
|
||||
{
|
||||
key: 'dc.date.issued',
|
||||
language: null,
|
||||
value: '2015-06-26'
|
||||
}]
|
||||
});
|
||||
|
||||
const mockItemWithoutAuthorAndDate: ItemSearchResult = new ItemSearchResult();
|
||||
mockItemWithoutAuthorAndDate.hitHighlights = [];
|
||||
mockItemWithoutAuthorAndDate.dspaceObject = Object.assign(new Item(), {
|
||||
bitstreams: Observable.of({}),
|
||||
metadata: [
|
||||
{
|
||||
key: 'dc.title',
|
||||
language: 'en_US',
|
||||
value: 'This is just another title'
|
||||
},
|
||||
{
|
||||
key: 'dc.type',
|
||||
language: null,
|
||||
value: 'Article'
|
||||
}]
|
||||
});
|
||||
|
||||
describe('ItemSearchResultListElementComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopAnimationsModule],
|
||||
declarations: [ItemSearchResultListElementComponent, TruncatePipe],
|
||||
providers: [
|
||||
{ provide: TruncatableService, useValue: truncatableServiceStub },
|
||||
{ provide: 'objectElementProvider', useValue: (mockItemWithoutAuthorAndDate) }
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).overrideComponent(ItemSearchResultListElementComponent, {
|
||||
set: { changeDetection: ChangeDetectionStrategy.Default }
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(ItemSearchResultListElementComponent);
|
||||
itemSearchResultListElementComponent = fixture.componentInstance;
|
||||
}));
|
||||
|
||||
describe('When the item has an author', () => {
|
||||
beforeEach(() => {
|
||||
itemSearchResultListElementComponent.dso = mockItemWithAuthorAndDate.dspaceObject;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should show the author paragraph', () => {
|
||||
const itemAuthorField = fixture.debugElement.query(By.css('span.item-list-authors'));
|
||||
expect(itemAuthorField).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('When the item has no author', () => {
|
||||
beforeEach(() => {
|
||||
itemSearchResultListElementComponent.dso = mockItemWithoutAuthorAndDate.dspaceObject;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should not show the author paragraph', () => {
|
||||
const itemAuthorField = fixture.debugElement.query(By.css('span.item-list-authors'));
|
||||
expect(itemAuthorField).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('When the item has an issuedate', () => {
|
||||
beforeEach(() => {
|
||||
itemSearchResultListElementComponent.dso = mockItemWithAuthorAndDate.dspaceObject;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should show the issuedate span', () => {
|
||||
const itemAuthorField = fixture.debugElement.query(By.css('span.item-list-date'));
|
||||
expect(itemAuthorField).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('When the item has no issuedate', () => {
|
||||
beforeEach(() => {
|
||||
itemSearchResultListElementComponent.dso = mockItemWithoutAuthorAndDate.dspaceObject;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should not show the issuedate span', () => {
|
||||
const dateField = fixture.debugElement.query(By.css('span.item-list-date'));
|
||||
expect(dateField).toBeNull();
|
||||
});
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user