Skip to content

Commit ad18d40

Browse files
committed
Cleanup inject functions
1 parent a13cfbb commit ad18d40

File tree

1 file changed

+20
-30
lines changed

1 file changed

+20
-30
lines changed

test/components/spinner/spinner.component.spec.ts

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { SpinnerComponent } from '../../../src/components/spinner/spinner.compon
1212
import { By } from '@angular/platform-browser';
1313
import { Spinkit, SPINKIT_COMPONENTS } from '../../../src/spinkits';
1414
import { Observable } from 'rxjs/Observable';
15-
import { PendingInterceptorService } from '../../../src/services/pending-interceptor.service';
1615
import { HttpClient } from '@angular/common/http';
1716
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
1817
import { NgHttpLoaderServicesModule } from '../../../src/services/ng-http-loader-services.module';
@@ -99,8 +98,7 @@ describe('SpinnerComponent', () => {
9998
});
10099

101100
it('should show and hide the spinner according to the pending http requests', fakeAsync(inject(
102-
[PendingInterceptorService, HttpClient, HttpTestingController],
103-
(service: PendingInterceptorService, http: HttpClient, httpMock: HttpTestingController) => {
101+
[HttpClient, HttpTestingController], (http: HttpClient, httpMock: HttpTestingController) => {
104102

105103
function runQuery(url: string): Observable<any> {
106104
return http.get(url);
@@ -125,8 +123,7 @@ describe('SpinnerComponent', () => {
125123
)));
126124

127125
it('should hide and show a the spinner for a single http request', fakeAsync(inject(
128-
[PendingInterceptorService, HttpClient, HttpTestingController],
129-
(service: PendingInterceptorService, http: HttpClient, httpMock: HttpTestingController) => {
126+
[HttpClient, HttpTestingController], (http: HttpClient, httpMock: HttpTestingController) => {
130127
http.get('/fake').subscribe();
131128

132129
tick();
@@ -139,8 +136,7 @@ describe('SpinnerComponent', () => {
139136
)));
140137

141138
it('should not show the spinner if the request is filtered', fakeAsync(inject(
142-
[PendingInterceptorService, HttpClient, HttpTestingController],
143-
(service: PendingInterceptorService, http: HttpClient, httpMock: HttpTestingController) => {
139+
[HttpClient, HttpTestingController], (http: HttpClient, httpMock: HttpTestingController) => {
144140
component.filteredUrlPatterns.push('fake');
145141
fixture.detectChanges();
146142

@@ -152,8 +148,7 @@ describe('SpinnerComponent', () => {
152148
)));
153149

154150
it('should take care of query strings in filteredUrlPatterns', fakeAsync(inject(
155-
[PendingInterceptorService, HttpClient, HttpTestingController],
156-
(service: PendingInterceptorService, http: HttpClient, httpMock: HttpTestingController) => {
151+
[HttpClient, HttpTestingController], (http: HttpClient, httpMock: HttpTestingController) => {
157152
component.filteredUrlPatterns.push('bar');
158153
fixture.detectChanges();
159154

@@ -172,8 +167,7 @@ describe('SpinnerComponent', () => {
172167
)));
173168

174169
it('should correctly filter with several requests and one pattern', fakeAsync(inject(
175-
[PendingInterceptorService, HttpClient, HttpTestingController],
176-
(service: PendingInterceptorService, http: HttpClient, httpMock: HttpTestingController) => {
170+
[HttpClient, HttpTestingController], (http: HttpClient, httpMock: HttpTestingController) => {
177171
component.filteredUrlPatterns.push('\\d');
178172
fixture.detectChanges();
179173

@@ -197,28 +191,25 @@ describe('SpinnerComponent', () => {
197191
expect(() => fixture.detectChanges()).toThrow(new Error('`filteredUrlPatterns` must be an array.'));
198192
});
199193

200-
it('should show the spinner even if the component is created after the http request is performed',
201-
fakeAsync(inject([PendingInterceptorService, HttpClient, HttpTestingController],
202-
(service: PendingInterceptorService, http: HttpClient, httpMock: HttpTestingController) => {
203-
http.get('/fake').subscribe();
194+
it('should show the spinner even if the component is created after the http request is performed', fakeAsync(inject(
195+
[HttpClient, HttpTestingController], (http: HttpClient, httpMock: HttpTestingController) => {
196+
http.get('/fake').subscribe();
204197

205-
const newFixture = TestBed.createComponent(SpinnerComponent);
206-
const newComponent = newFixture.componentInstance;
198+
const newFixture = TestBed.createComponent(SpinnerComponent);
199+
const newComponent = newFixture.componentInstance;
207200

208-
tick();
209-
expect(newComponent.isSpinnerVisible).toBeTruthy();
210-
httpMock.expectOne('/fake').flush({});
201+
tick();
202+
expect(newComponent.isSpinnerVisible).toBeTruthy();
203+
httpMock.expectOne('/fake').flush({});
211204

212-
tick();
213-
expect(newComponent.isSpinnerVisible).toBeFalsy();
214-
httpMock.verify();
215-
}
216-
))
217-
);
205+
tick();
206+
expect(newComponent.isSpinnerVisible).toBeFalsy();
207+
httpMock.verify();
208+
}
209+
)));
218210

219211
it('should correctly handle the debounce delay for a single http request', fakeAsync(inject(
220-
[PendingInterceptorService, HttpClient, HttpTestingController],
221-
(service: PendingInterceptorService, http: HttpClient, httpMock: HttpTestingController) => {
212+
[HttpClient, HttpTestingController], (http: HttpClient, httpMock: HttpTestingController) => {
222213
component.debounceDelay = 2000;
223214
http.get('/fake').subscribe();
224215

@@ -249,8 +240,7 @@ describe('SpinnerComponent', () => {
249240
)));
250241

251242
it('should correctly handle the debounce delay for multiple http requests', fakeAsync(inject(
252-
[PendingInterceptorService, HttpClient, HttpTestingController],
253-
(service: PendingInterceptorService, http: HttpClient, httpMock: HttpTestingController) => {
243+
[HttpClient, HttpTestingController], (http: HttpClient, httpMock: HttpTestingController) => {
254244
component.debounceDelay = 2000;
255245

256246
function runQuery(url: string): Observable<any> {

0 commit comments

Comments
 (0)