Как выполнить модульное тестирование сетки Kendo UI в угловых 8,0? - PullRequest
0 голосов
/ 22 октября 2019

Как пройти тест жасминовой кармы для сетки пользовательского интерфейса кендо, используя угловой 8.0. Я включил код. Я передал данные до сих пор сетка не связана с данными. Может кто-нибудь помочь мне узнать?

Проверьте код, который я сделал. Я пытался передать данные в сетку кендо, но она еще не заполнена. Есть ли другой способ связать данные. Я хотел пройти тест на то, что в кендо есть данные или нет.

<kendo-grid   [kendoGridBinding]="gridData" [selectable]="selectableSettings"
[kendoGridSelectBy]="'productPackageId'" 
  (selectedKeysChange)="selectedKeysChange($event)" id="relatedGrid">
    <kendo-grid-checkbox-column width="60"></kendo-grid-checkbox-column>
    <kendo-grid-column field="productPackageId" title="Pkg Id" width="100"></kendo-grid-column>
    <kendo-grid-column field="source" title="Source" width="100"></kendo-grid-column>
    <kendo-grid-column field="circuitId" title="Circuit Id" width="100"></kendo-grid-column>
    <kendo-grid-column field="location" title="Location" width="220"></kendo-grid-column>
    <kendo-grid-column field="bandwidth" title="Bandwidth" width="100"></kendo-grid-column>
    <kendo-grid-column field="term" title="Term" width="80"></kendo-grid-column>
    <kendo-grid-column field="packageName" title="Package Name" width="180"></kendo-grid-column>
    <kendo-grid-column field="swiftStatus" title="Swift Status" width="100"></kendo-grid-column>
    <kendo-grid-column field="ban" title="Ban" width="100"></kendo-grid-column>
    <kendo-grid-column field="networkStatus" title="Pkg Network Status" width="150"></kendo-grid-column>
    <kendo-grid-column field="arrangementName" title="Arrangement Name" width="150"></kendo-grid-column>
</kendo-grid>
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { HttpClientModule } from '@angular/common/http';

import { RelatedProductGridComponent } from './related-product-grid.component';
import { GridModule } from '@progress/kendo-angular-grid';
import { DialogsModule } from '@progress/kendo-angular-dialog';
import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA } from '@angular/core';

