mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +00:00
started fixing tests
This commit is contained in:
@@ -14,16 +14,20 @@ import { createSuccessfulRemoteDataObject$ } from '../../../../../shared/testing
|
||||
import { TruncatableService } from '../../../../../shared/truncatable/truncatable.service';
|
||||
import { CollectionElementLinkType } from '../../../../../shared/object-collection/collection-element-link.type';
|
||||
import { ViewMode } from '../../../../../core/shared/view-mode.model';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model';
|
||||
import { TaskAdminWorkflowSearchResultGridElementComponent } from './task-admin-workflow-search-result-grid-element.component';
|
||||
import { TaskObject } from '../../../../../core/tasks/models/task-object.model';
|
||||
import { SearchResult } from '../../../../../shared/search/search-result.model';
|
||||
import { LinkService } from '../../../../../core/cache/builders/link.service';
|
||||
import { getMockLinkService } from '../../../../../shared/mocks/mock-link-service';
|
||||
import { WorkflowItem } from '../../../../../core/submission/models/workflowitem.model';
|
||||
|
||||
describe('ItemAdminSearchResultGridElementComponent', () => {
|
||||
describe('TaskAdminWorkflowSearchResultGridElementComponent', () => {
|
||||
let component: TaskAdminWorkflowSearchResultGridElementComponent;
|
||||
let fixture: ComponentFixture<TaskAdminWorkflowSearchResultGridElementComponent>;
|
||||
let id;
|
||||
let searchResult;
|
||||
let linkService;
|
||||
|
||||
const mockBitstreamDataService = {
|
||||
getThumbnailFor(item: Item): Observable<RemoteData<Bitstream>> {
|
||||
@@ -33,9 +37,11 @@ describe('ItemAdminSearchResultGridElementComponent', () => {
|
||||
|
||||
function init() {
|
||||
id = '780b2588-bda5-4112-a1cd-0b15000a5339';
|
||||
searchResult = new ItemSearchResult();
|
||||
searchResult.indexableObject = new Item();
|
||||
searchResult = new SearchResult<TaskObject>();
|
||||
searchResult.indexableObject = new TaskObject();
|
||||
searchResult.indexableObject.workflowitem = createSuccessfulRemoteDataObject$(new WorkflowItem());
|
||||
searchResult.indexableObject.uuid = id;
|
||||
linkService = getMockLinkService();
|
||||
}
|
||||
|
||||
beforeEach(async(() => {
|
||||
@@ -52,6 +58,7 @@ describe('ItemAdminSearchResultGridElementComponent', () => {
|
||||
providers: [
|
||||
{ provide: TruncatableService, useValue: mockTruncatableService },
|
||||
{ provide: BitstreamDataService, useValue: mockBitstreamDataService },
|
||||
{ provide: LinkService, useValue: linkService },
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
})
|
||||
@@ -59,6 +66,7 @@ describe('ItemAdminSearchResultGridElementComponent', () => {
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
linkService.resolveLink.and.callFake((a) => a);
|
||||
fixture = TestBed.createComponent(TaskAdminWorkflowSearchResultGridElementComponent);
|
||||
component = fixture.componentInstance;
|
||||
component.object = searchResult;
|
||||
@@ -71,51 +79,4 @@ describe('ItemAdminSearchResultGridElementComponent', () => {
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
|
||||
describe('when the item is not withdrawn', () => {
|
||||
beforeEach(() => {
|
||||
component.dso.isWithdrawn = false;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should not show the withdrawn badge', () => {
|
||||
const badge = fixture.debugElement.query(By.css('div.withdrawn-badge'));
|
||||
expect(badge).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the item is withdrawn', () => {
|
||||
beforeEach(() => {
|
||||
component.dso.isWithdrawn = true;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should show the withdrawn badge', () => {
|
||||
const badge = fixture.debugElement.query(By.css('div.withdrawn-badge'));
|
||||
expect(badge).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the item is not private', () => {
|
||||
beforeEach(() => {
|
||||
component.dso.isDiscoverable = true;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
it('should not show the private badge', () => {
|
||||
const badge = fixture.debugElement.query(By.css('div.private-badge'));
|
||||
expect(badge).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the item is private', () => {
|
||||
beforeEach(() => {
|
||||
component.dso.isDiscoverable = false;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should show the private badge', () => {
|
||||
const badge = fixture.debugElement.query(By.css('div.private-badge'));
|
||||
expect(badge).not.toBeNull();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
@@ -3,39 +3,28 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { BitstreamDataService } from '../../../../../core/data/bitstream-data.service';
|
||||
import { RemoteData } from '../../../../../core/data/remote-data';
|
||||
import { Bitstream } from '../../../../../core/shared/bitstream.model';
|
||||
import { Item } from '../../../../../core/shared/item.model';
|
||||
import { mockTruncatableService } from '../../../../../shared/mocks/mock-trucatable.service';
|
||||
import { SharedModule } from '../../../../../shared/shared.module';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../../../../shared/testing/utils';
|
||||
import { TruncatableService } from '../../../../../shared/truncatable/truncatable.service';
|
||||
import { CollectionElementLinkType } from '../../../../../shared/object-collection/collection-element-link.type';
|
||||
import { ViewMode } from '../../../../../core/shared/view-mode.model';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model';
|
||||
import { WorkflowItemAdminWorkflowGridElementComponent } from './workflow-item-admin-workflow-grid-element.component';
|
||||
import { WorkflowItem } from '../../../../../core/submission/models/workflowitem.model';
|
||||
import { LinkService } from '../../../../../core/cache/builders/link.service';
|
||||
import { getMockLinkService } from '../../../../../shared/mocks/mock-link-service';
|
||||
|
||||
describe('ItemAdminSearchResultGridElementComponent', () => {
|
||||
describe('WorkflowItemAdminWorkflowGridElementComponent', () => {
|
||||
let component: WorkflowItemAdminWorkflowGridElementComponent;
|
||||
let fixture: ComponentFixture<WorkflowItemAdminWorkflowGridElementComponent>;
|
||||
let id;
|
||||
let searchResult;
|
||||
|
||||
const mockBitstreamDataService = {
|
||||
getThumbnailFor(item: Item): Observable<RemoteData<Bitstream>> {
|
||||
return createSuccessfulRemoteDataObject$(new Bitstream());
|
||||
}
|
||||
};
|
||||
let wfi;
|
||||
let linkService;
|
||||
|
||||
function init() {
|
||||
id = '780b2588-bda5-4112-a1cd-0b15000a5339';
|
||||
searchResult = new ItemSearchResult();
|
||||
searchResult.indexableObject = new Item();
|
||||
searchResult.indexableObject.uuid = id;
|
||||
wfi = new WorkflowItem();
|
||||
linkService = getMockLinkService();
|
||||
}
|
||||
|
||||
beforeEach(async(() => {
|
||||
@@ -50,8 +39,7 @@ describe('ItemAdminSearchResultGridElementComponent', () => {
|
||||
SharedModule
|
||||
],
|
||||
providers: [
|
||||
{ provide: TruncatableService, useValue: mockTruncatableService },
|
||||
{ provide: BitstreamDataService, useValue: mockBitstreamDataService },
|
||||
{ provide: LinkService, useValue: linkService },
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
})
|
||||
@@ -59,9 +47,10 @@ describe('ItemAdminSearchResultGridElementComponent', () => {
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
linkService.resolveLink.and.callFake((a) => a);
|
||||
fixture = TestBed.createComponent(WorkflowItemAdminWorkflowGridElementComponent);
|
||||
component = fixture.componentInstance;
|
||||
component.object = searchResult;
|
||||
component.object = wfi;
|
||||
component.linkTypes = CollectionElementLinkType;
|
||||
component.index = 0;
|
||||
component.viewModes = ViewMode;
|
||||
@@ -71,51 +60,4 @@ describe('ItemAdminSearchResultGridElementComponent', () => {
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
|
||||
describe('when the item is not withdrawn', () => {
|
||||
beforeEach(() => {
|
||||
component.dso.isWithdrawn = false;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should not show the withdrawn badge', () => {
|
||||
const badge = fixture.debugElement.query(By.css('div.withdrawn-badge'));
|
||||
expect(badge).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the item is withdrawn', () => {
|
||||
beforeEach(() => {
|
||||
component.dso.isWithdrawn = true;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should show the withdrawn badge', () => {
|
||||
const badge = fixture.debugElement.query(By.css('div.withdrawn-badge'));
|
||||
expect(badge).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the item is not private', () => {
|
||||
beforeEach(() => {
|
||||
component.dso.isDiscoverable = true;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
it('should not show the private badge', () => {
|
||||
const badge = fixture.debugElement.query(By.css('div.private-badge'));
|
||||
expect(badge).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the item is private', () => {
|
||||
beforeEach(() => {
|
||||
component.dso.isDiscoverable = false;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should show the private badge', () => {
|
||||
const badge = fixture.debugElement.query(By.css('div.private-badge'));
|
||||
expect(badge).not.toBeNull();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
@@ -2,26 +2,32 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../../../../shared/testing/utils';
|
||||
import { TruncatableService } from '../../../../../shared/truncatable/truncatable.service';
|
||||
import { CollectionElementLinkType } from '../../../../../shared/object-collection/collection-element-link.type';
|
||||
import { ViewMode } from '../../../../../core/shared/view-mode.model';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model';
|
||||
import { TaskAdminWorkflowSearchResultListElementComponent } from './task-admin-workflow-search-result-list-element.component';
|
||||
import { Item } from '../../../../../core/shared/item.model';
|
||||
import { SearchResult } from '../../../../../shared/search/search-result.model';
|
||||
import { LinkService } from '../../../../../core/cache/builders/link.service';
|
||||
import { getMockLinkService } from '../../../../../shared/mocks/mock-link-service';
|
||||
import { WorkflowItem } from '../../../../../core/submission/models/workflowitem.model';
|
||||
import { TaskObject } from '../../../../../core/tasks/models/task-object.model';
|
||||
|
||||
describe('ItemAdminSearchResultListElementComponent', () => {
|
||||
describe('TaskAdminWorkflowSearchResultListElementComponent', () => {
|
||||
let component: TaskAdminWorkflowSearchResultListElementComponent;
|
||||
let fixture: ComponentFixture<TaskAdminWorkflowSearchResultListElementComponent>;
|
||||
let id;
|
||||
let searchResult;
|
||||
let linkService;
|
||||
|
||||
function init() {
|
||||
id = '780b2588-bda5-4112-a1cd-0b15000a5339';
|
||||
searchResult = new ItemSearchResult();
|
||||
searchResult.indexableObject = new Item();
|
||||
searchResult = new SearchResult<TaskObject>();
|
||||
searchResult.indexableObject = new TaskObject();
|
||||
searchResult.indexableObject.workflowitem = createSuccessfulRemoteDataObject$(new WorkflowItem());
|
||||
searchResult.indexableObject.uuid = id;
|
||||
linkService = getMockLinkService();
|
||||
}
|
||||
|
||||
beforeEach(async(() => {
|
||||
@@ -32,13 +38,16 @@ describe('ItemAdminSearchResultListElementComponent', () => {
|
||||
RouterTestingModule.withRoutes([])
|
||||
],
|
||||
declarations: [TaskAdminWorkflowSearchResultListElementComponent],
|
||||
providers: [{ provide: TruncatableService, useValue: {} }],
|
||||
providers: [{ provide: TruncatableService, useValue: {} },
|
||||
{ provide: LinkService, useValue: linkService }
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
linkService.resolveLink.and.callFake((a) => a);
|
||||
fixture = TestBed.createComponent(TaskAdminWorkflowSearchResultListElementComponent);
|
||||
component = fixture.componentInstance;
|
||||
component.object = searchResult;
|
||||
@@ -51,51 +60,4 @@ describe('ItemAdminSearchResultListElementComponent', () => {
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
|
||||
describe('when the item is not withdrawn', () => {
|
||||
beforeEach(() => {
|
||||
component.dso.isWithdrawn = false;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should not show the withdrawn badge', () => {
|
||||
const badge = fixture.debugElement.query(By.css('div.withdrawn-badge'));
|
||||
expect(badge).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the item is withdrawn', () => {
|
||||
beforeEach(() => {
|
||||
component.dso.isWithdrawn = true;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should show the withdrawn badge', () => {
|
||||
const badge = fixture.debugElement.query(By.css('div.withdrawn-badge'));
|
||||
expect(badge).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the item is not private', () => {
|
||||
beforeEach(() => {
|
||||
component.dso.isDiscoverable = true;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
it('should not show the private badge', () => {
|
||||
const badge = fixture.debugElement.query(By.css('div.private-badge'));
|
||||
expect(badge).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the item is private', () => {
|
||||
beforeEach(() => {
|
||||
component.dso.isDiscoverable = false;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should show the private badge', () => {
|
||||
const badge = fixture.debugElement.query(By.css('div.private-badge'));
|
||||
expect(badge).not.toBeNull();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
@@ -1,47 +1,56 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { mockTruncatableService } from '../../../../../shared/mocks/mock-trucatable.service';
|
||||
import { SharedModule } from '../../../../../shared/shared.module';
|
||||
import { TruncatableService } from '../../../../../shared/truncatable/truncatable.service';
|
||||
import { CollectionElementLinkType } from '../../../../../shared/object-collection/collection-element-link.type';
|
||||
import { ViewMode } from '../../../../../core/shared/view-mode.model';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model';
|
||||
import { WorkflowItem } from '../../../../../core/submission/models/workflowitem.model';
|
||||
import { WorkflowItemAdminWorkflowListElementComponent } from './workflow-item-admin-workflow-list-element.component';
|
||||
import { Item } from '../../../../../core/shared/item.model';
|
||||
import { LinkService } from '../../../../../core/cache/builders/link.service';
|
||||
import { getMockLinkService } from '../../../../../shared/mocks/mock-link-service';
|
||||
|
||||
describe('ItemAdminSearchResultListElementComponent', () => {
|
||||
describe('WorkflowItemAdminWorkflowListElementComponent', () => {
|
||||
let component: WorkflowItemAdminWorkflowListElementComponent;
|
||||
let fixture: ComponentFixture<WorkflowItemAdminWorkflowListElementComponent>;
|
||||
let id;
|
||||
let searchResult;
|
||||
|
||||
let wfi;
|
||||
let linkService;
|
||||
function init() {
|
||||
id = '780b2588-bda5-4112-a1cd-0b15000a5339';
|
||||
searchResult = new ItemSearchResult();
|
||||
searchResult.indexableObject = new Item();
|
||||
searchResult.indexableObject.uuid = id;
|
||||
wfi = new WorkflowItem();
|
||||
linkService = getMockLinkService();
|
||||
}
|
||||
|
||||
beforeEach(async(() => {
|
||||
init();
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
TranslateModule.forRoot(),
|
||||
RouterTestingModule.withRoutes([])
|
||||
],
|
||||
TestBed.configureTestingModule(
|
||||
{
|
||||
declarations: [WorkflowItemAdminWorkflowListElementComponent],
|
||||
providers: [{ provide: TruncatableService, useValue: {} }],
|
||||
imports: [
|
||||
NoopAnimationsModule,
|
||||
TranslateModule.forRoot(),
|
||||
RouterTestingModule.withRoutes([]),
|
||||
SharedModule
|
||||
],
|
||||
providers: [
|
||||
{ provide: TruncatableService, useValue: mockTruncatableService },
|
||||
{ provide: LinkService, useValue: linkService },
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
linkService.resolveLink.and.callFake((a) => a);
|
||||
fixture = TestBed.createComponent(WorkflowItemAdminWorkflowListElementComponent);
|
||||
component = fixture.componentInstance;
|
||||
component.object = searchResult;
|
||||
component.object = wfi;
|
||||
component.linkTypes = CollectionElementLinkType;
|
||||
component.index = 0;
|
||||
component.viewModes = ViewMode;
|
||||
@@ -51,51 +60,4 @@ describe('ItemAdminSearchResultListElementComponent', () => {
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
|
||||
describe('when the item is not withdrawn', () => {
|
||||
beforeEach(() => {
|
||||
component.dso.isWithdrawn = false;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should not show the withdrawn badge', () => {
|
||||
const badge = fixture.debugElement.query(By.css('div.withdrawn-badge'));
|
||||
expect(badge).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the item is withdrawn', () => {
|
||||
beforeEach(() => {
|
||||
component.dso.isWithdrawn = true;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should show the withdrawn badge', () => {
|
||||
const badge = fixture.debugElement.query(By.css('div.withdrawn-badge'));
|
||||
expect(badge).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the item is not private', () => {
|
||||
beforeEach(() => {
|
||||
component.dso.isDiscoverable = true;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
it('should not show the private badge', () => {
|
||||
const badge = fixture.debugElement.query(By.css('div.private-badge'));
|
||||
expect(badge).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the item is private', () => {
|
||||
beforeEach(() => {
|
||||
component.dso.isDiscoverable = false;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should show the private badge', () => {
|
||||
const badge = fixture.debugElement.query(By.css('div.private-badge'));
|
||||
expect(badge).not.toBeNull();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
@@ -4,7 +4,6 @@ import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { ItemAdminWorkflowSearchResultActionsComponent } from './workflow-item-admin-workflow-actions.component';
|
||||
import { Item } from '../../../core/shared/item.model';
|
||||
import {
|
||||
ITEM_EDIT_DELETE_PATH,
|
||||
@@ -16,17 +15,20 @@ import {
|
||||
} from '../../../+item-page/edit-item-page/edit-item-page.routing.module';
|
||||
import { getItemEditPath } from '../../../+item-page/item-page-routing.module';
|
||||
import { URLCombiner } from '../../../core/url-combiner/url-combiner';
|
||||
import { WorkflowItemAdminWorkflowActionsComponent } from './workflow-item-admin-workflow-actions.component';
|
||||
import { WorkflowItem } from '../../../core/submission/models/workflowitem.model';
|
||||
import { getWorkflowItemDeletePath, getWorkflowItemSendBackPath } from '../../../+workflowitems-edit-page/workflowitems-edit-page-routing.module';
|
||||
|
||||
describe('ItemAdminSearchResultActionsComponent', () => {
|
||||
let component: ItemAdminWorkflowSearchResultActionsComponent;
|
||||
let fixture: ComponentFixture<ItemAdminWorkflowSearchResultActionsComponent>;
|
||||
describe('WorkflowItemAdminWorkflowActionsComponent', () => {
|
||||
let component: WorkflowItemAdminWorkflowActionsComponent;
|
||||
let fixture: ComponentFixture<WorkflowItemAdminWorkflowActionsComponent>;
|
||||
let id;
|
||||
let item;
|
||||
let wfi;
|
||||
|
||||
function init() {
|
||||
id = '780b2588-bda5-4112-a1cd-0b15000a5339';
|
||||
item = new Item();
|
||||
item.uuid = id;
|
||||
wfi = new WorkflowItem();
|
||||
wfi.id = id;
|
||||
}
|
||||
beforeEach(async(() => {
|
||||
init();
|
||||
@@ -35,16 +37,16 @@ describe('ItemAdminSearchResultActionsComponent', () => {
|
||||
TranslateModule.forRoot(),
|
||||
RouterTestingModule.withRoutes([])
|
||||
],
|
||||
declarations: [ItemAdminWorkflowSearchResultActionsComponent],
|
||||
declarations: [WorkflowItemAdminWorkflowActionsComponent],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ItemAdminWorkflowSearchResultActionsComponent);
|
||||
fixture = TestBed.createComponent(WorkflowItemAdminWorkflowActionsComponent);
|
||||
component = fixture.componentInstance;
|
||||
component.item = item;
|
||||
component.wfi = wfi;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
@@ -52,93 +54,15 @@ describe('ItemAdminSearchResultActionsComponent', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should render an edit button with the correct link', () => {
|
||||
const button = fixture.debugElement.query(By.css('a.edit-link'));
|
||||
const link = button.nativeElement.href;
|
||||
expect(link).toContain(getItemEditPath(id));
|
||||
});
|
||||
|
||||
it('should render a delete button with the correct link', () => {
|
||||
const button = fixture.debugElement.query(By.css('a.delete-link'));
|
||||
const link = button.nativeElement.href;
|
||||
expect(link).toContain(new URLCombiner(getItemEditPath(id), ITEM_EDIT_DELETE_PATH).toString());
|
||||
expect(link).toContain(new URLCombiner(getWorkflowItemDeletePath(wfi.id)).toString());
|
||||
});
|
||||
|
||||
it('should render a move button with the correct link', () => {
|
||||
const a = fixture.debugElement.query(By.css('a.move-link'));
|
||||
const a = fixture.debugElement.query(By.css('a.send-back-link'));
|
||||
const link = a.nativeElement.href;
|
||||
expect(link).toContain(new URLCombiner(getItemEditPath(id), ITEM_EDIT_MOVE_PATH).toString());
|
||||
expect(link).toContain(new URLCombiner(getWorkflowItemSendBackPath(wfi.id)).toString());
|
||||
});
|
||||
|
||||
describe('when the item is not withdrawn', () => {
|
||||
beforeEach(() => {
|
||||
component.item.isWithdrawn = false;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should render a withdraw button with the correct link', () => {
|
||||
const a = fixture.debugElement.query(By.css('a.withdraw-link'));
|
||||
const link = a.nativeElement.href;
|
||||
expect(link).toContain(new URLCombiner(getItemEditPath(id), ITEM_EDIT_WITHDRAW_PATH).toString());
|
||||
});
|
||||
|
||||
it('should not render a reinstate button with the correct link', () => {
|
||||
const a = fixture.debugElement.query(By.css('a.reinstate-link'));
|
||||
expect(a).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the item is withdrawn', () => {
|
||||
beforeEach(() => {
|
||||
component.item.isWithdrawn = true;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should not render a withdraw button with the correct link', () => {
|
||||
const a = fixture.debugElement.query(By.css('a.withdraw-link'));
|
||||
expect(a).toBeNull();
|
||||
});
|
||||
|
||||
it('should render a reinstate button with the correct link', () => {
|
||||
const a = fixture.debugElement.query(By.css('a.reinstate-link'));
|
||||
const link = a.nativeElement.href;
|
||||
expect(link).toContain(new URLCombiner(getItemEditPath(id), ITEM_EDIT_REINSTATE_PATH).toString());
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the item is not private', () => {
|
||||
beforeEach(() => {
|
||||
component.item.isDiscoverable = true;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should render a make private button with the correct link', () => {
|
||||
const a = fixture.debugElement.query(By.css('a.private-link'));
|
||||
const link = a.nativeElement.href;
|
||||
expect(link).toContain(new URLCombiner(getItemEditPath(id), ITEM_EDIT_PRIVATE_PATH).toString());
|
||||
});
|
||||
|
||||
it('should not render a make public button with the correct link', () => {
|
||||
const a = fixture.debugElement.query(By.css('a.public-link'));
|
||||
expect(a).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the item is private', () => {
|
||||
beforeEach(() => {
|
||||
component.item.isDiscoverable = false;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should not render a make private button with the correct link', () => {
|
||||
const a = fixture.debugElement.query(By.css('a.private-link'));
|
||||
expect(a).toBeNull();
|
||||
});
|
||||
|
||||
it('should render a make private button with the correct link', () => {
|
||||
const a = fixture.debugElement.query(By.css('a.public-link'));
|
||||
const link = a.nativeElement.href;
|
||||
expect(link).toContain(new URLCombiner(getItemEditPath(id), ITEM_EDIT_PUBLIC_PATH).toString());
|
||||
});
|
||||
})
|
||||
});
|
||||
|
@@ -1,20 +1,20 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { WorkflowItemSendBackComponent } from './workflow-item-send-back.component';
|
||||
|
||||
import { WorkflowItemDeleteComponent } from './workflow-item-send-back.component';
|
||||
|
||||
describe('WorkflowItemDeleteComponent', () => {
|
||||
let component: WorkflowItemDeleteComponent;
|
||||
let fixture: ComponentFixture<WorkflowItemDeleteComponent>;
|
||||
describe('WorkflowItemSendBackComponent', () => {
|
||||
let component: WorkflowItemSendBackComponent;
|
||||
let fixture: ComponentFixture<WorkflowItemSendBackComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ WorkflowItemDeleteComponent ]
|
||||
declarations: [ WorkflowItemSendBackComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(WorkflowItemDeleteComponent);
|
||||
fixture = TestBed.createComponent(WorkflowItemSendBackComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
Reference in New Issue
Block a user