|
1 |
| -# kefir-test-utils |
| 1 | +# <a id="kefir-test-utils"></a> [≡](#contents) [kefir-test-utils](#kefir-test-utils) · [](https://www.npmjs.com/package/kefir-test-utils) |
2 | 2 |
|
3 |
| -Framework-agnostic testing tool for Kefir. |
| 3 | +Framework-agnostic testing tool for [Kefir](https://kefirjs.github.io/kefir/). |
4 | 4 |
|
| 5 | +[](http://badge.fury.io/js/kefir-test-utils) |
5 | 6 | [](https://github.com/kefirjs/kefir-test-utils/actions?query=workflow%3ACI)
|
6 | 7 |
|
7 |
| ---- |
| 8 | +## <a id="contents"></a> [≡](#contents) [Contents](#contents) |
| 9 | + |
| 10 | +* [Plugin helpers](#plugin-helpers) |
| 11 | + * [`activate: (obs: Kefir.Observable) => void`](#activate) |
| 12 | + * [`deactivate: (obs: Kefir.Observable) => void`](#deactivate) |
| 13 | + * [`send: (obs: Kefir.Observable, values: Array<Event<T>>) => obs`](#send) |
| 14 | + * [`value: (value, options: ?{ current }) => Event<Value>`](#value) |
| 15 | + * [`error: (error, options: ?{ current }) => Event<Error>`](#error) |
| 16 | + * [`end: (options: ?{ current }) => Event<End>`](#end) |
| 17 | + * [`stream: () => Kefir.Stream`](#stream) |
| 18 | + * [`prop: () => Kefir.Property`](#prop) |
| 19 | + * [`pool: () => Kefir.Pool`](#pool) |
| 20 | + |
| 21 | +### <a id="plugin-helpers"></a> [≡](#contents) [Plugin helpers](#plugin-helpers) |
| 22 | + |
| 23 | +#### <a id="activate"></a> [≡](#contents) [`activate: (obs: Kefir.Observable) => void`](#activate) |
| 24 | + |
| 25 | +`activate` is a simple helper function to turn a stream on. |
| 26 | + |
| 27 | +#### <a id="deactivate"></a> [≡](#contents) [`deactivate: (obs: Kefir.Observable) => void`](#deactivate) |
| 28 | + |
| 29 | +`deactivate` is a simple helper function to turn a stream off. It can turn off streams that were activated with `activate`. Streams turned on through other means (direct call to `on{Value|Error|End|Any}`, use of `observe`, etc.) need to be deactivated through their complementary mechanisms. |
| 30 | + |
| 31 | +#### <a id="send"></a> [≡](#contents) [`send: (obs: Kefir.Observable, values: Array<Event<T>>) => obs`](#send) |
| 32 | + |
| 33 | +`send` is a helper function for emitting values into a given observable. Note that the second parameter is an array of values to emit from the observable. The `Event` is generated by the `value`, `error`, and `end` functions. For all three of these functions, the optional `options` object is not needed. |
| 34 | + |
| 35 | +#### <a id="value"></a> [≡](#contents) [`value: (value, options: ?{ current }) => Event<Value>`](#value) |
| 36 | + |
| 37 | +#### <a id="error"></a> [≡](#contents) [`error: (error, options: ?{ current }) => Event<Error>`](#error) |
| 38 | + |
| 39 | +#### <a id="end"></a> [≡](#contents) [`end: (options: ?{ current }) => Event<End>`](#end) |
| 40 | + |
| 41 | +`value` and `error` take a value or error and an optional `options` object and return an `Event` object that can be passed to `send`, `emit`, or `emitInTime`. `end` does not take this value, as the `end` event in Kefir does not send a value with it. |
| 42 | + |
| 43 | +When passing to `send`, the `options` object is ignored. `options` is used by `emit` and `emitInTime` (both described below) to determine whether the event should be treated as a `Kefir.Property`'s current event, error, or end. |
| 44 | + |
| 45 | +#### <a id="stream"></a> [≡](#contents) [`stream: () => Kefir.Stream`](#stream) |
| 46 | + |
| 47 | +#### <a id="prop"></a> [≡](#contents) [`prop: () => Kefir.Property`](#prop) |
| 48 | + |
| 49 | +#### <a id="pool"></a> [≡](#contents) [`pool: () => Kefir.Pool`](#pool) |
| 50 | + |
| 51 | +`stream`, `prop`, and `pool` are helper functions to create empty streams, properties, and pools. These can be used as mock sources to send values into. They have no other behavior. |
0 commit comments