Skip to content

Commit

Permalink
Merge d3c4222 into 76f9709
Browse files Browse the repository at this point in the history
  • Loading branch information
igortg committed Jan 25, 2019
2 parents 76f9709 + d3c4222 commit cdb9e43
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/ng-xform/measure-field/measure-field.component.spec.ts
Expand Up @@ -65,24 +65,24 @@ describe('MeasureFieldComponent', () => {

inputEl.nativeElement.value = newValueString;
inputEl.nativeElement.dispatchEvent(new Event('input'));
expect(component.control.value).toEqual(new Measure(15, 'm'));
expect(component.formattedValue).toEqual('15 m');

component.changeUnit('cm');
expect(component.viewModel).toEqual(1500);
expect(component.viewUnit).toEqual('cm');
expect(component.control.value).toEqual(new Measure(15, 'm'));
expect(component.formattedValue).toEqual('1500 cm');

component.changeUnit('');
expect(component.viewModel).toEqual(15);
expect(component.viewUnit).toEqual('m');
expect(component.control.value).toEqual(new Measure(15, 'm'));
expect(component.formattedValue).toEqual('15 m');

component.field.modelUnit = 'inch';
fixture.detectChanges();
component.ngOnInit();
inputEl.nativeElement.value = newValueString;
inputEl.nativeElement.dispatchEvent(new Event('input'));
expect(component.control.value).toEqual(new Measure(15, 'inch'));
expect(component.formattedValue).toEqual('15 inch');
});

it('should show unit and units dropdown', () => {
Expand Down
3 changes: 1 addition & 2 deletions src/ng-xform/measure-field/measure-field.component.ts
Expand Up @@ -69,8 +69,7 @@ export class MeasureFieldComponent extends BaseDynamicFieldComponent<MeasureFiel
this.field.modelUnit
);
}

this.control.setValue(newValue, { emitModelToViewChange: false });
this.updateInputValue();
this._onChange(newValue);
}

Expand Down

0 comments on commit cdb9e43

Please sign in to comment.