title: Karma Input parameter unit testing
body: <p>I'm having problems with unit testing in angular 6. I'm trying to test a simple component with one <code>input()</code> parameter. The problem was that I don't know how to continue. I receive an error when executing <code>ng test</code> :</p>
  
  <blockquote>
    <p>TypeError: Cannot read property 'id_profile' of undefined</p>
  </blockquote>
  
  <p>My code is this: </p>
  
  <blockquote>
    <p>Model </p>
  </blockquote>
  
  <pre><code>export class Profile {    
    id_profile: string;
    name: string;
  }
  </code></pre>
  
  <blockquote>
    <p>html</p>
  </blockquote>
  
  <pre><code>&lt;div class="card" (click)="clicked()"&gt;
      &lt;div id="profile"&gt;{{profile.id_profile}}&lt;/div&gt;
      &lt;i class="material-icons"&gt;vpn_key&lt;/i&gt;
  &lt;/div&gt;
  </code></pre>
  
  <blockquote>
    <p>component</p>
  </blockquote>
  
  <pre><code>import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
  import { Router } from '@angular/router';    
  import { Profile } from 'app/models';
  
  
  @Component({
    selector: 'app-profile',
    templateUrl: './profile.component.html',
    styleUrls: ['./profile.component.scss']
  })
  
  export class ProfileComponent {
  
    @Input() profile: Profile;
  
    private profileShown: Profile;
  
    constructor(public router: Router) {
    }
  
    OnInit() {
      this.profileShown= this.profile;
    }
  
    clicked() {
      this.profileShown= this.profile;
      this.router.navigate(['pages']);
    }   
  }
  </code></pre>
  
  <p>And finally, my test :</p>
  
  <pre><code>import { async, ComponentFixture, TestBed } from '@angular/core/testing';
  import { RouterTestingModule } from '@angular/router/testing';
  import { ProfileComponent} from './profile.component';
  
  describe('ProfileComponent', () =&gt; {
    let component: ProfileComponent;
    let fixture: ComponentFixture&lt;ProfileComponent&gt;;
  
    beforeEach(async(() =&gt; {
      TestBed.configureTestingModule({
        imports: [RouterTestingModule],
        declarations: [ProfileComponent]
      })
        .compileComponents();
    }));
  
    beforeEach(() =&gt; {
      fixture = TestBed.createComponent(ProfileComponent);
      component = fixture.componentInstance;
      fixture.detectChanges();
    });
  
    it('should create', () =&gt; {
      component.profile= {
        'id_profile': '12345678A',
        'name': 'SUMUM_D',      
      };
      fixture.detectChanges();
      expect(component).toBeTruthy();
    });
  });
  </code></pre>
  
  <p>What I have to do to solve this problem? Am I doing the correct things? Thanks in advance</p>