-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.component.spec.ts
35 lines (27 loc) · 1.06 KB
/
app.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
import { async, fakeAsync, TestBed, tick } from '@angular/core/testing';
import { Subject } from 'rxjs/Subject';
import { AppComponent } from './app.component';
import { SomeService } from './some.service';
describe('AppComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [AppComponent],
providers: [SomeService]
});
}));
it('should display a spinner after 300 ms until instant is available', fakeAsync(() => {
const someService = TestBed.get(SomeService);
const subject = new Subject<string>();
spyOn(someService, 'getFoo').and.returnValue(subject);
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
tick();
expect(fixture.nativeElement.querySelector('.spinner')).toBeFalsy();
tick(350);
fixture.detectChanges();
expect(fixture.nativeElement.querySelector('.spinner')).toBeTruthy();
subject.next('2017-08-09T12:00:00.000Z');
fixture.detectChanges();
expect(fixture.nativeElement.querySelector('.spinner')).toBeFalsy();
}));
});