mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
fix test
This commit is contained in:
+1
-1
@@ -1008,7 +1008,7 @@ describe('DropdownCloudWidgetComponent', () => {
|
||||
widget['setFormControlValue']();
|
||||
|
||||
expect(widget.dropdownControl.setValue).toHaveBeenCalledWith({ id: 'testValueObj', name: 'testValueObjName' }, { emitEvent: false });
|
||||
expect(widget.dropdownControl.value).toEqual({ id: 'testValue', name: '' });
|
||||
expect(widget.dropdownControl.value).toEqual({ id: 'testValueObj', name: 'testValueObjName' });
|
||||
});
|
||||
|
||||
it('should display options persisted from process variable', async () => {
|
||||
|
||||
+5
-1
@@ -195,8 +195,12 @@ export class DropdownCloudWidgetComponent extends WidgetComponent implements OnI
|
||||
}
|
||||
|
||||
private setFormControlValue(): void {
|
||||
if (this.field?.value && typeof this.field?.value === 'object') {
|
||||
if (Array.isArray(this.field.value)) {
|
||||
this.dropdownControl.setValue(this.field?.value, { emitEvent: false });
|
||||
} else if (this.field?.value && typeof this.field?.value === 'object') {
|
||||
this.dropdownControl.setValue({ id: this.field?.value.id, name: this.field?.value.name }, { emitEvent: false });
|
||||
} else if (this.field.value === null) {
|
||||
this.dropdownControl.setValue(this.field?.value, { emitEvent: false });
|
||||
} else {
|
||||
this.dropdownControl.setValue({ id: this.field?.value, name: '' }, { emitEvent: false });
|
||||
}
|
||||
|
||||
+1
-11
@@ -35,7 +35,7 @@ describe('defaultValueValidator', () => {
|
||||
|
||||
it('should return null when a valid option is selected', () => {
|
||||
const validator = defaultValueValidator(mockField);
|
||||
const control = new FormControl('opt_1');
|
||||
const control = new FormControl({ id: 'opt_1' });
|
||||
|
||||
const result = validator(control);
|
||||
|
||||
@@ -59,14 +59,4 @@ describe('defaultValueValidator', () => {
|
||||
|
||||
expect(result).toEqual({ required: true });
|
||||
});
|
||||
|
||||
it('should return null when the field has no options', () => {
|
||||
mockField.options = [];
|
||||
const validator = defaultValueValidator(mockField);
|
||||
const control = new FormControl('opt_1');
|
||||
|
||||
const result = validator(control);
|
||||
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user