mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
94 lines
3.3 KiB
TypeScript
94 lines
3.3 KiB
TypeScript
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
|
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
|
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
|
|
|
import { of as observableOf } from 'rxjs';
|
|
|
|
import { Item } from '../../../../core/shared/item.model';
|
|
import { WorkspaceItemSearchResultDetailElementComponent } from './workspace-item-search-result-detail-element.component';
|
|
import { WorkspaceItem } from '../../../../core/submission/models/workspaceitem.model';
|
|
import { createSuccessfulRemoteDataObject } from '../../../remote-data.utils';
|
|
import { WorkflowItemSearchResult } from '../../../object-collection/shared/workflow-item-search-result.model';
|
|
import { getMockLinkService } from '../../../mocks/link-service.mock';
|
|
import { LinkService } from '../../../../core/cache/builders/link.service';
|
|
import { DSONameService } from '../../../../core/breadcrumbs/dso-name.service';
|
|
import { DSONameServiceMock } from '../../../mocks/dso-name.service.mock';
|
|
import { Context } from 'src/app/core/shared/context.model';
|
|
|
|
let component: WorkspaceItemSearchResultDetailElementComponent;
|
|
let fixture: ComponentFixture<WorkspaceItemSearchResultDetailElementComponent>;
|
|
|
|
const compIndex = 1;
|
|
|
|
const mockResultObject: WorkflowItemSearchResult = new WorkflowItemSearchResult();
|
|
mockResultObject.hitHighlights = {};
|
|
const linkService = getMockLinkService();
|
|
|
|
const item = Object.assign(new Item(), {
|
|
bundles: observableOf({}),
|
|
metadata: {
|
|
'dc.title': [
|
|
{
|
|
language: 'en_US',
|
|
value: 'This is just another title'
|
|
}
|
|
],
|
|
'dc.type': [
|
|
{
|
|
language: null,
|
|
value: 'Article'
|
|
}
|
|
],
|
|
'dc.contributor.author': [
|
|
{
|
|
language: 'en_US',
|
|
value: 'Smith, Donald'
|
|
}
|
|
],
|
|
'dc.date.issued': [
|
|
{
|
|
language: null,
|
|
value: '2015-06-26'
|
|
}
|
|
]
|
|
}
|
|
});
|
|
const rd = createSuccessfulRemoteDataObject(item);
|
|
mockResultObject.indexableObject = Object.assign(new WorkspaceItem(), { item: observableOf(rd) });
|
|
|
|
describe('WorkspaceItemSearchResultDetailElementComponent', () => {
|
|
beforeEach(waitForAsync(() => {
|
|
TestBed.configureTestingModule({
|
|
imports: [NoopAnimationsModule],
|
|
declarations: [WorkspaceItemSearchResultDetailElementComponent],
|
|
providers: [
|
|
{ provide: 'objectElementProvider', useValue: (mockResultObject) },
|
|
{ provide: 'indexElementProvider', useValue: (compIndex) },
|
|
{ provide: LinkService, useValue: linkService },
|
|
{ provide: DSONameService, useClass: DSONameServiceMock },
|
|
],
|
|
schemas: [NO_ERRORS_SCHEMA]
|
|
}).overrideComponent(WorkspaceItemSearchResultDetailElementComponent, {
|
|
set: { changeDetection: ChangeDetectionStrategy.Default }
|
|
}).compileComponents();
|
|
}));
|
|
|
|
beforeEach(waitForAsync(() => {
|
|
fixture = TestBed.createComponent(WorkspaceItemSearchResultDetailElementComponent);
|
|
component = fixture.componentInstance;
|
|
}));
|
|
|
|
beforeEach(() => {
|
|
component.dso = mockResultObject.indexableObject;
|
|
fixture.detectChanges();
|
|
});
|
|
|
|
it('should init item properly', () => {
|
|
expect(component.item).toEqual(item);
|
|
});
|
|
|
|
it('should have the correct child context', () => {
|
|
expect(component.childContext).toEqual(Context.MyDSpaceWorkspace);
|
|
});
|
|
});
|