mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +00:00
finished tests
This commit is contained in:
@@ -1,16 +1,59 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { WorkflowItemSendBackComponent } from './workflow-item-send-back.component';
|
||||
|
||||
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
|
||||
import { MockTranslateLoader } from '../../shared/mocks/mock-translate-loader';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { RouterStub } from '../../shared/testing/router-stub';
|
||||
import { ActivatedRouteStub } from '../../shared/testing/active-router-stub';
|
||||
import { RouteService } from '../../core/services/route.service';
|
||||
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
||||
import { WorkflowItemDataService } from '../../core/submission/workflowitem-data.service';
|
||||
import { NotificationsServiceStub } from '../../shared/testing/notifications-service-stub';
|
||||
import { createSuccessfulRemoteDataObject, createSuccessfulRemoteDataObject$ } from '../../shared/testing/utils';
|
||||
import { WorkflowItem } from '../../core/submission/models/workflowitem.model';
|
||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { VarDirective } from '../../shared/utils/var.directive';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { WorkflowItemSendBackComponent } from './workflow-item-send-back.component';
|
||||
|
||||
describe('WorkflowItemSendBackComponent', () => {
|
||||
let component: WorkflowItemSendBackComponent;
|
||||
let fixture: ComponentFixture<WorkflowItemSendBackComponent>;
|
||||
let wfiService;
|
||||
let wfi;
|
||||
let itemRD$;
|
||||
let id;
|
||||
|
||||
function init() {
|
||||
wfiService = jasmine.createSpyObj('workflowItemService', {
|
||||
sendBack: observableOf(true)
|
||||
});
|
||||
itemRD$ = createSuccessfulRemoteDataObject$(itemRD$);
|
||||
wfi = new WorkflowItem();
|
||||
wfi.item = itemRD$;
|
||||
id = 'de11b5e5-064a-4e98-a7ac-a1a6a65ddf80';
|
||||
}
|
||||
|
||||
beforeEach(async(() => {
|
||||
init();
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ WorkflowItemSendBackComponent ]
|
||||
imports: [TranslateModule.forRoot({
|
||||
loader: {
|
||||
provide: TranslateLoader,
|
||||
useClass: MockTranslateLoader
|
||||
}
|
||||
})],
|
||||
declarations: [WorkflowItemSendBackComponent, VarDirective],
|
||||
providers: [
|
||||
{ provide: ActivatedRoute, useValue: new ActivatedRouteStub({}, { wfi: createSuccessfulRemoteDataObject(wfi) }) },
|
||||
{ provide: Router, useClass: RouterStub },
|
||||
{ provide: RouteService, useValue: {} },
|
||||
{ provide: NotificationsService, useClass: NotificationsServiceStub },
|
||||
{ provide: WorkflowItemDataService, useValue: wfiService },
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
})
|
||||
.compileComponents();
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -22,4 +65,9 @@ describe('WorkflowItemSendBackComponent', () => {
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should call sendBack on the workflow-item service when sendRequest is called', () => {
|
||||
component.sendRequest(id);
|
||||
expect(wfiService.sendBack).toHaveBeenCalledWith(id);
|
||||
});
|
||||
});
|
||||
|
@@ -11,6 +11,9 @@ import { TranslateService } from '@ngx-translate/core';
|
||||
selector: 'ds-workflow-item-send-back',
|
||||
templateUrl: '../workflow-item-action-page.component.html'
|
||||
})
|
||||
/**
|
||||
* Component representing a page to send back a workflow item to the submitter
|
||||
*/
|
||||
export class WorkflowItemSendBackComponent extends WorkflowItemActionPageComponent {
|
||||
constructor(protected route: ActivatedRoute,
|
||||
protected workflowItemService: WorkflowItemDataService,
|
||||
@@ -21,10 +24,17 @@ export class WorkflowItemSendBackComponent extends WorkflowItemActionPageCompone
|
||||
super(route, workflowItemService, router, routeService, notificationsService, translationService);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of page
|
||||
*/
|
||||
getType(): string {
|
||||
return 'send-back';
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs the action of this workflow item action page
|
||||
* @param id The id of the WorkflowItem
|
||||
*/
|
||||
sendRequest(id: string): Observable<boolean> {
|
||||
return this.workflowItemService.sendBack(id);
|
||||
}
|
||||
|
Reference in New Issue
Block a user