[TLC-254] mock config data service, get type in form builder service+test

This commit is contained in:
Kim Shepherd
2022-05-04 13:49:59 +12:00
parent fd0c8f409e
commit 5363ae1ac1
3 changed files with 16 additions and 2 deletions

View File

@@ -897,7 +897,7 @@ describe('FormBuilderService test suite', () => {
});
it(`should request the ${typeFieldProp} property and set value "dc_type"`, () => {
service.setTypeBindFieldFromConfig();
// This should have been called in the service constructor
expect(configSpy.findByPropertyName).toHaveBeenCalledTimes(1);
expect(configSpy.findByPropertyName).toHaveBeenCalledWith(typeFieldProp);
expect(service.getTypeField()).toEqual('dc_type');

View File

@@ -74,7 +74,7 @@ export class FormBuilderService extends DynamicFormService {
super(componentService, validationService);
this.formModels = new Map();
this.formGroups = new Map();
if (hasValue(configService)) {
if (hasValue(configService) || true) {
this.setTypeBindFieldFromConfig();
} else {
this.typeField = 'dc_type';

View File

@@ -0,0 +1,14 @@
import { createSuccessfulRemoteDataObject$ } from '../remote-data.utils';
import {ConfigurationProperty} from "../../core/shared/configuration-property.model";
export function getMockFindByIdDataService(propertyKey: string, ...values: string[]) {
return jasmine.createSpyObj('findByIdDataService', {
findByPropertyName: createSuccessfulRemoteDataObject$({
... new ConfigurationProperty(),
name: propertyKey,
values: values,
})
})
}