describe('RelatedProductGridComponent', () => {
  let component: RelatedProductGridComponent;
  let fixture: ComponentFixture<RelatedProductGridComponent>;
  const compiled = (): any => fixture.debugElement.nativeElement;
  function refreshFixture(): any[] {
   return [
      {
        source: 'Scenario',
        productPackageId: 441688616,
        circuitId: null,
        location: '60 HUDSON STREET NEW YORK, NEW YORK 10013',
        bandwidth: 'Fast E',
        term: '36',
        packageName: 'Dedicated Internet Access',
        swiftStatus: 'Pending',
        ban: null,
        networkStatus: 'On Net',
        arrangementName: null,
        isSearchComplete: false,
        errorMessage: null,
        group: '123-24545-64565464',
        relationshipName: 'A LOC Uni'
      },
      {
        source: 'Scenario',
        productPackageId: 441688617,
        circuitId: null,
        location: '6000 technology',
        bandwidth: 'Fast F',
        term: '12',
        packageName: 'Dedicated Internet Access',
        swiftStatus: 'Pending',
        ban: null,
        networkStatus: 'On Net',
        arrangementName: null,
        isSearchComplete: false,
        errorMessage: null,
        group: '123-24545-64565464',
        relationshipName: 'A LOC Uni'
      },
      {
        source: 'Scenario',
        productPackageId: 441688618,
        circuitId: null,
        location: '8332 erickson blvd',
        bandwidth: 'Fast G',
        term: '30',
        packageName: 'Dedicated Internet Access',
        swiftStatus: 'Pending',
        ban: null,
        networkStatus: 'On Net',
        arrangementName: null,
        isSearchComplete: false,
        errorMessage: null,
        group: '123-24545-64565464',
        relationshipName: 'A LOC Uni'
      },
      {
        source: 'Scenario',
        productPackageId: 441688619,
        circuitId: null,
        location: '60 HUDSON STREET NEW YORK, NEW YORK 10013',
        bandwidth: 'Fast E',
        term: '36',
        packageName: 'Dedicated Internet Access',
        swiftStatus: 'Pending',
        ban: null,
        networkStatus: 'On Net',
        arrangementName: null,
        isSearchComplete: false,
        errorMessage: null,
        group: '123-24545-64565464',
        relationshipName: 'A LOC Uni'
      },
      {
        source: 'Scenario',
        productPackageId: 441688620,
        circuitId: null,
        location: '6000 technology',
        bandwidth: 'Fast F',
        term: '12',
        packageName: 'Dedicated Internet Access',
        swiftStatus: 'Pending',
        ban: null,
        networkStatus: 'On Net',
        arrangementName: null,
        isSearchComplete: false,
        errorMessage: null,
        group: '123-24545-64565464',
        relationshipName: 'A LOC Uni'
      },
      {
        source: 'Scenario',
        productPackageId: 441688621,
        circuitId: null,
        location: '8332 erickson blvd',
        bandwidth: 'Fast G',
        term: '30',
        packageName: 'Dedicated Internet Access',
        swiftStatus: 'Pending',
        ban: null,
        networkStatus: 'On Net',
        arrangementName: null,
        isSearchComplete: false,
        errorMessage: null,
        group: '123-24545-64565464',
        relationshipName: 'A LOC Uni'
      },
      {
        source: 'Scenario',
        productPackageId: 441688622,
        circuitId: null,
        location: '60 HUDSON STREET NEW YORK, NEW YORK 10013',
        bandwidth: 'Fast E',
        term: '36',
        packageName: 'Dedicated Internet Access',
        swiftStatus: 'Pending',
        ban: null,
        networkStatus: 'On Net',
        arrangementName: null,
        isSearchComplete: false,
        errorMessage: null,
        group: '123-24545-64565464',
        relationshipName: 'A LOC Uni'
      },
      {
        source: 'Scenario',
        productPackageId: 441688623,
        circuitId: null,
        location: '6000 technology',
        bandwidth: 'Fast F',
        term: '12',
        packageName: 'Dedicated Internet Access',
        swiftStatus: 'Pending',
        ban: null,
        networkStatus: 'On Net',
        arrangementName: null,
        isSearchComplete: false,
        errorMessage: null,
        group: '123-24545-64565464',
        relationshipName: 'A LOC Uni'
      },
      {
        source: 'Scenario',
        productPackageId: 441688624,
        circuitId: null,
        location: '8332 erickson blvd',
        bandwidth: 'Fast G',
        term: '30',
        packageName: 'Dedicated Internet Access',
        swiftStatus: 'Pending',
        ban: null,
        networkStatus: 'On Net',
        arrangementName: null,
        isSearchComplete: false,
        errorMessage: null,
        group: '123-24545-64565464',
        relationshipName: 'A LOC Uni'
      },
      {
        source: 'Scenario',
        productPackageId: 441688625,
        circuitId: null,
        location: '60 HUDSON STREET NEW YORK, NEW YORK 10013',
        bandwidth: 'Fast E',
        term: '36',
        packageName: 'Dedicated Internet Access',
        swiftStatus: 'Pending',
        ban: null,
        networkStatus: 'On Net',
        arrangementName: null,
        isSearchComplete: false,
        errorMessage: null,
        group: '123-24545-64565464',
        relationshipName: 'A LOC Uni'
      },
      {
        source: 'Scenario',
        productPackageId: 441688626,
        circuitId: null,
        location: '6000 technology',
        bandwidth: 'Fast F',
        term: '12',
        packageName: 'Dedicated Internet Access',
        swiftStatus: 'Pending',
        ban: null,
        networkStatus: 'On Net',
        arrangementName: null,
        isSearchComplete: false,
        errorMessage: null,
        group: '123-24545-64565464',
        relationshipName: 'A LOC Uni'
      },
      {
        source: 'Scenario',
        productPackageId: 441688627,
        circuitId: null,
        location: '8332 erickson blvd',
        bandwidth: 'Fast G',
        term: '30',
        packageName: 'Dedicated Internet Access',
        swiftStatus: 'Pending',
        ban: null,
        networkStatus: 'On Net',
        arrangementName: null,
        isSearchComplete: false,
        errorMessage: null,
        group: '123-24545-64565464',
        relationshipName: 'A LOC Uni'
      },
      {
        source: 'Scenario',
        productPackageId: 441688628,
        circuitId: null,
        location: '60 HUDSON STREET NEW YORK, NEW YORK 10013',
        bandwidth: 'Fast E',
        term: '36',
        packageName: 'Dedicated Internet Access',
        swiftStatus: 'Pending',
        ban: null,
        networkStatus: 'On Net',
        arrangementName: null,
        isSearchComplete: false,
        errorMessage: null,
        group: '123-24545-64565464',
        relationshipName: 'A LOC Uni'
      },
      {
        source: 'Scenario',
        productPackageId: 441688629,
        circuitId: null,
        location: '6000 technology',
        bandwidth: 'Fast F',
        term: '12',
        packageName: 'Dedicated Internet Access',
        swiftStatus: 'Pending',
        ban: null,
        networkStatus: 'On Net',
        arrangementName: null,
        isSearchComplete: false,
        errorMessage: null,
        group: '123-24545-64565464',
        relationshipName: 'A LOC Uni'
      },
      {
        source: 'Scenario',
        productPackageId: 441688630,
        circuitId: null,
        location: '8332 erickson blvd',
        bandwidth: 'Fast G',
        term: '30',
        packageName: 'Dedicated Internet Access',
        swiftStatus: 'Pending',
        ban: null,
        networkStatus: 'On Net',
        arrangementName: null,
        isSearchComplete: false,
        errorMessage: null,
        group: '123-24545-64565464',
        relationshipName: 'A LOC Uni'
      }
    ];

  }
  beforeEach(async(() => {
    TestBed.configureTestingModule({
      imports: [HttpClientModule, FormsModule, ReactiveFormsModule, GridModule, DialogsModule],
      declarations: [ RelatedProductGridComponent ],
      schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA]
    })
    .compileComponents();
  }));

  beforeEach(() => {
    fixture = TestBed.createComponent(RelatedProductGridComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();
  });

  it('should create', () => {
    component.gridData = refreshFixture();
    expect(component).toBeTruthy();
  });

  it('should render packageName', () => {
    expect(compiled().querySelector('#pckName')).not.toBeNull();
  });

 it('should render grid', () => {
    component.gridData = refreshFixture();
    expect(compiled().querySelector('#relatedGrid>tbody>tr')).not.toBeNull();
  });

});
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...