UNPKG

bixi

Version:

企业级中后台前端解决方案

64 lines (55 loc) 1.55 kB
import { ComponentFixture, TestBed } from '@angular/core/testing'; import { Component, DebugElement } from '@angular/core'; import { BixiTableModule, ICols } from '@bixi/core/table'; import { BrowserAnimationsModule, NoopAnimationsModule } from '@angular/platform-browser/animations'; import { NzToolTipModule } from 'ng-zorro-antd/tooltip'; import { NzTableModule, NzTableSortersComponent } from 'ng-zorro-antd/table'; import { By } from '@angular/platform-browser'; describe('col sort', () => { let fixture: ComponentFixture<TestComponent>; let context: TestComponent; let debugEle: DebugElement; beforeEach(async () => { TestBed.configureTestingModule({ imports: [BixiTableModule, BrowserAnimationsModule, NzToolTipModule, NoopAnimationsModule, NzTableModule], declarations: [TestComponent] }); fixture = TestBed.createComponent(TestComponent); context = fixture.componentInstance; debugEle = fixture.debugElement; }); it('should init', () => { // given context.cols = [ { name: '年龄', key: 'age', sort: { key: 'age' } } ]; // when fixture.detectChanges(); // then const triggerEl = debugEle.query(By.directive(NzTableSortersComponent)); expect(triggerEl).toBeTruthy(); }); }); const rows = [{ name: '小明', info: { age: 12 } }]; @Component({ template: ` <bixi-table [rows]="rows" [cols]="cols" ></bixi-table>` }) class TestComponent { rows = rows; cols: ICols = []; }