Virtual metadata on item delete - filter relationship types without relationships - fix tests

This commit is contained in:
Samuel
2020-01-29 12:27:41 +01:00
parent b352690cca
commit 0387c5f15b

View File

@@ -1,4 +1,6 @@
import {async, ComponentFixture, TestBed} from '@angular/core/testing'; import {async, ComponentFixture, TestBed} from '@angular/core/testing';
import { ItemType } from '../../../core/shared/item-relationships/item-type.model';
import { Relationship } from '../../../core/shared/item-relationships/relationship.model';
import {Item} from '../../../core/shared/item.model'; import {Item} from '../../../core/shared/item.model';
import {RouterStub} from '../../../shared/testing/router-stub'; import {RouterStub} from '../../../shared/testing/router-stub';
import {of as observableOf} from 'rxjs'; import {of as observableOf} from 'rxjs';
@@ -29,9 +31,11 @@ let comp: ItemDeleteComponent;
let fixture: ComponentFixture<ItemDeleteComponent>; let fixture: ComponentFixture<ItemDeleteComponent>;
let mockItem; let mockItem;
let itemType;
let type1; let type1;
let type2; let type2;
let types; let types;
let relationships;
let itemPageUrl; let itemPageUrl;
let routerStub; let routerStub;
let mockItemDataService: ItemDataService; let mockItemDataService: ItemDataService;
@@ -53,6 +57,11 @@ describe('ItemDeleteComponent', () => {
isWithdrawn: true isWithdrawn: true
}); });
itemType = Object.assign(new ItemType(), {
id: 'itemType',
uuid: 'itemType',
});
type1 = Object.assign(new RelationshipType(), { type1 = Object.assign(new RelationshipType(), {
id: '1', id: '1',
uuid: 'type-1', uuid: 'type-1',
@@ -65,6 +74,59 @@ describe('ItemDeleteComponent', () => {
types = [type1, type2]; types = [type1, type2];
relationships = [
Object.assign(new Relationship(), {
id: '1',
uuid: 'relationship-1',
relationshipType: observableOf(new RemoteData(
false,
false,
true,
null,
type1
)),
leftItem: observableOf(new RemoteData(
false,
false,
true,
null,
mockItem,
)),
rightItem: observableOf(new RemoteData(
false,
false,
true,
null,
Object.assign(new Item(), {})
)),
}),
Object.assign(new Relationship(), {
id: '2',
uuid: 'relationship-2',
relationshipType: observableOf(new RemoteData(
false,
false,
true,
null,
type2
)),
leftItem: observableOf(new RemoteData(
false,
false,
true,
null,
mockItem,
)),
rightItem: observableOf(new RemoteData(
false,
false,
true,
null,
Object.assign(new Item(), {})
)),
}),
];
itemPageUrl = `fake-url/${mockItem.id}`; itemPageUrl = `fake-url/${mockItem.id}`;
routerStub = Object.assign(new RouterStub(), { routerStub = Object.assign(new RouterStub(), {
url: `${itemPageUrl}/edit` url: `${itemPageUrl}/edit`
@@ -92,14 +154,14 @@ describe('ItemDeleteComponent', () => {
false, false,
true, true,
null, null,
{}, itemType,
)), )),
getEntityTypeRelationships: observableOf(new RemoteData( getEntityTypeRelationships: observableOf(new RemoteData(
false, false,
false, false,
true, true,
null, null,
new PaginatedList(new PageInfo(), [{}]), new PaginatedList(new PageInfo(), types),
)), )),
} }
); );
@@ -113,8 +175,7 @@ describe('ItemDeleteComponent', () => {
relationshipService = jasmine.createSpyObj('relationshipService', relationshipService = jasmine.createSpyObj('relationshipService',
{ {
getItemRelationshipTypesArray: observableOf([type1, type2, type2]), getItemRelationshipsArray: observableOf(relationships),
getItemRelationshipsArray: observableOf([]),
} }
); );