item-relationships.component.spec.ts (dspace-angular-dspace-7.0) | : | item-relationships.component.spec.ts (dspace-angular-dspace-7.1) | ||
---|---|---|---|---|
skipping to change at line 28 | skipping to change at line 28 | |||
import { Relationship } from '../../../core/shared/item-relationships/relationsh ip.model'; | import { Relationship } from '../../../core/shared/item-relationships/relationsh ip.model'; | |||
import { Item } from '../../../core/shared/item.model'; | import { Item } from '../../../core/shared/item.model'; | |||
import { NotificationType } from '../../../shared/notifications/models/notificat ion-type'; | import { NotificationType } from '../../../shared/notifications/models/notificat ion-type'; | |||
import { INotification, Notification } from '../../../shared/notifications/model s/notification.model'; | import { INotification, Notification } from '../../../shared/notifications/model s/notification.model'; | |||
import { NotificationsService } from '../../../shared/notifications/notification s.service'; | import { NotificationsService } from '../../../shared/notifications/notification s.service'; | |||
import { SharedModule } from '../../../shared/shared.module'; | import { SharedModule } from '../../../shared/shared.module'; | |||
import { RouterStub } from '../../../shared/testing/router.stub'; | import { RouterStub } from '../../../shared/testing/router.stub'; | |||
import { ItemRelationshipsComponent } from './item-relationships.component'; | import { ItemRelationshipsComponent } from './item-relationships.component'; | |||
import { createSuccessfulRemoteDataObject, createSuccessfulRemoteDataObject$ } f rom '../../../shared/remote-data.utils'; | import { createSuccessfulRemoteDataObject, createSuccessfulRemoteDataObject$ } f rom '../../../shared/remote-data.utils'; | |||
import { createPaginatedList } from '../../../shared/testing/utils.test'; | import { createPaginatedList } from '../../../shared/testing/utils.test'; | |||
import { RelationshipTypeService } from '../../../core/data/relationship-type.se | ||||
rvice'; | ||||
import { relationshipTypes } from '../../../shared/testing/relationship-types.mo | ||||
ck'; | ||||
let comp: any; | let comp: any; | |||
let fixture: ComponentFixture<ItemRelationshipsComponent>; | let fixture: ComponentFixture<ItemRelationshipsComponent>; | |||
let de: DebugElement; | let de: DebugElement; | |||
let el: HTMLElement; | let el: HTMLElement; | |||
let objectUpdatesService; | let objectUpdatesService; | |||
let relationshipService; | let relationshipService; | |||
let requestService; | let requestService; | |||
let entityTypeService; | let entityTypeService; | |||
let objectCache; | let objectCache; | |||
skipping to change at line 49 | skipping to change at line 51 | |||
const warningNotification: INotification = new Notification('id', NotificationTy pe.Warning, 'warning'); | const warningNotification: INotification = new Notification('id', NotificationTy pe.Warning, 'warning'); | |||
const successNotification: INotification = new Notification('id', NotificationTy pe.Success, 'success'); | const successNotification: INotification = new Notification('id', NotificationTy pe.Success, 'success'); | |||
const notificationsService = jasmine.createSpyObj('notificationsService', | const notificationsService = jasmine.createSpyObj('notificationsService', | |||
{ | { | |||
info: infoNotification, | info: infoNotification, | |||
warning: warningNotification, | warning: warningNotification, | |||
success: successNotification | success: successNotification | |||
} | } | |||
); | ); | |||
const router = new RouterStub(); | const router = new RouterStub(); | |||
let relationshipTypeService; | ||||
let routeStub; | let routeStub; | |||
let itemService; | let itemService; | |||
const url = 'http://test-url.com/test-url'; | const url = 'http://test-url.com/test-url'; | |||
router.url = url; | router.url = url; | |||
let scheduler: TestScheduler; | let scheduler: TestScheduler; | |||
let item; | let item; | |||
let author1; | let author1; | |||
let author2; | let author2; | |||
skipping to change at line 181 | skipping to change at line 184 | |||
getRelatedItems: observableOf([author1, author2]), | getRelatedItems: observableOf([author1, author2]), | |||
getRelatedItemsByLabel: observableOf([author1, author2]), | getRelatedItemsByLabel: observableOf([author1, author2]), | |||
getItemRelationshipsArray: observableOf(relationships), | getItemRelationshipsArray: observableOf(relationships), | |||
deleteRelationship: observableOf(new RestResponse(true, 200, 'OK')), | deleteRelationship: observableOf(new RestResponse(true, 200, 'OK')), | |||
getItemResolvedRelatedItemsAndRelationships: observableCombineLatest(obs ervableOf([author1, author2]), observableOf([item, item]), observableOf(relation ships)), | getItemResolvedRelatedItemsAndRelationships: observableCombineLatest(obs ervableOf([author1, author2]), observableOf([item, item]), observableOf(relation ships)), | |||
getRelationshipsByRelatedItemIds: observableOf(relationships), | getRelationshipsByRelatedItemIds: observableOf(relationships), | |||
getRelationshipTypeLabelsByItem: observableOf([relationshipType.leftward Type]) | getRelationshipTypeLabelsByItem: observableOf([relationshipType.leftward Type]) | |||
} | } | |||
); | ); | |||
relationshipTypeService = jasmine.createSpyObj('searchByEntityType', | ||||
{ | ||||
searchByEntityType: observableOf(relationshipTypes) | ||||
} | ||||
); | ||||
requestService = jasmine.createSpyObj('requestService', | requestService = jasmine.createSpyObj('requestService', | |||
{ | { | |||
removeByHrefSubstring: {}, | removeByHrefSubstring: {}, | |||
hasByHref$: observableOf(false) | hasByHref$: observableOf(false) | |||
} | } | |||
); | ); | |||
objectCache = jasmine.createSpyObj('objectCache', { | objectCache = jasmine.createSpyObj('objectCache', { | |||
remove: undefined | remove: undefined | |||
}); | }); | |||
skipping to change at line 213 | skipping to change at line 222 | |||
providers: [ | providers: [ | |||
{ provide: ItemDataService, useValue: itemService }, | { provide: ItemDataService, useValue: itemService }, | |||
{ provide: ObjectUpdatesService, useValue: objectUpdatesService }, | { provide: ObjectUpdatesService, useValue: objectUpdatesService }, | |||
{ provide: Router, useValue: router }, | { provide: Router, useValue: router }, | |||
{ provide: ActivatedRoute, useValue: routeStub }, | { provide: ActivatedRoute, useValue: routeStub }, | |||
{ provide: NotificationsService, useValue: notificationsService }, | { provide: NotificationsService, useValue: notificationsService }, | |||
{ provide: RelationshipService, useValue: relationshipService }, | { provide: RelationshipService, useValue: relationshipService }, | |||
{ provide: EntityTypeService, useValue: entityTypeService }, | { provide: EntityTypeService, useValue: entityTypeService }, | |||
{ provide: ObjectCacheService, useValue: objectCache }, | { provide: ObjectCacheService, useValue: objectCache }, | |||
{ provide: RequestService, useValue: requestService }, | { provide: RequestService, useValue: requestService }, | |||
{ provide: RelationshipTypeService, useValue: relationshipTypeService }, | ||||
ChangeDetectorRef | ChangeDetectorRef | |||
], schemas: [ | ], schemas: [ | |||
NO_ERRORS_SCHEMA | NO_ERRORS_SCHEMA | |||
] | ] | |||
}).compileComponents(); | }).compileComponents(); | |||
})); | })); | |||
beforeEach(() => { | beforeEach(() => { | |||
fixture = TestBed.createComponent(ItemRelationshipsComponent); | fixture = TestBed.createComponent(ItemRelationshipsComponent); | |||
comp = fixture.componentInstance; | comp = fixture.componentInstance; | |||
skipping to change at line 258 | skipping to change at line 268 | |||
describe('submit', () => { | describe('submit', () => { | |||
beforeEach(() => { | beforeEach(() => { | |||
comp.submit(); | comp.submit(); | |||
}); | }); | |||
it('it should delete the correct relationship', () => { | it('it should delete the correct relationship', () => { | |||
expect(relationshipService.deleteRelationship).toHaveBeenCalledWith(relati onships[1].uuid, 'left'); | expect(relationshipService.deleteRelationship).toHaveBeenCalledWith(relati onships[1].uuid, 'left'); | |||
}); | }); | |||
}); | }); | |||
describe('discard', () => { | ||||
beforeEach(() => { | ||||
comp.item.firstMetadataValue = (info) => { | ||||
return 'Publication'; | ||||
}; | ||||
fixture.detectChanges(); | ||||
comp.initializeUpdates(); | ||||
fixture.detectChanges(); | ||||
}); | ||||
it('it should call relationshipTypeService.searchByEntityType', () => { | ||||
expect(relationshipTypeService.searchByEntityType).toHaveBeenCalled(); | ||||
}); | ||||
}); | ||||
}); | }); | |||
End of changes. 5 change blocks. | ||||
0 lines changed or deleted | 28 lines changed or added |