|
| 1 | +/* tslint:disable:no-unused-variable */ |
| 2 | + |
| 3 | +import { RouterTestingModule } from '@angular/router/testing'; |
| 4 | +import { HttpClientModule } from '@angular/common/http'; |
| 5 | +import { NO_ERRORS_SCHEMA, QueryList, SecurityContext } from '@angular/core'; |
| 6 | +import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; |
| 7 | +import { DataTableDirective, DataTablesModule } from 'angular-datatables'; |
| 8 | +import { MarkdownModule } from 'ngx-markdown'; |
| 9 | +import { BaseDemoComponent } from '../base-demo/base-demo.component'; |
| 10 | +import { AppRoutingModule } from '../app.routing'; |
| 11 | +import { By } from '@angular/platform-browser'; |
| 12 | +import { FormsModule } from '@angular/forms'; |
| 13 | +import { MultipleTablesComponent } from './multiple-tables.component'; |
| 14 | + |
| 15 | + |
| 16 | +let fixture: ComponentFixture<MultipleTablesComponent>, component: MultipleTablesComponent = null; |
| 17 | + |
| 18 | +describe('MultipleTablesComponent', () => { |
| 19 | + beforeEach(() => { |
| 20 | + fixture = TestBed.configureTestingModule({ |
| 21 | + declarations: [ |
| 22 | + BaseDemoComponent, |
| 23 | + MultipleTablesComponent, |
| 24 | + DataTableDirective |
| 25 | + ], |
| 26 | + imports: [ |
| 27 | + AppRoutingModule, |
| 28 | + RouterTestingModule, |
| 29 | + DataTablesModule.forRoot(), |
| 30 | + HttpClientModule, |
| 31 | + MarkdownModule.forRoot( |
| 32 | + { |
| 33 | + sanitize: SecurityContext.NONE |
| 34 | + } |
| 35 | + ), |
| 36 | + FormsModule |
| 37 | + ], |
| 38 | + schemas: [NO_ERRORS_SCHEMA] |
| 39 | + }).createComponent(MultipleTablesComponent); |
| 40 | + |
| 41 | + component = fixture.componentInstance; |
| 42 | + |
| 43 | + fixture.detectChanges(); // initial binding |
| 44 | + }); |
| 45 | + |
| 46 | + it('should create the app', waitForAsync(() => { |
| 47 | + const app = fixture.debugElement.componentInstance; |
| 48 | + expect(app).toBeTruthy(); |
| 49 | + })); |
| 50 | + |
| 51 | + it('should have title "Multiple DataTables in the same page"', waitForAsync(() => { |
| 52 | + const app = fixture.debugElement.componentInstance as MultipleTablesComponent; |
| 53 | + expect(app.pageTitle).toBe('Multiple DataTables in the same page'); |
| 54 | + })); |
| 55 | + |
| 56 | + it('should have two table instances in dtElements', async () => { |
| 57 | + const app = fixture.componentInstance as MultipleTablesComponent; |
| 58 | + await fixture.whenStable(); |
| 59 | + |
| 60 | + expect(app.dtElements.length).toBe(2); |
| 61 | + }); |
| 62 | + |
| 63 | +}); |
0 commit comments