title: angular2 unit test pass data to input from spec
body: <p>I have declared a component like this</p>
  
  <pre><code>export class Component {
  
    private selectedFieldType: string;
    private enableAddCheck: boolean = false;
  
    @Input('itemX') item;
  }
  </code></pre>
  
  <p>and i have a html for two binding like this</p>
  
  <pre><code>Field : &lt;input [(ngModel)]="item.fieldLabel" type="text" class="input-bars"&gt;
  </code></pre>
  
  <p>So i have created the unit testing code like this to check the two way binding like this</p>
  
  <pre><code>beforeEach(async(() =&gt; {
  
  
      // refine the test module by declaring the test component
      TestBed.configureTestingModule({
        imports: [ FormsModule ],
        declarations: [Component , DND_DIRECTIVES],
        schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA],
        providers: [
          { provide: ComponentFixtureAutoDetect, useValue: true },
           DND_PROVIDERS ]
      })
  
      // create component and test fixture
      fixture = TestBed.createComponent(Component );
  
      // get test component from the fixture
      comp = fixture.componentInstance;
  
  
  
    }));
  
    it('To check fieldLabel to way binding from inputbox to data', () =&gt; {
  
      comp.item = {
        fieldLabel: 'text'
      };
  
  
      fixture.detectChanges();
  
      let fieldTypeInput: HTMLInputElement;
  
      const input = fixture.debugElement.query(By.css('input'));
  
      fieldTypeInput = input[0].nativeElement;
      fieldTypeInput.value = 'field';
  
      fixture.detectChanges();
  
      expect(comp.item.fieldLabel).toBe('field');
  
    });
  </code></pre>
  
  <p>But it's giving 'fieldLabel' undefined error for me.</p>
  
  <p>How to pass the data to @input in my component through the unit test??</p>