[ADF-673] - text widget value is not updated when the mask is not applied (#1900)

This commit is contained in:
Vito 2017-05-24 07:43:34 -07:00 committed by Eugenio Romano
parent 10b310288a
commit 2b755d7ee4
2 changed files with 32 additions and 0 deletions

View File

@ -70,6 +70,8 @@ export class InputMaskDirective implements OnChanges, ControlValueAccessor {
if (this.inputMask && this.inputMask.mask) { if (this.inputMask && this.inputMask.mask) {
this.maskValue(this.el.nativeElement.value, this.el.nativeElement.selectionStart, this.maskValue(this.el.nativeElement.value, this.el.nativeElement.selectionStart,
this.inputMask.mask, this.inputMask.isReversed, event.keyCode); this.inputMask.mask, this.inputMask.isReversed, event.keyCode);
} else {
this._onChange(this.el.nativeElement.value);
} }
} }

View File

@ -65,6 +65,36 @@ describe('TextWidget', () => {
TestBed.resetTestingModule(); TestBed.resetTestingModule();
}); });
describe('and no mask is configured on text element', () => {
let inputElement: HTMLInputElement;
beforeEach(() => {
textWidget.field = new FormFieldModel(new FormModel({ taskId: 'fake-task-id' }), {
id: 'text-id',
name: 'text-name',
value: '',
type: FormFieldTypes.TEXT,
readOnly: false
});
fixture.detectChanges();
inputElement = <HTMLInputElement>element.querySelector('#text-id');
});
it('should raise ngModelChange event', async(() => {
inputElement.value = 'TEXT';
expect(textWidget.field.value).toBe('');
inputElement.dispatchEvent(new Event('input'));
fixture.whenStable().then(() => {
fixture.detectChanges();
expect(textWidget.field).not.toBeNull();
expect(textWidget.field.value).not.toBeNull();
expect(textWidget.field.value).toBe('TEXT');
});
}));
});
describe('and mask is configured on text element', () => { describe('and mask is configured on text element', () => {
let inputElement: HTMLInputElement; let inputElement: HTMLInputElement;