mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +00:00
68405: test fixes
This commit is contained in:

committed by
Art Lowel

parent
ab0f2c89e6
commit
884e94a08b
@@ -1,23 +1,23 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { Item } from '../../../core/shared/item.model';
|
||||
import { RouterStub } from '../../../shared/testing/router-stub';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { ItemMoveComponent } from './item-move.component';
|
||||
import { NotificationsServiceStub } from '../../../shared/testing/notifications-service-stub';
|
||||
import { NotificationsService } from '../../../shared/notifications/notifications.service';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { ItemDataService } from '../../../core/data/item-data.service';
|
||||
import { RemoteData } from '../../../core/data/remote-data';
|
||||
import { PaginatedList } from '../../../core/data/paginated-list';
|
||||
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { RestResponse } from '../../../core/cache/response.models';
|
||||
import { ItemDataService } from '../../../core/data/item-data.service';
|
||||
import { PaginatedList } from '../../../core/data/paginated-list';
|
||||
import { RemoteData } from '../../../core/data/remote-data';
|
||||
import { Collection } from '../../../core/shared/collection.model';
|
||||
import { Item } from '../../../core/shared/item.model';
|
||||
import { SearchService } from '../../../core/shared/search/search.service';
|
||||
import { NotificationsService } from '../../../shared/notifications/notifications.service';
|
||||
import { NotificationsServiceStub } from '../../../shared/testing/notifications-service-stub';
|
||||
import { RouterStub } from '../../../shared/testing/router-stub';
|
||||
import { ItemMoveComponent } from './item-move.component';
|
||||
|
||||
describe('ItemMoveComponent', () => {
|
||||
let comp: ItemMoveComponent;
|
||||
@@ -50,16 +50,14 @@ describe('ItemMoveComponent', () => {
|
||||
})
|
||||
};
|
||||
|
||||
const collection1 = Object.assign(new Collection(),{
|
||||
const collection1 = Object.assign(new Collection(), {
|
||||
uuid: 'collection-uuid-1',
|
||||
name: 'Test collection 1',
|
||||
self: 'self-link-1',
|
||||
name: 'Test collection 1'
|
||||
});
|
||||
|
||||
const collection2 = Object.assign(new Collection(),{
|
||||
const collection2 = Object.assign(new Collection(), {
|
||||
uuid: 'collection-uuid-2',
|
||||
name: 'Test collection 2',
|
||||
self: 'self-link-2',
|
||||
name: 'Test collection 2'
|
||||
});
|
||||
|
||||
const mockSearchService = {
|
||||
@@ -80,23 +78,20 @@ describe('ItemMoveComponent', () => {
|
||||
const notificationsServiceStub = new NotificationsServiceStub();
|
||||
|
||||
describe('ItemMoveComponent success', () => {
|
||||
beforeEach(async(() => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [CommonModule, FormsModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule.forRoot()],
|
||||
declarations: [ItemMoveComponent],
|
||||
providers: [
|
||||
{provide: ActivatedRoute, useValue: routeStub},
|
||||
{provide: Router, useValue: routerStub},
|
||||
{provide: ItemDataService, useValue: mockItemDataService},
|
||||
{provide: NotificationsService, useValue: notificationsServiceStub},
|
||||
{provide: SearchService, useValue: mockSearchService},
|
||||
{ provide: ActivatedRoute, useValue: routeStub },
|
||||
{ provide: Router, useValue: routerStub },
|
||||
{ provide: ItemDataService, useValue: mockItemDataService },
|
||||
{ provide: NotificationsService, useValue: notificationsServiceStub },
|
||||
{ provide: SearchService, useValue: mockSearchService },
|
||||
], schemas: [
|
||||
CUSTOM_ELEMENTS_SCHEMA
|
||||
]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ItemMoveComponent);
|
||||
comp = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
@@ -141,23 +136,20 @@ describe('ItemMoveComponent', () => {
|
||||
});
|
||||
|
||||
describe('ItemMoveComponent fail', () => {
|
||||
beforeEach(async(() => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [CommonModule, FormsModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule.forRoot()],
|
||||
declarations: [ItemMoveComponent],
|
||||
providers: [
|
||||
{provide: ActivatedRoute, useValue: routeStub},
|
||||
{provide: Router, useValue: routerStub},
|
||||
{provide: ItemDataService, useValue: mockItemDataServiceFail},
|
||||
{provide: NotificationsService, useValue: notificationsServiceStub},
|
||||
{provide: SearchService, useValue: mockSearchService},
|
||||
{ provide: ActivatedRoute, useValue: routeStub },
|
||||
{ provide: Router, useValue: routerStub },
|
||||
{ provide: ItemDataService, useValue: mockItemDataServiceFail },
|
||||
{ provide: NotificationsService, useValue: notificationsServiceStub },
|
||||
{ provide: SearchService, useValue: mockSearchService },
|
||||
], schemas: [
|
||||
CUSTOM_ELEMENTS_SCHEMA
|
||||
]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ItemMoveComponent);
|
||||
comp = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
|
@@ -1,19 +1,19 @@
|
||||
import {EditRelationshipListComponent} from './edit-relationship-list.component';
|
||||
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
|
||||
import {RelationshipType} from '../../../../core/shared/item-relationships/relationship-type.model';
|
||||
import {Relationship} from '../../../../core/shared/item-relationships/relationship.model';
|
||||
import {of as observableOf} from 'rxjs/internal/observable/of';
|
||||
import {RemoteData} from '../../../../core/data/remote-data';
|
||||
import {Item} from '../../../../core/shared/item.model';
|
||||
import {PaginatedList} from '../../../../core/data/paginated-list';
|
||||
import {PageInfo} from '../../../../core/shared/page-info.model';
|
||||
import {FieldChangeType} from '../../../../core/data/object-updates/object-updates.actions';
|
||||
import {SharedModule} from '../../../../shared/shared.module';
|
||||
import {TranslateModule} from '@ngx-translate/core';
|
||||
import {ObjectUpdatesService} from '../../../../core/data/object-updates/object-updates.service';
|
||||
import {DebugElement, NO_ERRORS_SCHEMA} from '@angular/core';
|
||||
import {By} from '@angular/platform-browser';
|
||||
import {ItemType} from '../../../../core/shared/item-relationships/item-type.model';
|
||||
import { DebugElement, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { of as observableOf } from 'rxjs/internal/observable/of';
|
||||
import { FieldChangeType } from '../../../../core/data/object-updates/object-updates.actions';
|
||||
import { ObjectUpdatesService } from '../../../../core/data/object-updates/object-updates.service';
|
||||
import { PaginatedList } from '../../../../core/data/paginated-list';
|
||||
import { RemoteData } from '../../../../core/data/remote-data';
|
||||
import { ItemType } from '../../../../core/shared/item-relationships/item-type.model';
|
||||
import { RelationshipType } from '../../../../core/shared/item-relationships/relationship-type.model';
|
||||
import { Relationship } from '../../../../core/shared/item-relationships/relationship.model';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { PageInfo } from '../../../../core/shared/page-info.model';
|
||||
import { SharedModule } from '../../../../shared/shared.module';
|
||||
import { EditRelationshipListComponent } from './edit-relationship-list.component';
|
||||
|
||||
let comp: EditRelationshipListComponent;
|
||||
let fixture: ComponentFixture<EditRelationshipListComponent>;
|
||||
@@ -57,7 +57,11 @@ describe('EditRelationshipListComponent', () => {
|
||||
});
|
||||
|
||||
relationship1 = Object.assign(new Relationship(), {
|
||||
self: url + '/2',
|
||||
_links: {
|
||||
self: {
|
||||
href: url + '/2'
|
||||
}
|
||||
},
|
||||
id: '2',
|
||||
uuid: '2',
|
||||
leftId: 'author1',
|
||||
@@ -68,7 +72,11 @@ describe('EditRelationshipListComponent', () => {
|
||||
});
|
||||
|
||||
relationship2 = Object.assign(new Relationship(), {
|
||||
self: url + '/3',
|
||||
_links: {
|
||||
self: {
|
||||
href: url + '/3'
|
||||
}
|
||||
},
|
||||
id: '3',
|
||||
uuid: '3',
|
||||
leftId: 'author2',
|
||||
@@ -79,7 +87,9 @@ describe('EditRelationshipListComponent', () => {
|
||||
});
|
||||
|
||||
item = Object.assign(new Item(), {
|
||||
self: 'fake-item-url/publication',
|
||||
_links: {
|
||||
self: { href: 'fake-item-url/publication' }
|
||||
},
|
||||
id: 'publication',
|
||||
uuid: 'publication',
|
||||
relationships: observableOf(new RemoteData(
|
||||
|
@@ -1,16 +1,16 @@
|
||||
import { async, TestBed } from '@angular/core/testing';
|
||||
import { of as observableOf } from 'rxjs/internal/observable/of';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { ObjectUpdatesService } from '../../../../core/data/object-updates/object-updates.service';
|
||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { EditRelationshipComponent } from './edit-relationship.component';
|
||||
import { async, TestBed } from '@angular/core/testing';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { of as observableOf } from 'rxjs/internal/observable/of';
|
||||
import { FieldChangeType } from '../../../../core/data/object-updates/object-updates.actions';
|
||||
import { ObjectUpdatesService } from '../../../../core/data/object-updates/object-updates.service';
|
||||
import { PaginatedList } from '../../../../core/data/paginated-list';
|
||||
import { RemoteData } from '../../../../core/data/remote-data';
|
||||
import { RelationshipType } from '../../../../core/shared/item-relationships/relationship-type.model';
|
||||
import { Relationship } from '../../../../core/shared/item-relationships/relationship.model';
|
||||
import { RemoteData } from '../../../../core/data/remote-data';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { PaginatedList } from '../../../../core/data/paginated-list';
|
||||
import { PageInfo } from '../../../../core/shared/page-info.model';
|
||||
import { FieldChangeType } from '../../../../core/data/object-updates/object-updates.actions';
|
||||
import { EditRelationshipComponent } from './edit-relationship.component';
|
||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
|
||||
let objectUpdatesService;
|
||||
@@ -42,7 +42,11 @@ describe('EditRelationshipComponent', () => {
|
||||
});
|
||||
|
||||
item = Object.assign(new Item(), {
|
||||
self: 'fake-item-url/publication',
|
||||
_links: {
|
||||
self: {
|
||||
href: 'fake-item-url/publication'
|
||||
}
|
||||
},
|
||||
id: 'publication',
|
||||
uuid: 'publication',
|
||||
relationships: observableOf(new RemoteData(false, false, true, undefined, new PaginatedList(new PageInfo(), relationships)))
|
||||
@@ -54,7 +58,9 @@ describe('EditRelationshipComponent', () => {
|
||||
|
||||
relationships = [
|
||||
Object.assign(new Relationship(), {
|
||||
self: url + '/2',
|
||||
_links: {
|
||||
self: { href: url + '/2' }
|
||||
},
|
||||
id: '2',
|
||||
uuid: '2',
|
||||
leftId: 'author1',
|
||||
@@ -64,7 +70,9 @@ describe('EditRelationshipComponent', () => {
|
||||
rightItem: observableOf(new RemoteData(false, false, true, undefined, item)),
|
||||
}),
|
||||
Object.assign(new Relationship(), {
|
||||
self: url + '/3',
|
||||
_links: {
|
||||
self: { href: url + '/3' }
|
||||
},
|
||||
id: '3',
|
||||
uuid: '3',
|
||||
leftId: 'author2',
|
||||
|
@@ -1,32 +1,32 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ItemRelationshipsComponent } from './item-relationships.component';
|
||||
import { ChangeDetectorRef, DebugElement, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { INotification, Notification } from '../../../shared/notifications/models/notification.model';
|
||||
import { NotificationType } from '../../../shared/notifications/models/notification-type';
|
||||
import { RouterStub } from '../../../shared/testing/router-stub';
|
||||
import { TestScheduler } from 'rxjs/testing';
|
||||
import { SharedModule } from '../../../shared/shared.module';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { ItemDataService } from '../../../core/data/item-data.service';
|
||||
import { ObjectUpdatesService } from '../../../core/data/object-updates/object-updates.service';
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { NotificationsService } from '../../../shared/notifications/notifications.service';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { getTestScheduler } from 'jasmine-marbles';
|
||||
import { combineLatest as observableCombineLatest, of as observableOf } from 'rxjs';
|
||||
import { TestScheduler } from 'rxjs/testing';
|
||||
import { GLOBAL_CONFIG } from '../../../../config';
|
||||
import { ObjectCacheService } from '../../../core/cache/object-cache.service';
|
||||
import { RestResponse } from '../../../core/cache/response.models';
|
||||
import { EntityTypeService } from '../../../core/data/entity-type.service';
|
||||
import { ItemDataService } from '../../../core/data/item-data.service';
|
||||
import { FieldChangeType } from '../../../core/data/object-updates/object-updates.actions';
|
||||
import { ObjectUpdatesService } from '../../../core/data/object-updates/object-updates.service';
|
||||
import { PaginatedList } from '../../../core/data/paginated-list';
|
||||
import { RelationshipService } from '../../../core/data/relationship.service';
|
||||
import { RemoteData } from '../../../core/data/remote-data';
|
||||
import { RequestService } from '../../../core/data/request.service';
|
||||
import { ItemType } from '../../../core/shared/item-relationships/item-type.model';
|
||||
import { RelationshipType } from '../../../core/shared/item-relationships/relationship-type.model';
|
||||
import { Relationship } from '../../../core/shared/item-relationships/relationship.model';
|
||||
import { combineLatest as observableCombineLatest, of as observableOf } from 'rxjs';
|
||||
import { RemoteData } from '../../../core/data/remote-data';
|
||||
import { Item } from '../../../core/shared/item.model';
|
||||
import { PaginatedList } from '../../../core/data/paginated-list';
|
||||
import { PageInfo } from '../../../core/shared/page-info.model';
|
||||
import { FieldChangeType } from '../../../core/data/object-updates/object-updates.actions';
|
||||
import { RelationshipService } from '../../../core/data/relationship.service';
|
||||
import { ObjectCacheService } from '../../../core/cache/object-cache.service';
|
||||
import { getTestScheduler } from 'jasmine-marbles';
|
||||
import { RestResponse } from '../../../core/cache/response.models';
|
||||
import { RequestService } from '../../../core/data/request.service';
|
||||
import { EntityTypeService } from '../../../core/data/entity-type.service';
|
||||
import { ItemType } from '../../../core/shared/item-relationships/item-type.model';
|
||||
import { NotificationType } from '../../../shared/notifications/models/notification-type';
|
||||
import {
|
||||
INotification,
|
||||
Notification
|
||||
} from '../../../shared/notifications/models/notification.model';
|
||||
import { ItemRelationshipsComponent } from './item-relationships.component';
|
||||
|
||||
let comp: any;
|
||||
let fixture: ComponentFixture<ItemRelationshipsComponent>;
|
||||
@@ -77,13 +77,17 @@ describe('ItemRelationshipsComponent', () => {
|
||||
|
||||
relationships = [
|
||||
Object.assign(new Relationship(), {
|
||||
self: url + '/2',
|
||||
_links: {
|
||||
self: { href: url + '/2' }
|
||||
},
|
||||
id: '2',
|
||||
uuid: '2',
|
||||
relationshipType: observableOf(new RemoteData(false, false, true, undefined, relationshipType))
|
||||
}),
|
||||
Object.assign(new Relationship(), {
|
||||
self: url + '/3',
|
||||
_links: {
|
||||
self: { href: url + '/3' }
|
||||
},
|
||||
id: '3',
|
||||
uuid: '3',
|
||||
relationshipType: observableOf(new RemoteData(false, false, true, undefined, relationshipType))
|
||||
@@ -91,7 +95,9 @@ describe('ItemRelationshipsComponent', () => {
|
||||
];
|
||||
|
||||
item = Object.assign(new Item(), {
|
||||
self: 'fake-item-url/publication',
|
||||
_links: {
|
||||
self: { href: 'fake-item-url/publication' }
|
||||
},
|
||||
id: 'publication',
|
||||
uuid: 'publication',
|
||||
relationships: observableOf(new RemoteData(false, false, true, undefined, new PaginatedList(new PageInfo(), relationships))),
|
||||
|
@@ -27,7 +27,6 @@ describe('ObjectCacheService', () => {
|
||||
const timestamp = new Date().getTime();
|
||||
const msToLive = 900000;
|
||||
let objectToCache = {
|
||||
self: selfLink,
|
||||
type: Item.type,
|
||||
_links: {
|
||||
self: { href: selfLink }
|
||||
@@ -39,7 +38,6 @@ describe('ObjectCacheService', () => {
|
||||
|
||||
function init() {
|
||||
objectToCache = {
|
||||
self: selfLink,
|
||||
type: Item.type,
|
||||
_links: {
|
||||
self: { href: selfLink }
|
||||
@@ -115,12 +113,13 @@ describe('ObjectCacheService', () => {
|
||||
|
||||
describe('getList', () => {
|
||||
it('should return an observable of the array of cached objects with the specified self link and type', () => {
|
||||
const item = new Item();
|
||||
item._links.self = { href: selfLink };
|
||||
const item = Object.assign(new Item(), {
|
||||
_links: { self: { href: selfLink } }
|
||||
});
|
||||
spyOn(service, 'getObjectBySelfLink').and.returnValue(observableOf(item));
|
||||
|
||||
service.getList([selfLink, selfLink]).pipe(first()).subscribe((arr) => {
|
||||
expect(arr[0].self).toBe(selfLink);
|
||||
expect(arr[0]._links.self.href).toBe(selfLink);
|
||||
expect(arr[0] instanceof Item).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
@@ -1,22 +1,22 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { Observable, of as observableOf } from 'rxjs';
|
||||
import { provideMockActions } from '@ngrx/effects/testing';
|
||||
import { Store, StoreModule } from '@ngrx/store';
|
||||
import { cold, hot } from 'jasmine-marbles';
|
||||
|
||||
import { ServerSyncBufferEffects } from './server-sync-buffer.effects';
|
||||
import { GLOBAL_CONFIG } from '../../../config';
|
||||
import { CommitSSBAction, EmptySSBAction, ServerSyncBufferActionTypes } from './server-sync-buffer.actions';
|
||||
import { RestRequestMethod } from '../data/rest-request-method';
|
||||
import { Store, StoreModule } from '@ngrx/store';
|
||||
import { RequestService } from '../data/request.service';
|
||||
import { ObjectCacheService } from './object-cache.service';
|
||||
import { MockStore } from '../../shared/testing/mock-store';
|
||||
import { Observable, of as observableOf } from 'rxjs';
|
||||
import * as operators from 'rxjs/operators';
|
||||
import { spyOnOperator } from '../../shared/testing/utils';
|
||||
import { DSpaceObject } from '../shared/dspace-object.model';
|
||||
import { GLOBAL_CONFIG } from '../../../config';
|
||||
import { getMockRequestService } from '../../shared/mocks/mock-request.service';
|
||||
import { MockStore } from '../../shared/testing/mock-store';
|
||||
import { spyOnOperator } from '../../shared/testing/utils';
|
||||
import { RequestService } from '../data/request.service';
|
||||
import { RestRequestMethod } from '../data/rest-request-method';
|
||||
import { DSpaceObject } from '../shared/dspace-object.model';
|
||||
import { ApplyPatchObjectCacheAction } from './object-cache.actions';
|
||||
import { ObjectCacheService } from './object-cache.service';
|
||||
import { CommitSSBAction, EmptySSBAction, ServerSyncBufferActionTypes } from './server-sync-buffer.actions';
|
||||
|
||||
import { ServerSyncBufferEffects } from './server-sync-buffer.effects';
|
||||
|
||||
describe('ServerSyncBufferEffects', () => {
|
||||
let ssbEffects: ServerSyncBufferEffects;
|
||||
@@ -47,8 +47,9 @@ describe('ServerSyncBufferEffects', () => {
|
||||
{
|
||||
provide: ObjectCacheService, useValue: {
|
||||
getObjectBySelfLink: (link) => {
|
||||
const object = new DSpaceObject();
|
||||
object._links.self = { href: link };
|
||||
const object = Object.assign(new DSpaceObject(), {
|
||||
_links: { self: { href: link } }
|
||||
});
|
||||
return observableOf(object);
|
||||
}
|
||||
}
|
||||
|
@@ -1,9 +1,9 @@
|
||||
import { autoserialize, deserialize } from 'cerialize';
|
||||
import { SectionsType } from '../../../submission/sections/sections-type';
|
||||
import { resourceType } from '../../cache/builders/build-decorators';
|
||||
import { HALLink } from '../../shared/hal-link.model';
|
||||
import { ConfigObject } from './config.model';
|
||||
import { SectionsType } from '../../../submission/sections/sections-type';
|
||||
import { ResourceType } from '../../shared/resource-type';
|
||||
import { ConfigObject } from './config.model';
|
||||
|
||||
/**
|
||||
* An interface that define section visibility and its properties.
|
||||
@@ -47,6 +47,7 @@ export class SubmissionSectionModel extends ConfigObject {
|
||||
@deserialize
|
||||
_links: {
|
||||
self: HALLink;
|
||||
config: HALLink;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -31,7 +31,6 @@ describe('BrowseResponseParsingService', () => {
|
||||
metadata: 'dc.date.issued'
|
||||
}, { name: 'dateaccessioned', metadata: 'dc.date.accessioned' }],
|
||||
order: 'ASC',
|
||||
type: 'browse',
|
||||
metadata: ['dc.date.issued'],
|
||||
_links: {
|
||||
self: { href: 'https://rest.api/discover/browses/dateissued' },
|
||||
@@ -44,7 +43,6 @@ describe('BrowseResponseParsingService', () => {
|
||||
metadata: 'dc.date.issued'
|
||||
}, { name: 'dateaccessioned', metadata: 'dc.date.accessioned' }],
|
||||
order: 'ASC',
|
||||
type: 'browse',
|
||||
metadata: ['dc.contributor.*', 'dc.creator'],
|
||||
_links: {
|
||||
self: { href: 'https://rest.api/discover/browses/author' },
|
||||
@@ -68,7 +66,6 @@ describe('BrowseResponseParsingService', () => {
|
||||
metadata: 'dc.date.issued'
|
||||
}, { name: 'dateaccessioned', metadata: 'dc.date.accessioned' }],
|
||||
order: 'ASC',
|
||||
type: 'browse',
|
||||
metadata: ['dc.date.issued'],
|
||||
_links: {
|
||||
self: { href: 'https://rest.api/discover/browses/dateissued' },
|
||||
|
@@ -1,23 +1,23 @@
|
||||
import { DataService } from './data.service';
|
||||
import { NormalizedObject } from '../cache/models/normalized-object.model';
|
||||
import { RequestService } from './request.service';
|
||||
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
|
||||
import { CoreState } from '../core.reducers';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { HALEndpointService } from '../shared/hal-endpoint.service';
|
||||
import { compare, Operation } from 'fast-json-patch';
|
||||
import { Observable, of as observableOf } from 'rxjs';
|
||||
import { FindListOptions } from './request.models';
|
||||
import * as uuidv4 from 'uuid/v4';
|
||||
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../shared/testing/utils';
|
||||
import { NormalizedObjectBuildService } from '../cache/builders/normalized-object-build.service';
|
||||
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
|
||||
import { NormalizedObject } from '../cache/models/normalized-object.model';
|
||||
import { SortDirection, SortOptions } from '../cache/models/sort-options.model';
|
||||
import { ObjectCacheService } from '../cache/object-cache.service';
|
||||
import { compare, Operation } from 'fast-json-patch';
|
||||
import { CoreState } from '../core.reducers';
|
||||
import { DSpaceObject } from '../shared/dspace-object.model';
|
||||
import { ChangeAnalyzer } from './change-analyzer';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { NormalizedObjectBuildService } from '../cache/builders/normalized-object-build.service';
|
||||
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
||||
import { HALEndpointService } from '../shared/hal-endpoint.service';
|
||||
import { Item } from '../shared/item.model';
|
||||
import * as uuidv4 from 'uuid/v4';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../shared/testing/utils';
|
||||
import { ChangeAnalyzer } from './change-analyzer';
|
||||
import { DataService } from './data.service';
|
||||
import { FindListOptions } from './request.models';
|
||||
import { RequestService } from './request.service';
|
||||
|
||||
const endpoint = 'https://rest.api/core';
|
||||
|
||||
@@ -184,13 +184,15 @@ describe('DataService', () => {
|
||||
operations = [{ op: 'replace', path: '/0/value', value: name2 } as Operation];
|
||||
selfLink = 'https://rest.api/endpoint/1698f1d3-be98-4c51-9fd8-6bfedcbd59b7';
|
||||
|
||||
dso = new DSpaceObject();
|
||||
dso._links.self = { href: selfLink };
|
||||
dso.metadata = [{ key: 'dc.title', value: name1 }];
|
||||
dso = Object.assign(new DSpaceObject(), {
|
||||
_links: { self: { href: selfLink } },
|
||||
metadata: [{ key: 'dc.title', value: name1 }]
|
||||
});
|
||||
|
||||
dso2 = new DSpaceObject();
|
||||
dso2._link.self = { href: selfLink };
|
||||
dso2.metadata = [{ key: 'dc.title', value: name2 }];
|
||||
dso2 = Object.assign(new DSpaceObject(), {
|
||||
_links: { self: { href: selfLink } },
|
||||
metadata: [{ key: 'dc.title', value: name2 }]
|
||||
});
|
||||
|
||||
spyOn(service, 'findByHref').and.returnValue(createSuccessfulRemoteDataObject$(dso));
|
||||
spyOn(objectCache, 'addPatch');
|
||||
|
@@ -1,21 +1,21 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { cold, getTestScheduler } from 'jasmine-marbles';
|
||||
import { TestScheduler } from 'rxjs/testing';
|
||||
import { BrowseService } from '../browse/browse.service';
|
||||
import { CoreState } from '../core.reducers';
|
||||
import { ItemDataService } from './item-data.service';
|
||||
import { RequestService } from './request.service';
|
||||
import { HALEndpointService } from '../shared/hal-endpoint.service';
|
||||
import { DeleteRequest, FindListOptions, PostRequest, RestRequest } from './request.models';
|
||||
import { ObjectCacheService } from '../cache/object-cache.service';
|
||||
import { Observable, of as observableOf } from 'rxjs';
|
||||
import { RestResponse } from '../cache/response.models';
|
||||
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
||||
import { NormalizedObjectBuildService } from '../cache/builders/normalized-object-build.service';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { RequestEntry } from './request.reducer';
|
||||
import { TestScheduler } from 'rxjs/testing';
|
||||
import { getMockRequestService } from '../../shared/mocks/mock-request.service';
|
||||
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
||||
import { BrowseService } from '../browse/browse.service';
|
||||
import { NormalizedObjectBuildService } from '../cache/builders/normalized-object-build.service';
|
||||
import { ObjectCacheService } from '../cache/object-cache.service';
|
||||
import { RestResponse } from '../cache/response.models';
|
||||
import { CoreState } from '../core.reducers';
|
||||
import { ExternalSourceEntry } from '../shared/external-source-entry.model';
|
||||
import { HALEndpointService } from '../shared/hal-endpoint.service';
|
||||
import { ItemDataService } from './item-data.service';
|
||||
import { DeleteRequest, FindListOptions, PostRequest, RestRequest } from './request.models';
|
||||
import { RequestEntry } from './request.reducer';
|
||||
import { RequestService } from './request.service';
|
||||
|
||||
describe('ItemDataService', () => {
|
||||
let scheduler: TestScheduler;
|
||||
@@ -45,7 +45,7 @@ describe('ItemDataService', () => {
|
||||
const objectCache = {} as ObjectCacheService;
|
||||
const halEndpointService = {
|
||||
getEndpoint(linkPath: string): Observable<string> {
|
||||
return cold('a', {a: itemEndpoint});
|
||||
return cold('a', { a: itemEndpoint });
|
||||
}
|
||||
} as HALEndpointService;
|
||||
|
||||
@@ -132,7 +132,7 @@ describe('ItemDataService', () => {
|
||||
|
||||
it('should return the endpoint to withdraw and reinstate items', () => {
|
||||
const result = service.getItemWithdrawEndpoint(scopeID);
|
||||
const expected = cold('a', {a: ScopedItemEndpoint});
|
||||
const expected = cold('a', { a: ScopedItemEndpoint });
|
||||
|
||||
expect(result).toBeObservable(expected);
|
||||
});
|
||||
@@ -154,7 +154,7 @@ describe('ItemDataService', () => {
|
||||
|
||||
it('should return the endpoint to make an item private or public', () => {
|
||||
const result = service.getItemDiscoverableEndpoint(scopeID);
|
||||
const expected = cold('a', {a: ScopedItemEndpoint});
|
||||
const expected = cold('a', { a: ScopedItemEndpoint });
|
||||
|
||||
expect(result).toBeObservable(expected);
|
||||
});
|
||||
@@ -201,7 +201,7 @@ describe('ItemDataService', () => {
|
||||
const externalSourceEntry = Object.assign(new ExternalSourceEntry(), {
|
||||
display: 'John, Doe',
|
||||
value: 'John, Doe',
|
||||
self: 'http://test-rest.com/server/api/integration/externalSources/orcidV2/entryValues/0000-0003-4851-8004'
|
||||
_links: { self: { href: 'http://test-rest.com/server/api/integration/externalSources/orcidV2/entryValues/0000-0003-4851-8004' } }
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
|
@@ -2,7 +2,7 @@ import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { Observable } from 'rxjs';
|
||||
import { distinctUntilChanged, filter, find, map, switchMap } from 'rxjs/operators';
|
||||
import { distinctUntilChanged, filter, find, map, switchMap, tap } from 'rxjs/operators';
|
||||
import { hasValue, isNotEmpty, isNotEmptyOperator } from '../../shared/empty.util';
|
||||
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
||||
import { BrowseService } from '../browse/browse.service';
|
||||
@@ -243,7 +243,7 @@ export class ItemDataService extends DataService<Item> {
|
||||
hrefObs.pipe(
|
||||
find((href: string) => hasValue(href)),
|
||||
map((href: string) => {
|
||||
const request = new PutRequest(requestId, href, collection.self, options);
|
||||
const request = new PutRequest(requestId, href, collection._links.self.href, options);
|
||||
this.requestService.configure(request);
|
||||
})
|
||||
).subscribe();
|
||||
|
@@ -34,13 +34,17 @@ describe('RelationshipService', () => {
|
||||
});
|
||||
|
||||
const relationship1 = Object.assign(new Relationship(), {
|
||||
self: relationshipsEndpointURL + '/2',
|
||||
_links: {
|
||||
self: { href: relationshipsEndpointURL + '/2' }
|
||||
},
|
||||
id: '2',
|
||||
uuid: '2',
|
||||
relationshipType: observableOf(new RemoteData(false, false, true, undefined, relationshipType))
|
||||
});
|
||||
const relationship2 = Object.assign(new Relationship(), {
|
||||
self: relationshipsEndpointURL + '/3',
|
||||
_links: {
|
||||
self: { href: relationshipsEndpointURL + '/3' }
|
||||
},
|
||||
id: '3',
|
||||
uuid: '3',
|
||||
relationshipType: observableOf(new RemoteData(false, false, true, undefined, relationshipType))
|
||||
@@ -49,24 +53,28 @@ describe('RelationshipService', () => {
|
||||
const relationships = [relationship1, relationship2];
|
||||
|
||||
const item = Object.assign(new Item(), {
|
||||
self: restEndpointURL + '/publication',
|
||||
id: 'publication',
|
||||
uuid: 'publication',
|
||||
relationships: observableOf(new RemoteData(false, false, true, undefined, new PaginatedList(new PageInfo(), relationships))),
|
||||
_links: {
|
||||
relationships: { href: restEndpointURL + '/publication/relationships' }
|
||||
relationships: { href: restEndpointURL + '/publication/relationships' },
|
||||
self: { href: restEndpointURL + '/publication' }
|
||||
}
|
||||
});
|
||||
|
||||
const relatedItem1 = Object.assign(new Item(), {
|
||||
self: 'fake-item-url/author1',
|
||||
id: 'author1',
|
||||
uuid: 'author1'
|
||||
uuid: 'author1',
|
||||
_links: {
|
||||
self: { href: restEndpointURL + '/author1' }
|
||||
}
|
||||
});
|
||||
const relatedItem2 = Object.assign(new Item(), {
|
||||
self: 'fake-item-url/author2',
|
||||
id: 'author2',
|
||||
uuid: 'author2'
|
||||
uuid: 'author2',
|
||||
_links: {
|
||||
self: { href: restEndpointURL + '/author2' }
|
||||
}
|
||||
});
|
||||
relationship1.leftItem = getRemotedataObservable(relatedItem1);
|
||||
relationship1.rightItem = getRemotedataObservable(item);
|
||||
@@ -130,8 +138,8 @@ describe('RelationshipService', () => {
|
||||
});
|
||||
|
||||
it('should clear the cache of the related items', () => {
|
||||
expect(objectCache.remove).toHaveBeenCalledWith(relatedItem1.self);
|
||||
expect(objectCache.remove).toHaveBeenCalledWith(item.self);
|
||||
expect(objectCache.remove).toHaveBeenCalledWith(relatedItem1._links.self.href);
|
||||
expect(objectCache.remove).toHaveBeenCalledWith(item._links.self.href);
|
||||
expect(requestService.removeByHrefSubstring).toHaveBeenCalledWith(relatedItem1.self);
|
||||
expect(requestService.removeByHrefSubstring).toHaveBeenCalledWith(item.self);
|
||||
});
|
||||
|
@@ -32,8 +32,16 @@ describe('IntegrationResponseParsingService', () => {
|
||||
let definitions;
|
||||
|
||||
function initVars() {
|
||||
pageInfo = Object.assign(new PageInfo(), { elementsPerPage: 5, totalElements: 5, totalPages: 1, currentPage: 1, self: 'https://rest.api/integration/authorities/type/entries'});
|
||||
definitions = new PaginatedList(pageInfo,[
|
||||
pageInfo = Object.assign(new PageInfo(), {
|
||||
elementsPerPage: 5,
|
||||
totalElements: 5,
|
||||
totalPages: 1,
|
||||
currentPage: 1,
|
||||
_links: {
|
||||
self: { href: 'https://rest.api/integration/authorities/type/entries' }
|
||||
}
|
||||
});
|
||||
definitions = new PaginatedList(pageInfo, [
|
||||
Object.assign(new AuthorityValue(), {
|
||||
type: 'authority',
|
||||
display: 'One',
|
||||
|
@@ -1,30 +1,10 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { RegistryService } from './registry.service';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { RequestService } from '../data/request.service';
|
||||
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
|
||||
import { HALEndpointService } from '../shared/hal-endpoint.service';
|
||||
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
|
||||
import { combineLatest as observableCombineLatest, Observable, of as observableOf } from 'rxjs';
|
||||
import { RequestEntry } from '../data/request.reducer';
|
||||
import { RemoteData } from '../data/remote-data';
|
||||
import { PageInfo } from '../shared/page-info.model';
|
||||
import { getMockRequestService } from '../../shared/mocks/mock-request.service';
|
||||
|
||||
import {
|
||||
RegistryMetadatafieldsSuccessResponse,
|
||||
RegistryMetadataschemasSuccessResponse,
|
||||
RestResponse
|
||||
} from '../cache/response.models';
|
||||
import { Component } from '@angular/core';
|
||||
import { RegistryMetadataschemasResponse } from './registry-metadataschemas-response.model';
|
||||
import { RegistryMetadatafieldsResponse } from './registry-metadatafields-response.model';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { Store, StoreModule } from '@ngrx/store';
|
||||
import { MockStore } from '../../shared/testing/mock-store';
|
||||
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
||||
import { NotificationsServiceStub } from '../../shared/testing/notifications-service-stub';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { combineLatest as observableCombineLatest, Observable, of as observableOf } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import {
|
||||
MetadataRegistryCancelFieldAction,
|
||||
MetadataRegistryCancelSchemaAction,
|
||||
@@ -37,12 +17,31 @@ import {
|
||||
MetadataRegistrySelectFieldAction,
|
||||
MetadataRegistrySelectSchemaAction
|
||||
} from '../../+admin/admin-registries/metadata-registry/metadata-registry.actions';
|
||||
import { ResourceType } from '../shared/resource-type';
|
||||
import { MetadataSchema } from '../metadata/metadata-schema.model';
|
||||
import { MetadataField } from '../metadata/metadata-field.model';
|
||||
import { getMockRequestService } from '../../shared/mocks/mock-request.service';
|
||||
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
||||
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
|
||||
import { MockStore } from '../../shared/testing/mock-store';
|
||||
import { NotificationsServiceStub } from '../../shared/testing/notifications-service-stub';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../shared/testing/utils';
|
||||
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
|
||||
|
||||
@Component({template: ''})
|
||||
import {
|
||||
RegistryMetadatafieldsSuccessResponse,
|
||||
RegistryMetadataschemasSuccessResponse,
|
||||
RestResponse
|
||||
} from '../cache/response.models';
|
||||
import { RemoteData } from '../data/remote-data';
|
||||
import { RequestEntry } from '../data/request.reducer';
|
||||
import { RequestService } from '../data/request.service';
|
||||
import { MetadataField } from '../metadata/metadata-field.model';
|
||||
import { MetadataSchema } from '../metadata/metadata-schema.model';
|
||||
import { HALEndpointService } from '../shared/hal-endpoint.service';
|
||||
import { PageInfo } from '../shared/page-info.model';
|
||||
import { RegistryMetadatafieldsResponse } from './registry-metadatafields-response.model';
|
||||
import { RegistryMetadataschemasResponse } from './registry-metadataschemas-response.model';
|
||||
import { RegistryService } from './registry.service';
|
||||
|
||||
@Component({ template: '' })
|
||||
class DummyComponent {
|
||||
}
|
||||
|
||||
@@ -57,15 +56,18 @@ describe('RegistryService', () => {
|
||||
const mockSchemasList = [
|
||||
Object.assign(new MetadataSchema(), {
|
||||
id: 1,
|
||||
self: 'https://dspace7.4science.it/dspace-spring-rest/api/core/metadataschemas/1',
|
||||
_links: {
|
||||
self: { href: 'https://dspace7.4science.it/dspace-spring-rest/api/core/metadataschemas/1' }
|
||||
},
|
||||
prefix: 'dc',
|
||||
namespace: 'http://dublincore.org/documents/dcmi-terms/',
|
||||
type: MetadataSchema.type
|
||||
}),
|
||||
}),
|
||||
Object.assign(new MetadataSchema(), {
|
||||
|
||||
id: 2,
|
||||
self: 'https://dspace7.4science.it/dspace-spring-rest/api/core/metadataschemas/2',
|
||||
_links: {
|
||||
self: { href: 'https://dspace7.4science.it/dspace-spring-rest/api/core/metadataschemas/2' }
|
||||
},
|
||||
prefix: 'mock',
|
||||
namespace: 'http://dspace.org/mockschema',
|
||||
type: MetadataSchema.type
|
||||
@@ -75,7 +77,9 @@ describe('RegistryService', () => {
|
||||
Object.assign(new MetadataField(),
|
||||
{
|
||||
id: 1,
|
||||
self: 'https://dspace7.4science.it/dspace-spring-rest/api/core/metadatafields/8',
|
||||
_links: {
|
||||
self: { href: 'https://dspace7.4science.it/dspace-spring-rest/api/core/metadatafields/8' }
|
||||
},
|
||||
element: 'contributor',
|
||||
qualifier: 'advisor',
|
||||
scopeNote: null,
|
||||
@@ -85,7 +89,9 @@ describe('RegistryService', () => {
|
||||
Object.assign(new MetadataField(),
|
||||
{
|
||||
id: 2,
|
||||
self: 'https://dspace7.4science.it/dspace-spring-rest/api/core/metadatafields/9',
|
||||
_links: {
|
||||
self: { href: 'https://dspace7.4science.it/dspace-spring-rest/api/core/metadatafields/9' }
|
||||
},
|
||||
element: 'contributor',
|
||||
qualifier: 'author',
|
||||
scopeNote: null,
|
||||
@@ -95,7 +101,9 @@ describe('RegistryService', () => {
|
||||
Object.assign(new MetadataField(),
|
||||
{
|
||||
id: 3,
|
||||
self: 'https://dspace7.4science.it/dspace-spring-rest/api/core/metadatafields/10',
|
||||
_links: {
|
||||
self: { href: 'https://dspace7.4science.it/dspace-spring-rest/api/core/metadatafields/10' }
|
||||
},
|
||||
element: 'contributor',
|
||||
qualifier: 'editor',
|
||||
scopeNote: 'test scope note',
|
||||
@@ -105,7 +113,9 @@ describe('RegistryService', () => {
|
||||
Object.assign(new MetadataField(),
|
||||
{
|
||||
id: 4,
|
||||
self: 'https://dspace7.4science.it/dspace-spring-rest/api/core/metadatafields/11',
|
||||
_links: {
|
||||
self: { href: 'https://dspace7.4science.it/dspace-spring-rest/api/core/metadatafields/11' }
|
||||
},
|
||||
element: 'contributor',
|
||||
qualifier: 'illustrator',
|
||||
scopeNote: null,
|
||||
@@ -130,7 +140,7 @@ describe('RegistryService', () => {
|
||||
toRemoteDataObservable: (requestEntryObs: Observable<RequestEntry>, payloadObs: Observable<any>) => {
|
||||
return observableCombineLatest(requestEntryObs,
|
||||
payloadObs).pipe(map(([req, pay]) => {
|
||||
return {req, pay};
|
||||
return { req, pay };
|
||||
})
|
||||
);
|
||||
},
|
||||
@@ -146,11 +156,11 @@ describe('RegistryService', () => {
|
||||
DummyComponent
|
||||
],
|
||||
providers: [
|
||||
{provide: RequestService, useValue: getMockRequestService()},
|
||||
{provide: RemoteDataBuildService, useValue: rdbStub},
|
||||
{provide: HALEndpointService, useValue: halServiceStub},
|
||||
{provide: Store, useClass: MockStore},
|
||||
{provide: NotificationsService, useValue: new NotificationsServiceStub()},
|
||||
{ provide: RequestService, useValue: getMockRequestService() },
|
||||
{ provide: RemoteDataBuildService, useValue: rdbStub },
|
||||
{ provide: HALEndpointService, useValue: halServiceStub },
|
||||
{ provide: Store, useClass: MockStore },
|
||||
{ provide: NotificationsService, useValue: new NotificationsServiceStub() },
|
||||
RegistryService
|
||||
]
|
||||
});
|
||||
@@ -165,7 +175,7 @@ describe('RegistryService', () => {
|
||||
page: pageInfo
|
||||
});
|
||||
const response = new RegistryMetadataschemasSuccessResponse(queryResponse, 200, 'OK', pageInfo);
|
||||
const responseEntry = Object.assign(new RequestEntry(), {response: response});
|
||||
const responseEntry = Object.assign(new RequestEntry(), { response: response });
|
||||
|
||||
beforeEach(() => {
|
||||
(registryService as any).requestService.getByHref.and.returnValue(observableOf(responseEntry));
|
||||
@@ -194,7 +204,7 @@ describe('RegistryService', () => {
|
||||
page: pageInfo
|
||||
});
|
||||
const response = new RegistryMetadataschemasSuccessResponse(queryResponse, 200, 'OK', pageInfo);
|
||||
const responseEntry = Object.assign(new RequestEntry(), {response: response});
|
||||
const responseEntry = Object.assign(new RequestEntry(), { response: response });
|
||||
|
||||
beforeEach(() => {
|
||||
(registryService as any).requestService.getByHref.and.returnValue(observableOf(responseEntry));
|
||||
@@ -223,7 +233,7 @@ describe('RegistryService', () => {
|
||||
page: pageInfo
|
||||
});
|
||||
const response = new RegistryMetadatafieldsSuccessResponse(queryResponse, 200, 'OK', pageInfo);
|
||||
const responseEntry = Object.assign(new RequestEntry(), {response: response});
|
||||
const responseEntry = Object.assign(new RequestEntry(), { response: response });
|
||||
|
||||
beforeEach(() => {
|
||||
(registryService as any).requestService.getByHref.and.returnValue(observableOf(responseEntry));
|
||||
|
@@ -1,27 +1,27 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { Location } from '@angular/common';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { DynamicFormControlModel, DynamicFormService, DynamicInputModel } from '@ng-dynamic-forms/core';
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { FormControl, FormGroup } from '@angular/forms';
|
||||
import { Community } from '../../../core/shared/community.model';
|
||||
import { ComColFormComponent } from './comcol-form.component';
|
||||
import { DSpaceObject } from '../../../core/shared/dspace-object.model';
|
||||
import { hasValue } from '../../empty.util';
|
||||
import { VarDirective } from '../../utils/var.directive';
|
||||
import { NotificationsService } from '../../notifications/notifications.service';
|
||||
import { NotificationsServiceStub } from '../../testing/notifications-service-stub';
|
||||
import { AuthService } from '../../../core/auth/auth.service';
|
||||
import { AuthServiceMock } from '../../mocks/mock-auth.service';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { DynamicFormControlModel, DynamicFormService, DynamicInputModel } from '@ng-dynamic-forms/core';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { RemoteData } from '../../../core/data/remote-data';
|
||||
import { RestRequestMethod } from '../../../core/data/rest-request-method';
|
||||
import { AuthService } from '../../../core/auth/auth.service';
|
||||
import { ObjectCacheService } from '../../../core/cache/object-cache.service';
|
||||
import { ErrorResponse, RestResponse } from '../../../core/cache/response.models';
|
||||
import { RemoteData } from '../../../core/data/remote-data';
|
||||
import { RequestError } from '../../../core/data/request.models';
|
||||
import { RequestService } from '../../../core/data/request.service';
|
||||
import { ObjectCacheService } from '../../../core/cache/object-cache.service';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { RestRequestMethod } from '../../../core/data/rest-request-method';
|
||||
import { Community } from '../../../core/shared/community.model';
|
||||
import { DSpaceObject } from '../../../core/shared/dspace-object.model';
|
||||
import { hasValue } from '../../empty.util';
|
||||
import { AuthServiceMock } from '../../mocks/mock-auth.service';
|
||||
import { NotificationsService } from '../../notifications/notifications.service';
|
||||
import { NotificationsServiceStub } from '../../testing/notifications-service-stub';
|
||||
import { VarDirective } from '../../utils/var.directive';
|
||||
import { ComColFormComponent } from './comcol-form.component';
|
||||
|
||||
describe('ComColFormComponent', () => {
|
||||
let comp: ComColFormComponent<DSpaceObject>;
|
||||
@@ -43,10 +43,10 @@ describe('ComColFormComponent', () => {
|
||||
const dcRandom = 'dc.random';
|
||||
const dcAbstract = 'dc.description.abstract';
|
||||
|
||||
const titleMD = { [dcTitle]: [ { value: 'Community Title', language: null } ] };
|
||||
const randomMD = { [dcRandom]: [ { value: 'Random metadata excluded from form', language: null } ] };
|
||||
const abstractMD = { [dcAbstract]: [ { value: 'Community description', language: null } ] };
|
||||
const newTitleMD = { [dcTitle]: [ { value: 'New Community Title', language: null } ] };
|
||||
const titleMD = { [dcTitle]: [{ value: 'Community Title', language: null }] };
|
||||
const randomMD = { [dcRandom]: [{ value: 'Random metadata excluded from form', language: null }] };
|
||||
const abstractMD = { [dcAbstract]: [{ value: 'Community description', language: null }] };
|
||||
const newTitleMD = { [dcTitle]: [{ value: 'New Community Title', language: null }] };
|
||||
const formModel = [
|
||||
new DynamicInputModel({
|
||||
id: 'title',
|
||||
@@ -96,7 +96,9 @@ describe('ComColFormComponent', () => {
|
||||
|
||||
describe('when the dso doesn\'t contain an ID (newly created)', () => {
|
||||
beforeEach(() => {
|
||||
initComponent(new Community());
|
||||
initComponent(Object.assign(new Community(), {
|
||||
_links: { self: { href: 'community-self' } }
|
||||
}));
|
||||
});
|
||||
|
||||
it('should initialize the uploadFilesOptions with a placeholder url', () => {
|
||||
@@ -191,7 +193,8 @@ describe('ComColFormComponent', () => {
|
||||
beforeEach(() => {
|
||||
initComponent(Object.assign(new Community(), {
|
||||
id: 'community-id',
|
||||
logo: observableOf(new RemoteData(false, false, true, null, undefined))
|
||||
logo: observableOf(new RemoteData(false, false, true, null, undefined)),
|
||||
_links: { self: { href: 'community-self' } }
|
||||
}));
|
||||
});
|
||||
|
||||
@@ -208,7 +211,8 @@ describe('ComColFormComponent', () => {
|
||||
beforeEach(() => {
|
||||
initComponent(Object.assign(new Community(), {
|
||||
id: 'community-id',
|
||||
logo: observableOf(new RemoteData(false, false, true, null, {}))
|
||||
logo: observableOf(new RemoteData(false, false, true, null, {})),
|
||||
_links: { self: { href: 'community-self' } }
|
||||
}));
|
||||
});
|
||||
|
||||
|
@@ -1,34 +1,30 @@
|
||||
import { Component, EventEmitter, Input, OnDestroy, OnInit, Output, ViewChild } from '@angular/core';
|
||||
import { Location } from '@angular/common';
|
||||
import {
|
||||
DynamicFormControlModel,
|
||||
DynamicFormService,
|
||||
DynamicInputModel
|
||||
} from '@ng-dynamic-forms/core';
|
||||
import { Component, EventEmitter, Input, OnDestroy, OnInit, Output, ViewChild } from '@angular/core';
|
||||
import { FormGroup } from '@angular/forms';
|
||||
import { DynamicFormControlModel, DynamicFormService, DynamicInputModel } from '@ng-dynamic-forms/core';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { FileUploader } from 'ng2-file-upload';
|
||||
import { combineLatest as observableCombineLatest } from 'rxjs';
|
||||
import { BehaviorSubject } from 'rxjs/internal/BehaviorSubject';
|
||||
import { Subscription } from 'rxjs/internal/Subscription';
|
||||
import { AuthService } from '../../../core/auth/auth.service';
|
||||
import { ObjectCacheService } from '../../../core/cache/object-cache.service';
|
||||
import { ErrorResponse, RestResponse } from '../../../core/cache/response.models';
|
||||
import { ComColDataService } from '../../../core/data/comcol-data.service';
|
||||
import { RemoteData } from '../../../core/data/remote-data';
|
||||
import { RequestService } from '../../../core/data/request.service';
|
||||
import { RestRequestMethod } from '../../../core/data/rest-request-method';
|
||||
import { Bitstream } from '../../../core/shared/bitstream.model';
|
||||
import { Collection } from '../../../core/shared/collection.model';
|
||||
import { Community } from '../../../core/shared/community.model';
|
||||
|
||||
import { DSpaceObject } from '../../../core/shared/dspace-object.model';
|
||||
import { MetadataMap, MetadataValue } from '../../../core/shared/metadata.models';
|
||||
import { ResourceType } from '../../../core/shared/resource-type';
|
||||
import { hasValue, isNotEmpty } from '../../empty.util';
|
||||
import { UploaderOptions } from '../../uploader/uploader-options.model';
|
||||
import { NotificationsService } from '../../notifications/notifications.service';
|
||||
import { ComColDataService } from '../../../core/data/comcol-data.service';
|
||||
import { Subscription } from 'rxjs/internal/Subscription';
|
||||
import { AuthService } from '../../../core/auth/auth.service';
|
||||
import { Community } from '../../../core/shared/community.model';
|
||||
import { Collection } from '../../../core/shared/collection.model';
|
||||
import { UploaderOptions } from '../../uploader/uploader-options.model';
|
||||
import { UploaderComponent } from '../../uploader/uploader.component';
|
||||
import { FileUploader } from 'ng2-file-upload';
|
||||
import { ErrorResponse, RestResponse } from '../../../core/cache/response.models';
|
||||
import { BehaviorSubject } from 'rxjs/internal/BehaviorSubject';
|
||||
import { RemoteData } from '../../../core/data/remote-data';
|
||||
import { Bitstream } from '../../../core/shared/bitstream.model';
|
||||
import { combineLatest as observableCombineLatest } from 'rxjs';
|
||||
import { RestRequestMethod } from '../../../core/data/rest-request-method';
|
||||
import { RequestService } from '../../../core/data/request.service';
|
||||
import { ObjectCacheService } from '../../../core/cache/object-cache.service';
|
||||
|
||||
/**
|
||||
* A form for creating and editing Communities or Collections
|
||||
@@ -253,8 +249,8 @@ export class ComColFormComponent<T extends DSpaceObject> implements OnInit, OnDe
|
||||
* Refresh the object's cache to ensure the latest version
|
||||
*/
|
||||
private refreshCache() {
|
||||
this.requestService.removeByHrefSubstring(this.dso.self);
|
||||
this.objectCache.remove(this.dso.self);
|
||||
this.requestService.removeByHrefSubstring(this.dso._links.self.href);
|
||||
this.objectCache.remove(this.dso._links.self.href);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,19 +1,18 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Community } from '../../../core/shared/community.model';
|
||||
import { CommunityDataService } from '../../../core/data/community-data.service';
|
||||
import { Observable } from 'rxjs';
|
||||
import { RouteService } from '../../../core/services/route.service';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { RemoteData } from '../../../core/data/remote-data';
|
||||
import { hasValue, isNotEmpty, isNotUndefined } from '../../empty.util';
|
||||
import { take } from 'rxjs/operators';
|
||||
import { getSucceededRemoteData } from '../../../core/shared/operators';
|
||||
import { DSpaceObject } from '../../../core/shared/dspace-object.model';
|
||||
import { DataService } from '../../../core/data/data.service';
|
||||
import { ComColDataService } from '../../../core/data/comcol-data.service';
|
||||
import { NotificationsService } from '../../notifications/notifications.service';
|
||||
import { Router } from '@angular/router';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { take } from 'rxjs/operators';
|
||||
import { ComColDataService } from '../../../core/data/comcol-data.service';
|
||||
import { CommunityDataService } from '../../../core/data/community-data.service';
|
||||
import { RemoteData } from '../../../core/data/remote-data';
|
||||
import { RouteService } from '../../../core/services/route.service';
|
||||
import { Community } from '../../../core/shared/community.model';
|
||||
import { DSpaceObject } from '../../../core/shared/dspace-object.model';
|
||||
import { getSucceededRemoteData } from '../../../core/shared/operators';
|
||||
import { ResourceType } from '../../../core/shared/resource-type';
|
||||
import { hasValue, isNotEmpty, isNotUndefined } from '../../empty.util';
|
||||
import { NotificationsService } from '../../notifications/notifications.service';
|
||||
|
||||
/**
|
||||
* Component representing the create page for communities and collections
|
||||
|
9
src/app/shared/mocks/mock-link-service.ts
Normal file
9
src/app/shared/mocks/mock-link-service.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { LinkService } from '../../core/cache/builders/link.service';
|
||||
|
||||
export function getMockLinkService(): LinkService {
|
||||
return jasmine.createSpyObj('linkService', {
|
||||
resolveLinks: jasmine.createSpy('resolveLinks'),
|
||||
resolveLink: jasmine.createSpy('resolveLink'),
|
||||
removeResolvedLinks: jasmine.createSpy('removeResolvedLinks')
|
||||
});
|
||||
}
|
@@ -1,16 +1,19 @@
|
||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { cold } from 'jasmine-marbles';
|
||||
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { LinkService } from '../../../../core/cache/builders/link.service';
|
||||
import { ItemDataService } from '../../../../core/data/item-data.service';
|
||||
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { WorkflowItem } from '../../../../core/submission/models/workflowitem.model';
|
||||
import { MyDspaceItemStatusType } from '../../../object-collection/shared/mydspace-item-status/my-dspace-item-status-type';
|
||||
import { createSuccessfulRemoteDataObject } from '../../../testing/utils';
|
||||
import { WorkflowItemSearchResultListElementComponent } from './workflow-item-search-result-list-element.component';
|
||||
import { WorkflowItemSearchResult } from '../../../object-collection/shared/workflow-item-search-result.model';
|
||||
import { createSuccessfulRemoteDataObject } from '../../../testing/utils';
|
||||
import { TruncatableService } from '../../../truncatable/truncatable.service';
|
||||
import { WorkflowItemSearchResultListElementComponent } from './workflow-item-search-result-list-element.component';
|
||||
|
||||
let component: WorkflowItemSearchResultListElementComponent;
|
||||
let fixture: ComponentFixture<WorkflowItemSearchResultListElementComponent>;
|
||||
@@ -52,13 +55,22 @@ const item = Object.assign(new Item(), {
|
||||
const rd = createSuccessfulRemoteDataObject(item);
|
||||
mockResultObject.indexableObject = Object.assign(new WorkflowItem(), { item: observableOf(rd) });
|
||||
|
||||
let linkService;
|
||||
|
||||
describe('WorkflowItemSearchResultListElementComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
linkService = {
|
||||
resolveLink() {
|
||||
// mock
|
||||
},
|
||||
};
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopAnimationsModule],
|
||||
declarations: [WorkflowItemSearchResultListElementComponent],
|
||||
providers: [
|
||||
{ provide: TruncatableService, useValue: {} },
|
||||
{ provide: ItemDataService, useValue: {} },
|
||||
{ provide: LinkService, useValue: linkService },
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).overrideComponent(WorkflowItemSearchResultListElementComponent, {
|
||||
@@ -77,7 +89,7 @@ describe('WorkflowItemSearchResultListElementComponent', () => {
|
||||
});
|
||||
|
||||
it('should init item properly', () => {
|
||||
expect(component.item).toEqual(item);
|
||||
expect(component.item$).toBeObservable(cold('a',{a: item}));
|
||||
});
|
||||
|
||||
it('should have properly status', () => {
|
||||
|
@@ -3,14 +3,17 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { LinkService } from '../../../../core/cache/builders/link.service';
|
||||
import { ItemDataService } from '../../../../core/data/item-data.service';
|
||||
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { WorkspaceItemSearchResultListElementComponent } from './workspace-item-search-result-list-element.component';
|
||||
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 { createSuccessfulRemoteDataObject } from '../../../testing/utils';
|
||||
import { WorkflowItemSearchResult } from '../../../object-collection/shared/workflow-item-search-result.model';
|
||||
import { createSuccessfulRemoteDataObject } from '../../../testing/utils';
|
||||
import { TruncatableService } from '../../../truncatable/truncatable.service';
|
||||
import { WorkspaceItemSearchResultListElementComponent } from './workspace-item-search-result-list-element.component';
|
||||
|
||||
let component: WorkspaceItemSearchResultListElementComponent;
|
||||
let fixture: ComponentFixture<WorkspaceItemSearchResultListElementComponent>;
|
||||
@@ -51,14 +54,18 @@ const item = Object.assign(new Item(), {
|
||||
});
|
||||
const rd = createSuccessfulRemoteDataObject(item);
|
||||
mockResultObject.indexableObject = Object.assign(new WorkspaceItem(), { item: observableOf(rd) });
|
||||
let linkService;
|
||||
|
||||
describe('WorkspaceItemSearchResultListElementComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
linkService = getMockLinkService;
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopAnimationsModule],
|
||||
declarations: [WorkspaceItemSearchResultListElementComponent],
|
||||
providers: [
|
||||
{ provide: TruncatableService, useValue: {} },
|
||||
{ provide: ItemDataService, useValue: {} },
|
||||
{ provide: LinkService, useValue: linkService },
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).overrideComponent(WorkspaceItemSearchResultListElementComponent, {
|
||||
@@ -77,10 +84,12 @@ describe('WorkspaceItemSearchResultListElementComponent', () => {
|
||||
});
|
||||
|
||||
it('should init item properly', () => {
|
||||
expect(component.item).toEqual(item);
|
||||
expect(linkService.resolveLink).toHaveBeenCalled();
|
||||
expect(component.item$).toEqual(observableOf(item));
|
||||
});
|
||||
|
||||
it('should have properly status', () => {
|
||||
expect(linkService.resolveLink).toHaveBeenCalled();
|
||||
expect(component.status).toEqual(MyDspaceItemStatusType.WORKSPACE);
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user