@hirez_io/observer-spy
Advanced tools
Comparing version 1.2.1 to 1.3.0
export { ObserverSpy } from './observer-spy'; | ||
export { subscribeAndSpyOn, ObserverSpyWithSubscription } from './subscribe-and-spy-on'; | ||
export { fakeTime } from './fake-time'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -5,4 +5,7 @@ "use strict"; | ||
exports.ObserverSpy = observer_spy_1.ObserverSpy; | ||
var subscribe_and_spy_on_1 = require("./subscribe-and-spy-on"); | ||
exports.subscribeAndSpyOn = subscribe_and_spy_on_1.subscribeAndSpyOn; | ||
exports.ObserverSpyWithSubscription = subscribe_and_spy_on_1.ObserverSpyWithSubscription; | ||
var fake_time_1 = require("./fake-time"); | ||
exports.fakeTime = fake_time_1.fakeTime; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@hirez_io/observer-spy", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"repository": { | ||
@@ -5,0 +5,0 @@ "type": "git", |
@@ -11,4 +11,5 @@ # @hirez_io/observer-spy 👀💪 | ||
[](#contributors-) | ||
<!-- ALL-CONTRIBUTORS-BADGE:END --> | ||
<!-- ALL-CONTRIBUTORS-BADGE:END --> | ||
<div align="center"> | ||
@@ -139,2 +140,28 @@ <a href="http://testangular.com/?utm_source=github&utm_medium=link&utm_campaign=observer-spy"> | ||
## Quick Usage with `subscribeAndSpyOn(observable)` | ||
You can also create an `ObserverSpy` and immediately subscribe to an observable with this simple helper function. | ||
Observer spies generated that way will provide an additional `unsubscribe()` method that you might want to call | ||
if your source observable does not complete or does not get terminated by an error while testing. | ||
**Example:** | ||
```js | ||
import { subscribeAndSpyOn } from '@hirez_io/observer-spy'; | ||
it('should immediately subscribe and spy on Observable ', () => { | ||
const fakeObservable = of('first', 'second', 'third'); | ||
// get an "ObserverSpyWithSubscription" | ||
const observerSpy = subscribeAndSpyOn(fakeObservable); | ||
// and optionally unsubscribe | ||
observerSpy.unsubscribe(); | ||
expect(observerSpy.getFirstValue()).toEqual('first'); | ||
// or use the shorthand version: | ||
expect(subscribeAndSpyOn(fakeObservable).getFirstValue()).toEqual('first'); | ||
}); | ||
``` | ||
# Testing Async Observables | ||
@@ -319,4 +346,5 @@ | ||
<!-- prettier-ignore-end --> | ||
<!-- ALL-CONTRIBUTORS-LIST:END --> | ||
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! |
export { ObserverSpy } from './observer-spy'; | ||
export { subscribeAndSpyOn, ObserverSpyWithSubscription } from './subscribe-and-spy-on'; | ||
export { fakeTime } from './fake-time'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
263249
40
535
348