mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
[CST-12490] unit test fixes
This commit is contained in:
@@ -1,23 +1,79 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { LdnServiceFormEditComponent } from './ldn-service-form-edit.component';
|
||||
import { ChangeDetectorRef, EventEmitter } from '@angular/core';
|
||||
import { ReactiveFormsModule, FormBuilder } from '@angular/forms';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { TranslateModule, TranslateService } from '@ngx-translate/core';
|
||||
import { PaginationService } from 'ngx-pagination';
|
||||
import { NotificationsService } from '../../../shared/notifications/notifications.service';
|
||||
import { LdnItemfiltersService } from '../ldn-services-data/ldn-itemfilters-data.service';
|
||||
import { LdnServicesService } from '../ldn-services-data/ldn-services-data.service';
|
||||
import { RouterStub } from '../../../shared/testing/router.stub';
|
||||
import { MockActivatedRoute } from '../../../shared/mocks/active-router.mock';
|
||||
import { NotificationsServiceStub } from '../../../shared/testing/notifications-service.stub';
|
||||
import { of } from 'rxjs';
|
||||
import { RouteService } from '../../../core/services/route.service';
|
||||
import { provideMockStore } from '@ngrx/store/testing';
|
||||
|
||||
describe('LdnServiceFormEditComponent', () => {
|
||||
let component: LdnServiceFormEditComponent;
|
||||
let fixture: ComponentFixture<LdnServiceFormEditComponent>;
|
||||
let component: LdnServiceFormEditComponent;
|
||||
let fixture: ComponentFixture<LdnServiceFormEditComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [LdnServiceFormEditComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
let ldnServicesService: any;
|
||||
let ldnItemfiltersService: any;
|
||||
let cdRefStub: any;
|
||||
let modalService: any;
|
||||
|
||||
fixture = TestBed.createComponent(LdnServiceFormEditComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
const translateServiceStub = {
|
||||
get: () => of('translated-text'),
|
||||
onLangChange: new EventEmitter(),
|
||||
onTranslationChange: new EventEmitter(),
|
||||
onDefaultLangChange: new EventEmitter()
|
||||
};
|
||||
|
||||
beforeEach(async () => {
|
||||
ldnServicesService = {
|
||||
update: () => ({}),
|
||||
};
|
||||
ldnItemfiltersService = {
|
||||
findAll: () => of(['item1', 'item2']),
|
||||
};
|
||||
cdRefStub = Object.assign({
|
||||
detectChanges: () => fixture.detectChanges()
|
||||
});
|
||||
modalService = {
|
||||
open: () => {/*comment*/
|
||||
}
|
||||
};
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [ReactiveFormsModule, TranslateModule.forRoot()],
|
||||
declarations: [LdnServiceFormEditComponent],
|
||||
providers: [
|
||||
{ provide: LdnServicesService, useValue: ldnServicesService },
|
||||
{ provide: LdnItemfiltersService, useValue: ldnItemfiltersService },
|
||||
{ provide: Router, useValue: new RouterStub() },
|
||||
{ provide: ActivatedRoute, useValue: new MockActivatedRoute() },
|
||||
{ provide: ChangeDetectorRef, useValue: cdRefStub },
|
||||
{ provide: NgbModal, useValue: modalService },
|
||||
{ provide: NotificationsService, useValue: NotificationsServiceStub },
|
||||
{ provide: TranslateService, useValue: translateServiceStub },
|
||||
{ provide: PaginationService, useValue: {} },
|
||||
FormBuilder,
|
||||
RouteService,
|
||||
provideMockStore({ }),
|
||||
]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(LdnServiceFormEditComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
@@ -1,25 +1,80 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { LdnServiceFormComponent } from './ldn-service-form.component';
|
||||
import { FormBuilder, ReactiveFormsModule } from '@angular/forms';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { NgbModal, NgbModalModule } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { TranslateModule, TranslateService } from '@ngx-translate/core';
|
||||
import { LdnItemfiltersService } from '../ldn-services-data/ldn-itemfilters-data.service';
|
||||
import { LdnServicesService } from '../ldn-services-data/ldn-services-data.service';
|
||||
import { NotificationsService } from 'src/app/shared/notifications/notifications.service';
|
||||
import { Router } from '@angular/router';
|
||||
import { RouterStub } from 'src/app/shared/testing/router.stub';
|
||||
import { createPaginatedList } from 'src/app/shared/testing/utils.test';
|
||||
import { Itemfilter } from '../ldn-services-model/ldn-service-itemfilters';
|
||||
import { createSuccessfulRemoteDataObject$ } from 'src/app/shared/remote-data.utils';
|
||||
import { of } from 'rxjs';
|
||||
import { EventEmitter } from '@angular/core';
|
||||
|
||||
describe('LdnServiceFormComponent', () => {
|
||||
let component: LdnServiceFormComponent;
|
||||
let fixture: ComponentFixture<LdnServiceFormComponent>;
|
||||
let component: LdnServiceFormComponent;
|
||||
let fixture: ComponentFixture<LdnServiceFormComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [LdnServiceFormComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
let ldnServicesService: any;
|
||||
let ldnItemfiltersService: any;
|
||||
let notificationsService: any;
|
||||
|
||||
const itemFiltersRdPL$ = createSuccessfulRemoteDataObject$(createPaginatedList([new Itemfilter()]));
|
||||
const translateServiceStub = {
|
||||
get: () => of('translated-text'),
|
||||
onLangChange: new EventEmitter(),
|
||||
onTranslationChange: new EventEmitter(),
|
||||
onDefaultLangChange: new EventEmitter()
|
||||
};
|
||||
|
||||
beforeEach(async () => {
|
||||
ldnItemfiltersService = jasmine.createSpyObj('ldnItemfiltersService', {
|
||||
findAll: jasmine.createSpy('findAll'),
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(LdnServiceFormComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
ldnServicesService = jasmine.createSpyObj('ldnServicesService', {
|
||||
create: jasmine.createSpy('create'),
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
notificationsService = jasmine.createSpyObj('notificationsService', {
|
||||
success: jasmine.createSpy('success'),
|
||||
error: jasmine.createSpy('error'),
|
||||
});
|
||||
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [
|
||||
ReactiveFormsModule,
|
||||
RouterTestingModule,
|
||||
NgbModalModule,
|
||||
TranslateModule.forRoot()
|
||||
],
|
||||
providers: [
|
||||
{ provide: LdnItemfiltersService, useValue: ldnItemfiltersService },
|
||||
{ provide: LdnServicesService, useValue: ldnServicesService },
|
||||
{ provide: NotificationsService, useValue: notificationsService },
|
||||
{ provide: TranslateService, useValue: translateServiceStub },
|
||||
{ provide: Router, useValue: new RouterStub() },
|
||||
{ provide: NgbModal, useValue: { open: () => {/*comment*/ } } },
|
||||
FormBuilder
|
||||
],
|
||||
declarations: [LdnServiceFormComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(LdnServiceFormComponent);
|
||||
component = fixture.componentInstance;
|
||||
ldnItemfiltersService.findAll.and.returnValue(itemFiltersRdPL$);
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
@@ -1,27 +1,9 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { LdnService } from "../ldn-services-model/ldn-services.model";
|
||||
import { ActivatedRoute } from "@angular/router";
|
||||
import { ProcessDataService } from "../../../core/data/processes/process-data.service";
|
||||
import { LinkService } from "../../../core/cache/builders/link.service";
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-ldn-service-new',
|
||||
templateUrl: './ldn-service-new.component.html',
|
||||
styleUrls: ['./ldn-service-new.component.scss']
|
||||
})
|
||||
export class LdnServiceNewComponent implements OnInit {
|
||||
/**
|
||||
* Emits preselected process if there is one
|
||||
*/
|
||||
ldnService$?: Observable<LdnService>;
|
||||
|
||||
constructor(private route: ActivatedRoute, private processService: ProcessDataService, private linkService: LinkService) {
|
||||
}
|
||||
|
||||
/**
|
||||
* If there's an id parameter, use this the process with this identifier as presets for the form
|
||||
*/
|
||||
ngOnInit() {
|
||||
}
|
||||
export class LdnServiceNewComponent {
|
||||
}
|
||||
|
@@ -1,25 +1,54 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { LdnServicesOverviewComponent } from './ldn-services-directory.component';
|
||||
import { ChangeDetectorRef, EventEmitter } from '@angular/core';
|
||||
import { NotificationsService } from '../../../shared/notifications/notifications.service';
|
||||
import { NotificationsServiceStub } from '../../../shared/testing/notifications-service.stub';
|
||||
import { TranslateModule, TranslateService } from '@ngx-translate/core';
|
||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { LdnServicesService } from '../ldn-services-data/ldn-services-data.service';
|
||||
import { PaginationService } from '../../../core/pagination/pagination.service';
|
||||
import { PaginationServiceStub } from '../../../shared/testing/pagination-service.stub';
|
||||
import { of } from 'rxjs';
|
||||
|
||||
import { ServicesDirectoryComponent } from './services-directory.component';
|
||||
describe('LdnServicesOverviewComponent', () => {
|
||||
let component: LdnServicesOverviewComponent;
|
||||
let fixture: ComponentFixture<LdnServicesOverviewComponent>;
|
||||
|
||||
describe('ServicesDirectoryComponent', () => {
|
||||
let component: ServicesDirectoryComponent;
|
||||
let fixture: ComponentFixture<ServicesDirectoryComponent>;
|
||||
const translateServiceStub = {
|
||||
get: () => of('translated-text'),
|
||||
onLangChange: new EventEmitter(),
|
||||
onTranslationChange: new EventEmitter(),
|
||||
onDefaultLangChange: new EventEmitter()
|
||||
};
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ServicesDirectoryComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [TranslateModule.forRoot()],
|
||||
declarations: [LdnServicesOverviewComponent],
|
||||
providers: [
|
||||
{ provide: LdnServicesService, useValue: {} },
|
||||
{ provide: PaginationService, useValue: new PaginationServiceStub() },
|
||||
{
|
||||
provide: NgbModal, useValue: {
|
||||
open: () => {/*comment*/
|
||||
}
|
||||
}
|
||||
},
|
||||
{ provide: ChangeDetectorRef, useValue: {} },
|
||||
{ provide: NotificationsService, useValue: NotificationsServiceStub },
|
||||
{ provide: TranslateService, useValue: translateServiceStub },
|
||||
]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ServicesDirectoryComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(LdnServicesOverviewComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
@@ -1,17 +0,0 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { LdnDirectoryService } from './ldn-directory.service';
|
||||
|
||||
describe('LdnDirectoryService', () => {
|
||||
let service: LdnDirectoryService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(LdnDirectoryService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
// @ts-ignore
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
@@ -1,29 +0,0 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { map, Observable } from 'rxjs';
|
||||
import { LdnServicesService } from "../ldn-services-data/ldn-services-data.service";
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class LdnDirectoryService {
|
||||
private itemFilterEndpoint = 'http://localhost:8080/server/api/config/itemfilters';
|
||||
|
||||
|
||||
constructor(private http: HttpClient,
|
||||
private ldnServicesService: LdnServicesService) {
|
||||
}
|
||||
|
||||
public getItemFilters(): Observable<any> {
|
||||
|
||||
return this.ldnServicesService.findAll().pipe(
|
||||
map((servicesData) => {
|
||||
return servicesData;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@@ -1,17 +0,0 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { LdnServicesBulkDeleteService } from './ldn-service-bulk-delete.service';
|
||||
|
||||
describe('LdnServiceBulkDeleteService', () => {
|
||||
let service: LdnServicesBulkDeleteService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(LdnServicesBulkDeleteService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
// @ts-ignore
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
@@ -1,14 +1,23 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { NotifyInfoComponent } from './notify-info.component';
|
||||
import { NotifyInfoService } from './notify-info.service';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
|
||||
describe('NotifyInfoComponent', () => {
|
||||
let component: NotifyInfoComponent;
|
||||
let fixture: ComponentFixture<NotifyInfoComponent>;
|
||||
let notifyInfoServiceSpy: any;
|
||||
|
||||
beforeEach(async () => {
|
||||
notifyInfoServiceSpy = jasmine.createSpyObj('NotifyInfoService', ['getCoarLdnLocalInboxUrls']);
|
||||
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ NotifyInfoComponent ]
|
||||
imports: [TranslateModule.forRoot()],
|
||||
declarations: [ NotifyInfoComponent ],
|
||||
providers: [
|
||||
{ provide: NotifyInfoService, useValue: notifyInfoServiceSpy }
|
||||
]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
@@ -16,7 +16,7 @@ export class NotifyInfoComponent implements OnInit {
|
||||
*/
|
||||
coarRestApiUrl: Observable<string[]> = of([]);
|
||||
|
||||
constructor(public notifyInfoService: NotifyInfoService) {}
|
||||
constructor(private notifyInfoService: NotifyInfoService) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.coarRestApiUrl = this.notifyInfoService.getCoarLdnLocalInboxUrls();
|
||||
|
@@ -1,16 +1,49 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { NotifyInfoGuard } from './notify-info.guard';
|
||||
import { Router } from '@angular/router';
|
||||
import { NotifyInfoService } from './notify-info.service';
|
||||
import { of } from 'rxjs';
|
||||
|
||||
describe('NotifyInfoGuard', () => {
|
||||
let guard: NotifyInfoGuard;
|
||||
let notifyInfoServiceSpy: any;
|
||||
let router: any;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
notifyInfoServiceSpy = jasmine.createSpyObj('NotifyInfoService', ['isCoarConfigEnabled']);
|
||||
router = jasmine.createSpyObj('Router', ['parseUrl']);
|
||||
TestBed.configureTestingModule({
|
||||
providers: [
|
||||
NotifyInfoGuard,
|
||||
{ provide: NotifyInfoService, useValue: notifyInfoServiceSpy},
|
||||
{ provide: Router, useValue: router}
|
||||
]
|
||||
});
|
||||
guard = TestBed.inject(NotifyInfoGuard);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(guard).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should return true if COAR config is enabled', (done) => {
|
||||
notifyInfoServiceSpy.isCoarConfigEnabled.and.returnValue(of(true));
|
||||
|
||||
guard.canActivate(null, null).subscribe((result) => {
|
||||
expect(result).toBe(true);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should call parseUrl method of Router if COAR config is not enabled', (done) => {
|
||||
notifyInfoServiceSpy.isCoarConfigEnabled.and.returnValue(of(false));
|
||||
router.parseUrl.and.returnValue(of('/404'));
|
||||
|
||||
guard.canActivate(null, null).subscribe(() => {
|
||||
expect(router.parseUrl).toHaveBeenCalledWith('/404');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
@@ -16,7 +16,7 @@ export class NotifyInfoGuard implements CanActivate {
|
||||
canActivate(
|
||||
route: ActivatedRouteSnapshot,
|
||||
state: RouterStateSnapshot
|
||||
): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
|
||||
): Observable<boolean | UrlTree> {
|
||||
return this.notifyInfoService.isCoarConfigEnabled().pipe(
|
||||
map(coarLdnEnabled => {
|
||||
if (coarLdnEnabled) {
|
||||
|
@@ -1,16 +1,50 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { NotifyInfoService } from './notify-info.service';
|
||||
import { ConfigurationDataService } from '../../data/configuration-data.service';
|
||||
import { of } from 'rxjs';
|
||||
|
||||
describe('NotifyInfoService', () => {
|
||||
let service: NotifyInfoService;
|
||||
let configurationDataService: any;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
configurationDataService = {
|
||||
findByPropertyName: jasmine.createSpy('findByPropertyName').and.returnValue(of({})),
|
||||
};
|
||||
TestBed.configureTestingModule({
|
||||
providers: [
|
||||
NotifyInfoService,
|
||||
{ provide: ConfigurationDataService, useValue: configurationDataService },
|
||||
]
|
||||
});
|
||||
service = TestBed.inject(NotifyInfoService);
|
||||
configurationDataService = TestBed.inject(ConfigurationDataService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should retrieve and map coar configuration', () => {
|
||||
const mockResponse = { payload: { values: ['true'] } };
|
||||
(configurationDataService.findByPropertyName as jasmine.Spy).and.returnValue(of(mockResponse));
|
||||
|
||||
service.isCoarConfigEnabled().subscribe((result) => {
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
it('should retrieve and map LDN local inbox URLs', () => {
|
||||
const mockResponse = { values: ['inbox1', 'inbox2'] };
|
||||
(configurationDataService.findByPropertyName as jasmine.Spy).and.returnValue(of(mockResponse));
|
||||
|
||||
service.getCoarLdnLocalInboxUrls().subscribe((result) => {
|
||||
expect(result).toEqual(['inbox1', 'inbox2']);
|
||||
});
|
||||
});
|
||||
|
||||
it('should return the inbox relation link', () => {
|
||||
expect(service.getInboxRelationLink()).toBe('http://www.w3.org/ns/ldp#inbox');
|
||||
});
|
||||
});
|
||||
|
@@ -19,7 +19,6 @@ import { Item } from '../shared/item.model';
|
||||
import { WorkspaceItem } from './models/workspaceitem.model';
|
||||
import { RequestEntry } from '../data/request-entry.model';
|
||||
import { CoreState } from '../core-state.model';
|
||||
import { testSearchDataImplementation } from '../data/base/search-data.spec';
|
||||
import { testDeleteDataImplementation } from '../data/base/delete-data.spec';
|
||||
|
||||
describe('WorkspaceitemDataService test', () => {
|
||||
@@ -84,17 +83,19 @@ describe('WorkspaceitemDataService test', () => {
|
||||
function initTestService() {
|
||||
hrefOnlyDataService = getMockHrefOnlyDataService();
|
||||
return new WorkspaceitemDataService(
|
||||
comparator,
|
||||
halService,
|
||||
http,
|
||||
notificationsService,
|
||||
requestService,
|
||||
rdbService,
|
||||
objectCache,
|
||||
halService,
|
||||
notificationsService,
|
||||
store,
|
||||
);
|
||||
}
|
||||
|
||||
describe('composition', () => {
|
||||
const initService = () => new WorkspaceitemDataService(null, null, null, null, null);
|
||||
testSearchDataImplementation(initService);
|
||||
const initService = () => new WorkspaceitemDataService(null, null, null, null, null, null, null, null);
|
||||
testDeleteDataImplementation(initService);
|
||||
});
|
||||
|
||||
@@ -126,7 +127,7 @@ describe('WorkspaceitemDataService test', () => {
|
||||
service = initTestService();
|
||||
|
||||
spyOn((service as any), 'findByHref').and.callThrough();
|
||||
spyOn((service as any), 'getSearchByHref').and.returnValue(searchRequestURL$);
|
||||
spyOn((service as any), 'getIDHref').and.callThrough();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@@ -138,7 +139,7 @@ describe('WorkspaceitemDataService test', () => {
|
||||
scheduler.schedule(() => service.findByItem('1234-1234', true, true, pageInfo));
|
||||
scheduler.flush();
|
||||
|
||||
expect((service as any).findByHref).toHaveBeenCalledWith(searchRequestURL$, true, true);
|
||||
expect((service as any).findByHref).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should return a RemoteData<WorkspaceItem> for the search', () => {
|
||||
|
@@ -50,6 +50,20 @@ export class WorkspaceitemDataService extends IdentifiableDataService<WorkspaceI
|
||||
public delete(objectId: string, copyVirtualMetadata?: string[]): Observable<RemoteData<NoContent>> {
|
||||
return this.deleteData.delete(objectId, copyVirtualMetadata);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an existing object on the server
|
||||
* @param href The self link of the object to be removed
|
||||
* @param copyVirtualMetadata (optional parameter) the identifiers of the relationship types for which the virtual
|
||||
* metadata should be saved as real metadata
|
||||
* @return A RemoteData observable with an empty payload, but still representing the state of the request: statusCode,
|
||||
* errorMessage, timeCompleted, etc
|
||||
* Only emits once all request related to the DSO has been invalidated.
|
||||
*/
|
||||
public deleteByHref(href: string, copyVirtualMetadata?: string[]): Observable<RemoteData<NoContent>> {
|
||||
return this.deleteData.deleteByHref(href, copyVirtualMetadata);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the WorkspaceItem object found through the UUID of an item
|
||||
*
|
||||
|
@@ -17,16 +17,23 @@ import { TranslateLoaderMock } from '../shared/mocks/translate-loader.mock';
|
||||
import { storeModuleConfig } from '../app.reducer';
|
||||
import { AuthorizationDataService } from '../core/data/feature-authorization/authorization-data.service';
|
||||
import { AuthorizationDataServiceStub } from '../shared/testing/authorization-service.stub';
|
||||
import { NotifyInfoService } from '../core/coar-notify/notify-info/notify-info.service';
|
||||
import { of } from 'rxjs';
|
||||
|
||||
let comp: FooterComponent;
|
||||
let fixture: ComponentFixture<FooterComponent>;
|
||||
let de: DebugElement;
|
||||
let el: HTMLElement;
|
||||
|
||||
let notifyInfoServiceStub: any;
|
||||
|
||||
describe('Footer component', () => {
|
||||
|
||||
// waitForAsync beforeEach
|
||||
beforeEach(waitForAsync(() => {
|
||||
notifyInfoServiceStub = {
|
||||
isCoarConfigEnabled: () => of(true)
|
||||
};
|
||||
return TestBed.configureTestingModule({
|
||||
imports: [CommonModule, StoreModule.forRoot({}, storeModuleConfig), TranslateModule.forRoot({
|
||||
loader: {
|
||||
@@ -38,6 +45,7 @@ describe('Footer component', () => {
|
||||
providers: [
|
||||
FooterComponent,
|
||||
{ provide: AuthorizationDataService, useClass: AuthorizationDataServiceStub },
|
||||
{ provide: NotifyInfoService, useValue: notifyInfoServiceStub },
|
||||
],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||
});
|
||||
|
@@ -62,6 +62,7 @@ describe('FullItemPageComponent', () => {
|
||||
let serverResponseService: jasmine.SpyObj<ServerResponseService>;
|
||||
let signpostingDataService: jasmine.SpyObj<SignpostingDataService>;
|
||||
let linkHeadService: jasmine.SpyObj<LinkHeadService>;
|
||||
let notifyInfoService: jasmine.SpyObj<NotifyInfoService>;
|
||||
|
||||
const mocklink = {
|
||||
href: 'http://test.org',
|
||||
@@ -106,6 +107,12 @@ describe('FullItemPageComponent', () => {
|
||||
removeTag: jasmine.createSpy('removeTag'),
|
||||
});
|
||||
|
||||
notifyInfoService = jasmine.createSpyObj('NotifyInfoService', {
|
||||
isCoarConfigEnabled: observableOf(true),
|
||||
getCoarLdnLocalInboxUrls: observableOf(['http://test.org']),
|
||||
getInboxRelationLink: observableOf('http://test.org'),
|
||||
});
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
imports: [TranslateModule.forRoot({
|
||||
loader: {
|
||||
@@ -123,7 +130,7 @@ describe('FullItemPageComponent', () => {
|
||||
{ provide: ServerResponseService, useValue: serverResponseService },
|
||||
{ provide: SignpostingDataService, useValue: signpostingDataService },
|
||||
{ provide: LinkHeadService, useValue: linkHeadService },
|
||||
{ provide: NotifyInfoService, useValue: {} },
|
||||
{ provide: NotifyInfoService, useValue: notifyInfoService },
|
||||
{ provide: PLATFORM_ID, useValue: 'server' }
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
@@ -180,7 +187,7 @@ describe('FullItemPageComponent', () => {
|
||||
|
||||
it('should add the signposting links', () => {
|
||||
expect(serverResponseService.setHeader).toHaveBeenCalled();
|
||||
expect(linkHeadService.addTag).toHaveBeenCalledTimes(2);
|
||||
expect(linkHeadService.addTag).toHaveBeenCalledTimes(3);
|
||||
});
|
||||
});
|
||||
describe('when the item is withdrawn and the user is not an admin', () => {
|
||||
@@ -209,7 +216,7 @@ describe('FullItemPageComponent', () => {
|
||||
|
||||
it('should add the signposting links', () => {
|
||||
expect(serverResponseService.setHeader).toHaveBeenCalled();
|
||||
expect(linkHeadService.addTag).toHaveBeenCalledTimes(2);
|
||||
expect(linkHeadService.addTag).toHaveBeenCalledTimes(3);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -226,7 +233,7 @@ describe('FullItemPageComponent', () => {
|
||||
|
||||
it('should add the signposting links', () => {
|
||||
expect(serverResponseService.setHeader).toHaveBeenCalled();
|
||||
expect(linkHeadService.addTag).toHaveBeenCalledTimes(2);
|
||||
expect(linkHeadService.addTag).toHaveBeenCalledTimes(3);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -59,7 +59,7 @@ export class FullItemPageComponent extends ItemPageComponent implements OnInit,
|
||||
protected notifyInfoService: NotifyInfoService,
|
||||
@Inject(PLATFORM_ID) protected platformId: string,
|
||||
) {
|
||||
super(route, router, items, authService, authorizationService, responseService, signpostingDataService, linkHeadService,notifyInfoService, platformId);
|
||||
super(route, router, items, authService, authorizationService, responseService, signpostingDataService, linkHeadService, notifyInfoService, platformId);
|
||||
}
|
||||
|
||||
/*** AoT inheritance fix, will hopefully be resolved in the near future **/
|
||||
|
@@ -75,6 +75,8 @@ describe('ItemPageComponent', () => {
|
||||
data: observableOf({ dso: createSuccessfulRemoteDataObject(mockItem) })
|
||||
});
|
||||
|
||||
const getCoarLdnLocalInboxUrls = ['http://InboxUrls.org', 'http://InboxUrls2.org'];
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
authService = jasmine.createSpyObj('authService', {
|
||||
isAuthenticated: observableOf(true),
|
||||
@@ -99,7 +101,7 @@ describe('ItemPageComponent', () => {
|
||||
notifyInfoService = jasmine.createSpyObj('NotifyInfoService', {
|
||||
getInboxRelationLink: 'http://www.w3.org/ns/ldp#inbox',
|
||||
isCoarConfigEnabled: observableOf(true),
|
||||
getCoarLdnLocalInboxUrls: observableOf(['http://test.org', 'http://test2.org']),
|
||||
getCoarLdnLocalInboxUrls: observableOf(getCoarLdnLocalInboxUrls),
|
||||
});
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
@@ -175,7 +177,7 @@ describe('ItemPageComponent', () => {
|
||||
|
||||
it('should add the signposting links', () => {
|
||||
expect(serverResponseService.setHeader).toHaveBeenCalled();
|
||||
expect(linkHeadService.addTag).toHaveBeenCalledTimes(2);
|
||||
expect(linkHeadService.addTag).toHaveBeenCalledTimes(4);
|
||||
});
|
||||
|
||||
|
||||
@@ -184,7 +186,7 @@ describe('ItemPageComponent', () => {
|
||||
expect(comp.signpostingLinks).toEqual([mocklink, mocklink2]);
|
||||
|
||||
// Check if linkHeadService.addTag() was called with the correct arguments
|
||||
expect(linkHeadService.addTag).toHaveBeenCalledTimes(mockSignpostingLinks.length);
|
||||
expect(linkHeadService.addTag).toHaveBeenCalledTimes(mockSignpostingLinks.length + getCoarLdnLocalInboxUrls.length);
|
||||
let expected: LinkDefinition = mockSignpostingLinks[0] as LinkDefinition;
|
||||
expect(linkHeadService.addTag).toHaveBeenCalledWith(expected);
|
||||
expected = {
|
||||
@@ -195,8 +197,7 @@ describe('ItemPageComponent', () => {
|
||||
});
|
||||
|
||||
it('should set Link header on the server', () => {
|
||||
|
||||
expect(serverResponseService.setHeader).toHaveBeenCalledWith('Link', '<http://test.org> ; rel="rel1" ; type="type1" , <http://test2.org> ; rel="rel2" ');
|
||||
expect(serverResponseService.setHeader).toHaveBeenCalledWith('Link', '<http://test.org> ; rel="rel1" ; type="type1" , <http://test2.org> ; rel="rel2" , <http://InboxUrls.org> ; rel="http://www.w3.org/ns/ldp#inbox", <http://InboxUrls2.org> ; rel="http://www.w3.org/ns/ldp#inbox"');
|
||||
});
|
||||
|
||||
});
|
||||
@@ -224,9 +225,9 @@ describe('ItemPageComponent', () => {
|
||||
expect(objectLoader.nativeElement).toBeDefined();
|
||||
});
|
||||
|
||||
it('should add the signposting links', () => {
|
||||
it('should add the signposti`ng links`', () => {
|
||||
expect(serverResponseService.setHeader).toHaveBeenCalled();
|
||||
expect(linkHeadService.addTag).toHaveBeenCalledTimes(2);
|
||||
expect(linkHeadService.addTag).toHaveBeenCalledTimes(4);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -243,7 +244,7 @@ describe('ItemPageComponent', () => {
|
||||
|
||||
it('should add the signposting links', () => {
|
||||
expect(serverResponseService.setHeader).toHaveBeenCalled();
|
||||
expect(linkHeadService.addTag).toHaveBeenCalledTimes(2);
|
||||
expect(linkHeadService.addTag).toHaveBeenCalledTimes(4);
|
||||
});
|
||||
});
|
||||
|
||||
|
@@ -17,7 +17,8 @@ describe('SuggestionsPopupComponent', () => {
|
||||
const suggestionStateService = jasmine.createSpyObj('SuggestionTargetsStateService', {
|
||||
hasUserVisitedSuggestions: jasmine.createSpy('hasUserVisitedSuggestions'),
|
||||
getCurrentUserSuggestionTargets: jasmine.createSpy('getCurrentUserSuggestionTargets'),
|
||||
dispatchMarkUserSuggestionsAsVisitedAction: jasmine.createSpy('dispatchMarkUserSuggestionsAsVisitedAction')
|
||||
dispatchMarkUserSuggestionsAsVisitedAction: jasmine.createSpy('dispatchMarkUserSuggestionsAsVisitedAction'),
|
||||
dispatchRefreshUserSuggestionsAction: jasmine.createSpy('dispatchRefreshUserSuggestionsAction')
|
||||
});
|
||||
|
||||
const mockNotificationInterpolation = { count: 12, source: 'source', suggestionId: 'id', displayName: 'displayName' };
|
||||
|
@@ -31,7 +31,6 @@ export class SuggestionsPopupComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
public initializePopup() {
|
||||
console.log('POPUP INIT dispatchRefreshUserSuggestionsAction');
|
||||
this.reciterSuggestionStateService.dispatchRefreshUserSuggestionsAction();
|
||||
const notifier = new Subject();
|
||||
this.subscription = combineLatest([
|
||||
|
@@ -262,6 +262,10 @@ export const environment: BuildConfig = {
|
||||
undoTimeout: 10000 // 10 seconds
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
suggestion: [],
|
||||
|
||||
themes: [
|
||||
{
|
||||
name: 'full-item-page-theme',
|
||||
|
Reference in New Issue
Block a user