Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7bfab3f

Browse files
committed
Add unit tests
1 parent aa37021 commit 7bfab3f

File tree

7 files changed

+41
-41
lines changed

7 files changed

+41
-41
lines changed

‎.gitignore‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ npm-debug.log
3737
yarn-error.log
3838
testem.log
3939
/typings
40-
/.angulardoc.json
4140

4241
# System Files
4342
.DS_Store

‎src/app/app.component.css‎

Whitespace-only changes.

‎src/app/app.component.spec.ts‎

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
1-
import { TestBed, async } from '@angular/core/testing';
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
import { By } from '@angular/platform-browser';
3+
24
import { AppComponent } from './app.component';
5+
import { CesiumDirective } from './cesium.directive';
6+
37
describe('AppComponent', () => {
4-
beforeEach(async(() => {
8+
let component: AppComponent;
9+
let fixture: ComponentFixture<AppComponent>;
10+
11+
beforeEach(() => {
512
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+
});
2728
});

‎src/app/app.component.ts‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ import { Component } from '@angular/core';
22

33
@Component({
44
selector: 'app-root',
5-
templateUrl: './app.component.html',
6-
styleUrls: ['./app.component.css']
5+
template: '<div appCesium></div>'
76
})
8-
export class AppComponent {
9-
title = 'app';
10-
}
7+
export class AppComponent {}

‎src/app/app.module.ts‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
1-
import { BrowserModule } from '@angular/platform-browser';
21
import { NgModule } from '@angular/core';
3-
2+
import{BrowserModule}from'@angular/platform-browser';
43

54
import { AppComponent } from './app.component';
65
import { CesiumDirective } from './cesium.directive';
76

8-
97
@NgModule({
108
declarations: [
119
AppComponent,
1210
CesiumDirective
1311
],
14-
imports: [
15-
BrowserModule
16-
],
17-
providers: [],
12+
imports: [BrowserModule],
1813
bootstrap: [AppComponent]
1914
})
2015
export class AppModule { }

‎src/app/cesium.directive.spec.ts‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
1+
import { TestBed } from '@angular/core/testing';
2+
3+
import { AppComponent } from './app.component';
14
import { CesiumDirective } from './cesium.directive';
25

36
describe('CesiumDirective', () => {
4-
it('should create an instance', () => {
5-
const directive = new CesiumDirective();
6-
expect(directive).toBeTruthy();
7+
it('should create a Cesium viewer', () => {
8+
const spy = spyOn(window['Cesium'], 'Viewer');
9+
const fixture = TestBed.configureTestingModule({
10+
declarations: [
11+
AppComponent,
12+
CesiumDirective
13+
]
14+
}).createComponent(AppComponent);
15+
fixture.detectChanges();
16+
expect(spy.calls.any()).toBe(true);
717
});
818
});

‎src/app/cesium.directive.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ import { Directive, ElementRef, OnInit } from '@angular/core';
44
selector: '[appCesium]'
55
})
66
export class CesiumDirective implements OnInit {
7-
87
constructor(private el: ElementRef) {}
98

109
ngOnInit() {
1110
const viewer = new Cesium.Viewer(this.el.nativeElement);
1211
}
13-
1412
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /