mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-09 19:13:08 +00:00
58789: RegistryService tests, small bugfixes and prod-build fixes
This commit is contained in:
@@ -18,7 +18,7 @@ import { NotificationsService } from '../../../shared/notifications/notification
|
|||||||
import { NotificationsServiceStub } from '../../../shared/testing/notifications-service-stub';
|
import { NotificationsServiceStub } from '../../../shared/testing/notifications-service-stub';
|
||||||
import { RestResponse } from '../../../core/cache/response.models';
|
import { RestResponse } from '../../../core/cache/response.models';
|
||||||
|
|
||||||
fdescribe('MetadataRegistryComponent', () => {
|
describe('MetadataRegistryComponent', () => {
|
||||||
let comp: MetadataRegistryComponent;
|
let comp: MetadataRegistryComponent;
|
||||||
let fixture: ComponentFixture<MetadataRegistryComponent>;
|
let fixture: ComponentFixture<MetadataRegistryComponent>;
|
||||||
let registryService: RegistryService;
|
let registryService: RegistryService;
|
||||||
|
@@ -64,7 +64,7 @@ export class MetadataRegistryComponent {
|
|||||||
* Force-update the list of schemas by first clearing the cache related to metadata schemas, then performing
|
* Force-update the list of schemas by first clearing the cache related to metadata schemas, then performing
|
||||||
* a new REST call
|
* a new REST call
|
||||||
*/
|
*/
|
||||||
private forceUpdateSchemas() {
|
public forceUpdateSchemas() {
|
||||||
this.registryService.clearMetadataSchemaRequests().subscribe();
|
this.registryService.clearMetadataSchemaRequests().subscribe();
|
||||||
this.updateSchemas();
|
this.updateSchemas();
|
||||||
}
|
}
|
||||||
|
@@ -73,7 +73,7 @@ export class MetadataSchemaFormComponent implements OnInit {
|
|||||||
*/
|
*/
|
||||||
@Output() submitForm: EventEmitter<any> = new EventEmitter();
|
@Output() submitForm: EventEmitter<any> = new EventEmitter();
|
||||||
|
|
||||||
constructor(private registryService: RegistryService, private formBuilderService: FormBuilderService, private translateService: TranslateService) {
|
constructor(public registryService: RegistryService, private formBuilderService: FormBuilderService, private translateService: TranslateService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
@@ -90,7 +90,7 @@ export class MetadataFieldFormComponent implements OnInit {
|
|||||||
*/
|
*/
|
||||||
@Output() submitForm: EventEmitter<any> = new EventEmitter();
|
@Output() submitForm: EventEmitter<any> = new EventEmitter();
|
||||||
|
|
||||||
constructor(private registryService: RegistryService,
|
constructor(public registryService: RegistryService,
|
||||||
private formBuilderService: FormBuilderService,
|
private formBuilderService: FormBuilderService,
|
||||||
private translateService: TranslateService) {
|
private translateService: TranslateService) {
|
||||||
}
|
}
|
||||||
|
@@ -96,7 +96,7 @@ export class MetadataSchemaComponent implements OnInit {
|
|||||||
* Force-update the list of fields by first clearing the cache related to metadata fields, then performing
|
* Force-update the list of fields by first clearing the cache related to metadata fields, then performing
|
||||||
* a new REST call
|
* a new REST call
|
||||||
*/
|
*/
|
||||||
private forceUpdateFields() {
|
public forceUpdateFields() {
|
||||||
this.registryService.clearMetadataFieldRequests().subscribe();
|
this.registryService.clearMetadataFieldRequests().subscribe();
|
||||||
this.updateFields();
|
this.updateFields();
|
||||||
}
|
}
|
||||||
|
@@ -21,6 +21,8 @@ import { RequestService } from './request.service';
|
|||||||
import { ActionsSubject, Store } from '@ngrx/store';
|
import { ActionsSubject, Store } from '@ngrx/store';
|
||||||
import { TestScheduler } from 'rxjs/testing';
|
import { TestScheduler } from 'rxjs/testing';
|
||||||
import { BehaviorSubject } from 'rxjs/internal/BehaviorSubject';
|
import { BehaviorSubject } from 'rxjs/internal/BehaviorSubject';
|
||||||
|
import { MockStore } from '../../shared/testing/mock-store';
|
||||||
|
import { IndexState } from '../index/index.reducer';
|
||||||
|
|
||||||
describe('RequestService', () => {
|
describe('RequestService', () => {
|
||||||
let scheduler: TestScheduler;
|
let scheduler: TestScheduler;
|
||||||
@@ -59,7 +61,8 @@ describe('RequestService', () => {
|
|||||||
service = new RequestService(
|
service = new RequestService(
|
||||||
objectCache,
|
objectCache,
|
||||||
uuidService,
|
uuidService,
|
||||||
store
|
store,
|
||||||
|
undefined
|
||||||
);
|
);
|
||||||
serviceAsAny = service as any;
|
serviceAsAny = service as any;
|
||||||
});
|
});
|
||||||
|
@@ -32,6 +32,8 @@ import { MockTranslateLoader } from '../../shared/mocks/mock-translate-loader';
|
|||||||
import { BrowseService } from '../browse/browse.service';
|
import { BrowseService } from '../browse/browse.service';
|
||||||
import { HALEndpointService } from '../shared/hal-endpoint.service';
|
import { HALEndpointService } from '../shared/hal-endpoint.service';
|
||||||
import { EmptyError } from 'rxjs/internal-compatibility';
|
import { EmptyError } from 'rxjs/internal-compatibility';
|
||||||
|
import { MockStore } from '../../shared/testing/mock-store';
|
||||||
|
import { IndexState } from '../index/index.reducer';
|
||||||
|
|
||||||
/* tslint:disable:max-classes-per-file */
|
/* tslint:disable:max-classes-per-file */
|
||||||
@Component({
|
@Component({
|
||||||
@@ -82,7 +84,7 @@ describe('MetadataService', () => {
|
|||||||
|
|
||||||
objectCacheService = new ObjectCacheService(store);
|
objectCacheService = new ObjectCacheService(store);
|
||||||
uuidService = new UUIDService();
|
uuidService = new UUIDService();
|
||||||
requestService = new RequestService(objectCacheService, uuidService, store);
|
requestService = new RequestService(objectCacheService, uuidService, store, undefined);
|
||||||
remoteDataBuildService = new RemoteDataBuildService(objectCacheService, requestService);
|
remoteDataBuildService = new RemoteDataBuildService(objectCacheService, requestService);
|
||||||
|
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
|
@@ -14,13 +14,30 @@ import { getMockRequestService } from '../../shared/mocks/mock-request.service';
|
|||||||
import {
|
import {
|
||||||
RegistryBitstreamformatsSuccessResponse,
|
RegistryBitstreamformatsSuccessResponse,
|
||||||
RegistryMetadatafieldsSuccessResponse,
|
RegistryMetadatafieldsSuccessResponse,
|
||||||
RegistryMetadataschemasSuccessResponse
|
RegistryMetadataschemasSuccessResponse, RestResponse
|
||||||
} from '../cache/response.models';
|
} from '../cache/response.models';
|
||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { RegistryMetadataschemasResponse } from './registry-metadataschemas-response.model';
|
import { RegistryMetadataschemasResponse } from './registry-metadataschemas-response.model';
|
||||||
import { RegistryMetadatafieldsResponse } from './registry-metadatafields-response.model';
|
import { RegistryMetadatafieldsResponse } from './registry-metadatafields-response.model';
|
||||||
import { RegistryBitstreamformatsResponse } from './registry-bitstreamformats-response.model';
|
import { RegistryBitstreamformatsResponse } from './registry-bitstreamformats-response.model';
|
||||||
import { map } from 'rxjs/operators';
|
import { map } from 'rxjs/operators';
|
||||||
|
import { Store } from '@ngrx/store';
|
||||||
|
import { AppState } from '../../app.reducer';
|
||||||
|
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 {
|
||||||
|
MetadataRegistryCancelFieldAction,
|
||||||
|
MetadataRegistryCancelSchemaAction, MetadataRegistryDeselectAllFieldAction,
|
||||||
|
MetadataRegistryDeselectAllSchemaAction, MetadataRegistryDeselectFieldAction,
|
||||||
|
MetadataRegistryDeselectSchemaAction,
|
||||||
|
MetadataRegistryEditFieldAction,
|
||||||
|
MetadataRegistryEditSchemaAction, MetadataRegistrySelectFieldAction,
|
||||||
|
MetadataRegistrySelectSchemaAction
|
||||||
|
} from '../../+admin/admin-registries/metadata-registry/metadata-registry.actions';
|
||||||
|
import { MetadataSchema } from '../metadata/metadataschema.model';
|
||||||
|
import { MetadataField } from '../metadata/metadatafield.model';
|
||||||
|
|
||||||
@Component({ template: '' })
|
@Component({ template: '' })
|
||||||
class DummyComponent {
|
class DummyComponent {
|
||||||
@@ -49,31 +66,35 @@ describe('RegistryService', () => {
|
|||||||
];
|
];
|
||||||
const mockFieldsList = [
|
const mockFieldsList = [
|
||||||
{
|
{
|
||||||
|
id: 1,
|
||||||
self: 'https://dspace7.4science.it/dspace-spring-rest/api/core/metadatafields/8',
|
self: 'https://dspace7.4science.it/dspace-spring-rest/api/core/metadatafields/8',
|
||||||
element: 'contributor',
|
element: 'contributor',
|
||||||
qualifier: 'advisor',
|
qualifier: 'advisor',
|
||||||
scopenote: null,
|
scopeNote: null,
|
||||||
schema: mockSchemasList[0]
|
schema: mockSchemasList[0]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
id: 2,
|
||||||
self: 'https://dspace7.4science.it/dspace-spring-rest/api/core/metadatafields/9',
|
self: 'https://dspace7.4science.it/dspace-spring-rest/api/core/metadatafields/9',
|
||||||
element: 'contributor',
|
element: 'contributor',
|
||||||
qualifier: 'author',
|
qualifier: 'author',
|
||||||
scopenote: null,
|
scopeNote: null,
|
||||||
schema: mockSchemasList[0]
|
schema: mockSchemasList[0]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
id: 3,
|
||||||
self: 'https://dspace7.4science.it/dspace-spring-rest/api/core/metadatafields/10',
|
self: 'https://dspace7.4science.it/dspace-spring-rest/api/core/metadatafields/10',
|
||||||
element: 'contributor',
|
element: 'contributor',
|
||||||
qualifier: 'editor',
|
qualifier: 'editor',
|
||||||
scopenote: 'test scope note',
|
scopeNote: 'test scope note',
|
||||||
schema: mockSchemasList[1]
|
schema: mockSchemasList[1]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
id: 4,
|
||||||
self: 'https://dspace7.4science.it/dspace-spring-rest/api/core/metadatafields/11',
|
self: 'https://dspace7.4science.it/dspace-spring-rest/api/core/metadatafields/11',
|
||||||
element: 'contributor',
|
element: 'contributor',
|
||||||
qualifier: 'illustrator',
|
qualifier: 'illustrator',
|
||||||
scopenote: null,
|
scopeNote: null,
|
||||||
schema: mockSchemasList[1]
|
schema: mockSchemasList[1]
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
@@ -118,6 +139,7 @@ describe('RegistryService', () => {
|
|||||||
|
|
||||||
const endpoint = 'path';
|
const endpoint = 'path';
|
||||||
const endpointWithParams = `${endpoint}?size=${pageInfo.elementsPerPage}&page=${pageInfo.currentPage - 1}`;
|
const endpointWithParams = `${endpoint}?size=${pageInfo.elementsPerPage}&page=${pageInfo.currentPage - 1}`;
|
||||||
|
const fieldEndpointWithParams = `${endpoint}?schema=${mockSchemasList[0].prefix}&size=${pageInfo.elementsPerPage}&page=${pageInfo.currentPage - 1}`;
|
||||||
|
|
||||||
const halServiceStub = {
|
const halServiceStub = {
|
||||||
getEndpoint: (link: string) => observableOf(endpoint)
|
getEndpoint: (link: string) => observableOf(endpoint)
|
||||||
@@ -136,9 +158,11 @@ describe('RegistryService', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const mockStore = new MockStore<AppState>(Object.create(null));
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [CommonModule],
|
imports: [CommonModule, TranslateModule.forRoot()],
|
||||||
declarations: [
|
declarations: [
|
||||||
DummyComponent
|
DummyComponent
|
||||||
],
|
],
|
||||||
@@ -146,6 +170,8 @@ describe('RegistryService', () => {
|
|||||||
{ provide: RequestService, useValue: getMockRequestService() },
|
{ provide: RequestService, useValue: getMockRequestService() },
|
||||||
{ provide: RemoteDataBuildService, useValue: rdbStub },
|
{ provide: RemoteDataBuildService, useValue: rdbStub },
|
||||||
{ provide: HALEndpointService, useValue: halServiceStub },
|
{ provide: HALEndpointService, useValue: halServiceStub },
|
||||||
|
{ provide: Store, useValue: mockStore },
|
||||||
|
{ provide: NotificationsService, useValue: new NotificationsServiceStub() },
|
||||||
RegistryService
|
RegistryService
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
@@ -237,7 +263,7 @@ describe('RegistryService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should call getByHref on the request service with the correct request url', () => {
|
it('should call getByHref on the request service with the correct request url', () => {
|
||||||
expect((registryService as any).requestService.getByHref).toHaveBeenCalledWith(endpointWithParams);
|
expect((registryService as any).requestService.getByHref).toHaveBeenCalledWith(fieldEndpointWithParams);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -269,4 +295,186 @@ describe('RegistryService', () => {
|
|||||||
expect((registryService as any).requestService.getByHref).toHaveBeenCalledWith(endpointWithParams);
|
expect((registryService as any).requestService.getByHref).toHaveBeenCalledWith(endpointWithParams);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('when dispatching to the store', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
spyOn(mockStore, 'dispatch');
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when calling editMetadataSchema', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
registryService.editMetadataSchema(mockSchemasList[0]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should dispatch a MetadataRegistryEditSchemaAction with the correct schema', () => {
|
||||||
|
expect(mockStore.dispatch).toHaveBeenCalledWith(new MetadataRegistryEditSchemaAction(mockSchemasList[0]));
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when calling cancelEditMetadataSchema', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
registryService.cancelEditMetadataSchema();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should dispatch a MetadataRegistryCancelSchemaAction', () => {
|
||||||
|
expect(mockStore.dispatch).toHaveBeenCalledWith(new MetadataRegistryCancelSchemaAction());
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when calling selectMetadataSchema', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
registryService.selectMetadataSchema(mockSchemasList[0]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should dispatch a MetadataRegistrySelectSchemaAction with the correct schema', () => {
|
||||||
|
expect(mockStore.dispatch).toHaveBeenCalledWith(new MetadataRegistrySelectSchemaAction(mockSchemasList[0]));
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when calling deselectMetadataSchema', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
registryService.deselectMetadataSchema(mockSchemasList[0]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should dispatch a MetadataRegistryDeselectSchemaAction with the correct schema', () => {
|
||||||
|
expect(mockStore.dispatch).toHaveBeenCalledWith(new MetadataRegistryDeselectSchemaAction(mockSchemasList[0]));
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when calling deselectAllMetadataSchema', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
registryService.deselectAllMetadataSchema();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should dispatch a MetadataRegistryDeselectAllSchemaAction', () => {
|
||||||
|
expect(mockStore.dispatch).toHaveBeenCalledWith(new MetadataRegistryDeselectAllSchemaAction());
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when calling editMetadataField', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
registryService.editMetadataField(mockFieldsList[0]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should dispatch a MetadataRegistryEditFieldAction with the correct Field', () => {
|
||||||
|
expect(mockStore.dispatch).toHaveBeenCalledWith(new MetadataRegistryEditFieldAction(mockFieldsList[0]));
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when calling cancelEditMetadataField', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
registryService.cancelEditMetadataField();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should dispatch a MetadataRegistryCancelFieldAction', () => {
|
||||||
|
expect(mockStore.dispatch).toHaveBeenCalledWith(new MetadataRegistryCancelFieldAction());
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when calling selectMetadataField', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
registryService.selectMetadataField(mockFieldsList[0]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should dispatch a MetadataRegistrySelectFieldAction with the correct Field', () => {
|
||||||
|
expect(mockStore.dispatch).toHaveBeenCalledWith(new MetadataRegistrySelectFieldAction(mockFieldsList[0]));
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when calling deselectMetadataField', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
registryService.deselectMetadataField(mockFieldsList[0]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should dispatch a MetadataRegistryDeselectFieldAction with the correct Field', () => {
|
||||||
|
expect(mockStore.dispatch).toHaveBeenCalledWith(new MetadataRegistryDeselectFieldAction(mockFieldsList[0]));
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when calling deselectAllMetadataField', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
registryService.deselectAllMetadataField();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should dispatch a MetadataRegistryDeselectAllFieldAction', () => {
|
||||||
|
expect(mockStore.dispatch).toHaveBeenCalledWith(new MetadataRegistryDeselectAllFieldAction());
|
||||||
|
})
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when createOrUpdateMetadataSchema is called', () => {
|
||||||
|
let result: Observable<MetadataSchema>;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
result = registryService.createOrUpdateMetadataSchema(mockSchemasList[0]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return the created/updated metadata schema', () => {
|
||||||
|
result.subscribe((schema: MetadataSchema) => {
|
||||||
|
expect(schema).toEqual(mockSchemasList[0]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when createOrUpdateMetadataField is called', () => {
|
||||||
|
let result: Observable<MetadataField>;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
result = registryService.createOrUpdateMetadataField(mockFieldsList[0]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return the created/updated metadata field', () => {
|
||||||
|
result.subscribe((field: MetadataField) => {
|
||||||
|
expect(field).toEqual(mockFieldsList[0]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when deleteMetadataSchema is called', () => {
|
||||||
|
let result: Observable<RestResponse>;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
result = registryService.deleteMetadataSchema(mockSchemasList[0].id);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return a successful response', () => {
|
||||||
|
result.subscribe((response: RestResponse) => {
|
||||||
|
expect(response.isSuccessful).toBe(true);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when deleteMetadataField is called', () => {
|
||||||
|
let result: Observable<RestResponse>;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
result = registryService.deleteMetadataField(mockFieldsList[0].id);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return a successful response', () => {
|
||||||
|
result.subscribe((response: RestResponse) => {
|
||||||
|
expect(response.isSuccessful).toBe(true);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when clearMetadataSchemaRequests is called', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
registryService.clearMetadataSchemaRequests().subscribe();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should remove the requests related to metadata schemas from cache', () => {
|
||||||
|
expect((registryService as any).requestService.removeByHrefSubstring).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when clearMetadataFieldRequests is called', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
registryService.clearMetadataFieldRequests().subscribe();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should remove the requests related to metadata fields from cache', () => {
|
||||||
|
expect((registryService as any).requestService.removeByHrefSubstring).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -350,13 +350,13 @@ describe('FormComponent test suite', () => {
|
|||||||
const control = formComp.formGroup.get(['dc_title']);
|
const control = formComp.formGroup.get(['dc_title']);
|
||||||
control.setValue('Test Title');
|
control.setValue('Test Title');
|
||||||
formState.testForm.valid = true;
|
formState.testForm.valid = true;
|
||||||
spyOn(formComp.submit, 'emit');
|
spyOn(formComp.submitForm, 'emit');
|
||||||
|
|
||||||
form.next(formState.testForm);
|
form.next(formState.testForm);
|
||||||
formFixture.detectChanges();
|
formFixture.detectChanges();
|
||||||
|
|
||||||
formComp.onSubmit();
|
formComp.onSubmit();
|
||||||
expect(formComp.submit.emit).toHaveBeenCalled();
|
expect(formComp.submitForm.emit).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not emit submit Event on form submit whether the form is not valid', () => {
|
it('should not emit submit Event on form submit whether the form is not valid', () => {
|
||||||
|
@@ -7,6 +7,9 @@ export function getMockRequestService(requestEntry$: Observable<RequestEntry> =
|
|||||||
configure: false,
|
configure: false,
|
||||||
generateRequestId: 'clients/b186e8ce-e99c-4183-bc9a-42b4821bdb78',
|
generateRequestId: 'clients/b186e8ce-e99c-4183-bc9a-42b4821bdb78',
|
||||||
getByHref: requestEntry$,
|
getByHref: requestEntry$,
|
||||||
getByUUID: requestEntry$
|
getByUUID: requestEntry$,
|
||||||
|
/* tslint:disable:no-empty */
|
||||||
|
removeByHrefSubstring: () => {}
|
||||||
|
/* tslint:enable:no-empty */
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user