Skip to content

Commit 95972fb

Browse files
committed
Sanitize test suite
1 parent e1ec863 commit 95972fb

File tree

5 files changed

+629
-691
lines changed

5 files changed

+629
-691
lines changed

src/test/components/ng-http-loader.component.on-push.spec.ts

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import { HttpClient } from '@angular/common/http';
1111
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
1212
import { ChangeDetectionStrategy, Component } from '@angular/core';
13-
import { async, ComponentFixture, fakeAsync, inject, TestBed, tick } from '@angular/core/testing';
13+
import { async, ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
1414
import { By } from '@angular/platform-browser';
1515
import { NgHttpLoaderModule } from '../../lib/ng-http-loader.module';
1616

@@ -24,6 +24,8 @@ export class HostComponent {
2424
describe('NgHttpLoaderComponent OnPush', () => {
2525
let component: HostComponent;
2626
let fixture: ComponentFixture<HostComponent>;
27+
let http: HttpClient;
28+
let httpMock: HttpTestingController;
2729

2830
beforeEach(async(() => {
2931
TestBed.configureTestingModule({
@@ -36,27 +38,27 @@ describe('NgHttpLoaderComponent OnPush', () => {
3638
beforeEach(() => {
3739
fixture = TestBed.createComponent(HostComponent);
3840
component = fixture.componentInstance;
41+
http = TestBed.get(HttpClient);
42+
httpMock = TestBed.get(HttpTestingController);
3943
});
4044

41-
it('should work as expected when the host component has ChangeDetectionStrategy.OnPush', fakeAsync(inject(
42-
[HttpClient, HttpTestingController], (http: HttpClient, httpMock: HttpTestingController) => {
43-
http.get('/fake').subscribe();
44-
tick();
45-
fixture.detectChanges();
46-
let spinner = fixture
47-
.debugElement
48-
.query(By.css('#spinner'))
49-
.nativeElement;
50-
expect(spinner).toBeTruthy();
51-
52-
httpMock.expectOne('/fake').flush({});
53-
tick();
54-
fixture.detectChanges();
55-
56-
spinner = fixture
57-
.debugElement
58-
.query(By.css('#spinner'));
59-
expect(spinner).toBeNull();
60-
}
61-
)));
45+
it('should work as expected when the host component has ChangeDetectionStrategy.OnPush', fakeAsync(() => {
46+
http.get('/fake').subscribe();
47+
tick();
48+
fixture.detectChanges();
49+
let spinner = fixture
50+
.debugElement
51+
.query(By.css('#spinner'))
52+
.nativeElement;
53+
expect(spinner).toBeTruthy();
54+
55+
httpMock.expectOne('/fake').flush({});
56+
tick();
57+
fixture.detectChanges();
58+
59+
spinner = fixture
60+
.debugElement
61+
.query(By.css('#spinner'));
62+
expect(spinner).toBeNull();
63+
}));
6264
});

src/test/components/ng-http-loader.component.outlet.spec.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@
77
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
88
*/
99

10-
import { HttpClientTestingModule } from '@angular/common/http/testing';
1110
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
1211
import { By } from '@angular/platform-browser';
1312
import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
1413
import { BehaviorSubject } from 'rxjs';
1514
import { NgHttpLoaderComponent } from '../../lib/components/ng-http-loader.component';
1615
import { SkThreeBounceComponent } from '../../lib/components/sk-three-bounce/sk-three-bounce.component';
17-
import { PendingRequestsInterceptorProvider } from '../../lib/services/pending-requests-interceptor.service';
1816
import { SPINKIT_COMPONENTS } from '../../lib/spinkits';
1917

2018
describe('NgHttpLoaderComponentOutlet', () => {
@@ -24,8 +22,6 @@ describe('NgHttpLoaderComponentOutlet', () => {
2422
beforeEach(async(() => {
2523
TestBed.configureTestingModule({
2624
declarations: [NgHttpLoaderComponent, ...SPINKIT_COMPONENTS],
27-
imports: [HttpClientTestingModule],
28-
providers: [PendingRequestsInterceptorProvider]
2925
})
3026
.overrideModule(BrowserDynamicTestingModule, {
3127
set: { entryComponents: [SkThreeBounceComponent] }

0 commit comments

Comments
 (0)