|
1 | | -import { TestBed, async } from '@angular/core/testing'; |
| 1 | +import { ComponentFixture, TestBed } from '@angular/core/testing'; |
| 2 | +import { By } from '@angular/platform-browser'; |
| 3 | + |
2 | 4 | import { AppComponent } from './app.component'; |
| 5 | +import { CesiumDirective } from './cesium.directive'; |
| 6 | + |
3 | 7 | describe('AppComponent', () => { |
4 | | - beforeEach(async(() => { |
| 8 | + let component: AppComponent; |
| 9 | + let fixture: ComponentFixture<AppComponent>; |
| 10 | + |
| 11 | + beforeEach(() => { |
5 | 12 | TestBed.configureTestingModule({ |
6 | | - declarations: [ |
7 | | - AppComponent |
8 | | - ], |
9 | | - }).compileComponents(); |
10 | | - })); |
11 | | - it('should create the app', async(() => { |
12 | | - const fixture = TestBed.createComponent(AppComponent); |
13 | | - const app = fixture.debugElement.componentInstance; |
14 | | - expect(app).toBeTruthy(); |
15 | | - })); |
16 | | - it(`should have as title 'app'`, async(() => { |
17 | | - const fixture = TestBed.createComponent(AppComponent); |
18 | | - const app = fixture.debugElement.componentInstance; |
19 | | - expect(app.title).toEqual('app'); |
20 | | - })); |
21 | | - it('should render title in a h1 tag', async(() => { |
22 | | - const fixture = TestBed.createComponent(AppComponent); |
23 | | - fixture.detectChanges(); |
24 | | - const compiled = fixture.debugElement.nativeElement; |
25 | | - expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!'); |
26 | | - })); |
| 13 | + declarations: [AppComponent] |
| 14 | + }); |
| 15 | + |
| 16 | + fixture = TestBed.createComponent(AppComponent); |
| 17 | + component = fixture.componentInstance; |
| 18 | + }); |
| 19 | + |
| 20 | + it('should create', () => { |
| 21 | + expect(component).toBeDefined(); |
| 22 | + }); |
| 23 | + |
| 24 | + it('should have a Cesium element', () => { |
| 25 | + const de = fixture.debugElement.query(By.directive(CesiumDirective)); |
| 26 | + expect(de).toBeDefined(); |
| 27 | + }); |
27 | 28 | }); |
0 commit comments