title: Angular Unit Testing using Mock Models
body: <p>I am trying to unit test a component. I need to set a variable on that component to an instance of PolicyMock, which is a mock I created from a model. </p>
  
  <p>Example of Policy (real model)</p>
  
  <pre><code>export class Policy {
  
      businessArea: BusinessArea;
      statusCode: number;
      submittedStatus: SubmittedStatus;
      // ...
  }
  </code></pre>
  
  <p>Example of the model I made, PolicyMock:</p>
  
  <pre><code>export class PolicyMock extends Policy {
      businessArea: 2;
      statusCode: -1;
      submittedStatus: 1;
      // ...
  }
  </code></pre>
  
  <p>Now, I am not used to this heavy Object Oriented programming, I come from Javascript and React mainly. So it is likely some lack of understanding on my part, but when I try to set the variable in the component to an instance of my Mock model and console out those results I get this instead of the actual values within the class: </p>
  
  <pre><code>[PolicyMock{}]
  </code></pre>
  
  <p>Here is how I am trying to get set the variable (it's a private method so I am using the escape hatch syntax)</p>
  
  <pre><code>let cp: DataTableComponent&lt;Policy&gt;;
  cp = new DataTableComponent&lt;Policy&gt;(sanitize, ref);
  cp['data'] = [new PolicyMock()];
  console.log(cp['data']);
  </code></pre>
  
  <p>I've also tried setting cp['data'] as an empty array intially and pushing the instance to it but that yielded the same result.</p>
  
  <p>Any help would be appreciated!</p>