mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-1997] override custom form widgets by default (#3346)
* override custom form widgets by default * update tests
This commit is contained in:
committed by
Eugenio Romano
parent
ace38942af
commit
592ad185e7
@@ -85,11 +85,12 @@ describe('FormRenderingService', () => {
|
||||
).toThrowError('resolver is null or not defined');
|
||||
});
|
||||
|
||||
it('should fail overriding existing resolver without explicit flag', () => {
|
||||
it('should fail overriding existing resolver with explicit flag', () => {
|
||||
expect(
|
||||
() => service.setComponentTypeResolver(
|
||||
FormFieldTypes.TEXT,
|
||||
DynamicComponentResolver.fromType(UnknownWidgetComponent)
|
||||
DynamicComponentResolver.fromType(UnknownWidgetComponent),
|
||||
false
|
||||
)
|
||||
).toThrowError('already mapped, use override option if you intend replacing existing mapping.');
|
||||
});
|
||||
@@ -100,6 +101,12 @@ describe('FormRenderingService', () => {
|
||||
expect(service.getComponentTypeResolver(FormFieldTypes.TEXT)).toBe(customResolver);
|
||||
});
|
||||
|
||||
it('should override existing resolver without explicit flag', () => {
|
||||
let customResolver = DynamicComponentResolver.fromType(UnknownWidgetComponent);
|
||||
service.setComponentTypeResolver(FormFieldTypes.TEXT, customResolver);
|
||||
expect(service.getComponentTypeResolver(FormFieldTypes.TEXT)).toBe(customResolver);
|
||||
});
|
||||
|
||||
it('should return default value when resolving with no field', () => {
|
||||
expect(service.resolveComponentType(null)).toBe(UnknownWidgetComponent);
|
||||
});
|
||||
|
@@ -50,7 +50,7 @@ export abstract class DynamicComponentMapper {
|
||||
* @param resolver The new resolver function
|
||||
* @param override The new resolver will only replace an existing one if this parameter is true
|
||||
*/
|
||||
setComponentTypeResolver(type: string, resolver: DynamicComponentResolveFunction, override: boolean = false) {
|
||||
setComponentTypeResolver(type: string, resolver: DynamicComponentResolveFunction, override: boolean = true) {
|
||||
if (!type) {
|
||||
throw new Error(`type is null or not defined`);
|
||||
}
|
||||
|
Reference in New Issue
Block a user