I am writing tests for our component, everything was working fine, until I started testing integration of the template with formControls. I am using same concept as Angular team in their test do. (https://github.com/angular/angular/blob/master/packages/forms/test/reactive_integration_spec.ts)
Anyway, I am struggling with Error: Expected 'John' to equal 'Thomas' in the last expect. Here is my code:
it('should change formControl value when value inside the input is changed', () => {
hostComponent.formConfig = {mode: 'write'};
const control = component.updateForm.get('surName');
hostFixture.detectChanges();
// model -> view
const input = hostFixture.debugElement.query(By.css('#surName'));
const element = input.nativeElement as HTMLInputElement;
expect(element.value).toEqual('John');
element.value = 'Thomas';
element.dispatchEvent(new Event('input'));
// view -> model
expect(control.value).toEqual('Thomas'); // This expectation is failing
});
Is anybody here able to help me please? I have tried almost everything and this test is 95% identical to the Angular one.
Aucun commentaire:
Enregistrer un commentaire