单元测试包含[virtualScroll]属性

时间:2018-03-09 14:01:38

标签: ionic-framework jasmine ionic3 karma-runner karma-jasmine

我想知道如何确保ion-list显示正确的内容。

ion-list看起来像这样:

<ion-list [virtualScroll]="list" [approxItemHeight]="'132px'">
  <ion-item *virtualItem="let item">
    <span item-start>{{item.foo}}</span>
  </ion-item>
</ion-list>

单元测试:

it('should display the correct content', () => {
  comp.list = [ { foo: 'bar' } ];
  fixture.detectChanges();

  de = fixture.debugElement.query(By.css('ion-content'));
  el = de.nativeElement;

  console.log(el);
});

输出:

<ion-list class="list list-md virtual-loading" ng-reflect-virtual-scroll="[object Object],[object Object" ng-reflect-approx-item-height="132px">
    <!---->
</ion-list>

如何触发业力在ion-item中呈现ion-list

1 个答案:

答案 0 :(得分:0)

您已经在测试中手动发出了更新事件:

const virtualScrollComponent = fixture.debugElement.query(By.directive(VirtualScrollComponent)).componentInstance;
virtualScrollComponent.update.emit(list);