Skip to content

Commit 53875ab

Browse files
committed
Standalone test for observable stream
1 parent 876d922 commit 53875ab

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/app/http-interceptor.service.spec.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
88
*/
99

10-
import { inject, TestBed } from '@angular/core/testing';
10+
import { async, inject, TestBed } from '@angular/core/testing';
1111
import { HttpInterceptorService } from './http-interceptor.service';
1212
import { HttpModule, RequestOptions, Response, ResponseOptions } from '@angular/http';
1313
import { MockBackend, MockConnection } from '@angular/http/testing';
@@ -61,4 +61,18 @@ describe('HttpInterceptorService', () => {
6161
expect(service.pendingRequests).toBe(0);
6262
})
6363
);
64+
65+
it('should correctly notify the pendingRequestsStatus observable', async(
66+
inject([HttpInterceptorService], (service: HttpInterceptorService) => {
67+
const pendingRequestsStatus = service.pendingRequestsStatus;
68+
69+
pendingRequestsStatus
70+
.subscribe(
71+
next => expect(next).toBeTruthy(),
72+
error => console.log(error)
73+
);
74+
75+
service.get('http://www.fake.url');
76+
})
77+
));
6478
});

0 commit comments

Comments
 (0)