Skip to content

Commit 997b472

Browse files
committed
Add a test for a single http request
1 parent 239533a commit 997b472

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/app/spinner/spinner.component.spec.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,19 @@ describe('SpinnerComponent', () => {
117117
expect(component.isSpinnerVisible).toBeFalsy();
118118
})
119119
);
120+
121+
it('should hide and show a the spinner for a single http request',
122+
inject([HttpInterceptorService, MockBackend], (service: HttpInterceptorService, backend: MockBackend) => {
123+
let connection: MockConnection;
124+
const responseMock = {key: 'value'},
125+
mockResponse: Response = new Response(new ResponseOptions({body: responseMock, status: 200}));
126+
127+
backend.connections.subscribe((c: MockConnection) => connection = c);
128+
service.get('http://www.fake.url').subscribe();
129+
expect(component.isSpinnerVisible).toBeTruthy();
130+
connection.mockRespond(mockResponse);
131+
expect(component.isSpinnerVisible).toBeFalsy();
132+
133+
})
134+
);
120135
});

0 commit comments

Comments
 (0)