-
Notifications
You must be signed in to change notification settings - Fork 112
/
async-stream.component.spec.ts
42 lines (35 loc) · 1.16 KB
/
async-stream.component.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/* tslint:disable:no-unused-variable */
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { Subject } from 'rxjs/Subject';
import { AsyncComponent } from './async-stream.component';
describe('Async Compnent', () => {
let component: AsyncComponent;
let fixture: ComponentFixture<AsyncComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [AsyncComponent]
});
}));
beforeEach(() => {
fixture = TestBed.createComponent(AsyncComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
it('should correctly visualize the emitted values from the stream', () => {
const stream = new Subject<string>();
component.personName = stream.asObservable();
fixture.detectChanges();
expect(
fixture.debugElement.query(By.css('div')).nativeElement.innerHTML
).toBe('');
stream.next('Hi');
fixture.detectChanges();
expect(
fixture.debugElement.query(By.css('div')).nativeElement.innerHTML
).toBe('Hi');
});
});