mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-14 21:43:04 +00:00
[TLC-254] Get Type Bind config from backend
This commit is contained in:
@@ -48,12 +48,18 @@ import { DynamicConcatModel } from './ds-dynamic-form-ui/models/ds-dynamic-conca
|
||||
import { DynamicLookupNameModel } from './ds-dynamic-form-ui/models/lookup/dynamic-lookup-name.model';
|
||||
import { DynamicRowArrayModel } from './ds-dynamic-form-ui/models/ds-dynamic-row-array-model';
|
||||
import { FormRowModel } from '../../../core/config/models/config-submission-form.model';
|
||||
import {ConfigurationDataService} from "../../../core/data/configuration-data.service";
|
||||
import {createSuccessfulRemoteDataObject$} from "../../remote-data.utils";
|
||||
import {ConfigurationProperty} from "../../../core/shared/configuration-property.model";
|
||||
|
||||
describe('FormBuilderService test suite', () => {
|
||||
|
||||
let testModel: DynamicFormControlModel[];
|
||||
let testFormConfiguration: SubmissionFormsModel;
|
||||
let service: FormBuilderService;
|
||||
let configSpy: ConfigurationDataService;
|
||||
const typeFieldProp = 'submit.type-bind.field';
|
||||
const typeFieldTestValue = 'dc.type';
|
||||
|
||||
const submissionId = '1234';
|
||||
|
||||
@@ -65,15 +71,24 @@ describe('FormBuilderService test suite', () => {
|
||||
return new Promise<boolean>((resolve) => setTimeout(() => resolve(true), 0));
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
const createConfigSuccessSpy = (...values: string[]) => jasmine.createSpyObj('configurationDataService', {
|
||||
findByPropertyName: createSuccessfulRemoteDataObject$({
|
||||
... new ConfigurationProperty(),
|
||||
name: typeFieldProp,
|
||||
values: values,
|
||||
}),
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
configSpy = createConfigSuccessSpy(typeFieldTestValue);
|
||||
TestBed.configureTestingModule({
|
||||
imports: [ReactiveFormsModule],
|
||||
providers: [
|
||||
{ provide: FormBuilderService, useClass: FormBuilderService },
|
||||
{ provide: DynamicFormValidationService, useValue: {} },
|
||||
{ provide: NG_VALIDATORS, useValue: testValidator, multi: true },
|
||||
{ provide: NG_ASYNC_VALIDATORS, useValue: testAsyncValidator, multi: true }
|
||||
{ provide: NG_ASYNC_VALIDATORS, useValue: testAsyncValidator, multi: true },
|
||||
{ provide: ConfigurationDataService, useValue: configSpy }
|
||||
]
|
||||
});
|
||||
|
||||
@@ -881,4 +896,11 @@ describe('FormBuilderService test suite', () => {
|
||||
expect(formArray.length === 0).toBe(true);
|
||||
});
|
||||
|
||||
it(`should request the ${typeFieldProp} property and set value "dc_type"`, () => {
|
||||
service.setTypeBindFieldFromConfig();
|
||||
expect(configSpy.findByPropertyName).toHaveBeenCalledTimes(1);
|
||||
expect(configSpy.findByPropertyName).toHaveBeenCalledWith(typeFieldProp);
|
||||
expect(service.getTypeField()).toEqual('dc_type');
|
||||
});
|
||||
|
||||
});
|
||||
|
Reference in New Issue
Block a user