A
A
Alexey Polyakov2017-06-25 09:03:35
Angular
Alexey Polyakov, 2017-06-25 09:03:35

How to correctly test a class in angular?

The question may not be the most important, and many rather pass by, because if it works in the browser window, then it’s okay, but I want to get to the bottom of the truth. In short, there are three components in angular - all are registered, everything works, but ng test swears at the creation of the last component, where the class looks like:

import {Item} from "../item";

@Component({
  selector: 'app-item',
  templateUrl: './item.component.html',
  styleUrls: ['./item.component.sass']
})
export class ItemComponent implements OnInit {

  @Input('item') data : Item;
  @Input('fir') fname : string;

*лишнее убрал
}

And the creation of a component occurs in another component through:
<app-item
     *ngFor="let i of items"
     [item]="i"
     [fir]="fir">
</app-item>

As far as I understand, this component itself does not create anything, because accessing it from the top component in the constructor:
this.items = [
      new Item(" _f1", " _s1"),
      new Item(" _f2", " _s2"),
    ];

or can it somehow artificially write data in the spec file to create a component, or is it not necessary, given that the upper component passes the check with all its initialization?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question