mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-19 07:53:02 +00:00
fix SearchResultListElementComponent tests for workflow and workspace items
This commit is contained in:
@@ -1,14 +1,15 @@
|
|||||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||||
import { cold } from 'jasmine-marbles';
|
|
||||||
|
|
||||||
import { of as observableOf } from 'rxjs';
|
import { of as observableOf } from 'rxjs';
|
||||||
|
import { take } from 'rxjs/operators';
|
||||||
import { LinkService } from '../../../../core/cache/builders/link.service';
|
import { LinkService } from '../../../../core/cache/builders/link.service';
|
||||||
import { ItemDataService } from '../../../../core/data/item-data.service';
|
import { ItemDataService } from '../../../../core/data/item-data.service';
|
||||||
|
|
||||||
import { Item } from '../../../../core/shared/item.model';
|
import { Item } from '../../../../core/shared/item.model';
|
||||||
import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model';
|
import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model';
|
||||||
|
import { getMockLinkService } from '../../../mocks/mock-link-service';
|
||||||
import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type';
|
import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type';
|
||||||
import { WorkflowItemSearchResult } from '../../../object-collection/shared/workflow-item-search-result.model';
|
import { WorkflowItemSearchResult } from '../../../object-collection/shared/workflow-item-search-result.model';
|
||||||
import { createSuccessfulRemoteDataObject } from '../../../testing/utils';
|
import { createSuccessfulRemoteDataObject } from '../../../testing/utils';
|
||||||
@@ -59,11 +60,7 @@ let linkService;
|
|||||||
|
|
||||||
describe('WorkflowItemSearchResultListElementComponent', () => {
|
describe('WorkflowItemSearchResultListElementComponent', () => {
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
linkService = {
|
linkService = getMockLinkService();
|
||||||
resolveLink() {
|
|
||||||
// mock
|
|
||||||
},
|
|
||||||
};
|
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [NoopAnimationsModule],
|
imports: [NoopAnimationsModule],
|
||||||
declarations: [WorkflowItemSearchResultListElementComponent],
|
declarations: [WorkflowItemSearchResultListElementComponent],
|
||||||
@@ -88,8 +85,12 @@ describe('WorkflowItemSearchResultListElementComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should init item properly', () => {
|
it('should init item properly', (done) => {
|
||||||
expect(component.item$).toBeObservable(cold('a',{a: item}));
|
component.item$.pipe(take(1)).subscribe((i) => {
|
||||||
|
expect(linkService.resolveLink).toHaveBeenCalled();
|
||||||
|
expect(i).toBe(item);
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have properly status', () => {
|
it('should have properly status', () => {
|
||||||
|
@@ -3,11 +3,13 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
|||||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||||
|
|
||||||
import { of as observableOf } from 'rxjs';
|
import { of as observableOf } from 'rxjs';
|
||||||
|
import { take } from 'rxjs/operators';
|
||||||
import { LinkService } from '../../../../core/cache/builders/link.service';
|
import { LinkService } from '../../../../core/cache/builders/link.service';
|
||||||
import { ItemDataService } from '../../../../core/data/item-data.service';
|
import { ItemDataService } from '../../../../core/data/item-data.service';
|
||||||
|
|
||||||
import { Item } from '../../../../core/shared/item.model';
|
import { Item } from '../../../../core/shared/item.model';
|
||||||
import { WorkspaceItem } from '../../../../core/submission/models/workspaceitem.model';
|
import { WorkspaceItem } from '../../../../core/submission/models/workspaceitem.model';
|
||||||
|
import { getMockLinkService } from '../../../mocks/mock-link-service';
|
||||||
import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type';
|
import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type';
|
||||||
import { WorkflowItemSearchResult } from '../../../object-collection/shared/workflow-item-search-result.model';
|
import { WorkflowItemSearchResult } from '../../../object-collection/shared/workflow-item-search-result.model';
|
||||||
import { createSuccessfulRemoteDataObject } from '../../../testing/utils';
|
import { createSuccessfulRemoteDataObject } from '../../../testing/utils';
|
||||||
@@ -57,7 +59,7 @@ let linkService;
|
|||||||
|
|
||||||
describe('WorkspaceItemSearchResultListElementComponent', () => {
|
describe('WorkspaceItemSearchResultListElementComponent', () => {
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
linkService = getMockLinkService;
|
linkService = getMockLinkService();
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [NoopAnimationsModule],
|
imports: [NoopAnimationsModule],
|
||||||
declarations: [WorkspaceItemSearchResultListElementComponent],
|
declarations: [WorkspaceItemSearchResultListElementComponent],
|
||||||
@@ -82,9 +84,12 @@ describe('WorkspaceItemSearchResultListElementComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should init item properly', () => {
|
it('should init item properly', (done) => {
|
||||||
expect(linkService.resolveLink).toHaveBeenCalled();
|
component.item$.pipe(take(1)).subscribe((i) => {
|
||||||
expect(component.item$).toEqual(observableOf(item));
|
expect(linkService.resolveLink).toHaveBeenCalled();
|
||||||
|
expect(i).toBe(item);
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have properly status', () => {
|
it('should have properly status', () => {
|
||||||
|
Reference in New Issue
Block a user