Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

README #369

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 47 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,51 @@
# kefir-test-utils
# <a id="kefir-test-utils"></a> [≡](#contents) [kefir-test-utils](#kefir-test-utils) &middot; [![npm](https://img.shields.io/npm/dm/kefir-test-utils.svg)](https://www.npmjs.com/package/kefir-test-utils)

Framework-agnostic testing tool for Kefir.
Framework-agnostic testing tool for [Kefir](https://kefirjs.github.io/kefir/).

[![npm version](https://badge.fury.io/js/kefir-test-utils.svg)](http://badge.fury.io/js/kefir-test-utils)
[![Build Status](https://github.com/kefirjs/kefir-test-utils/actions/workflows/continuous_integration.yml/badge.svg)](https://github.com/kefirjs/kefir-test-utils/actions?query=workflow%3ACI)

---
## <a id="contents"></a> [≡](#contents) [Contents](#contents)

* [Plugin helpers](#plugin-helpers)
* [`activate: (obs: Kefir.Observable) => void`](#activate)
* [`deactivate: (obs: Kefir.Observable) => void`](#deactivate)
* [`send: (obs: Kefir.Observable, values: Array<Event<T>>) => obs`](#send)
* [`value: (value, options: ?{ current }) => Event<Value>`](#value)
* [`error: (error, options: ?{ current }) => Event<Error>`](#error)
* [`end: (options: ?{ current }) => Event<End>`](#end)
* [`stream: () => Kefir.Stream`](#stream)
* [`prop: () => Kefir.Property`](#prop)
* [`pool: () => Kefir.Pool`](#pool)

### <a id="plugin-helpers"></a> [≡](#contents) [Plugin helpers](#plugin-helpers)

#### <a id="activate"></a> [≡](#contents) [`activate: (obs: Kefir.Observable) => void`](#activate)

`activate` is a simple helper function to turn a stream on.

#### <a id="deactivate"></a> [≡](#contents) [`deactivate: (obs: Kefir.Observable) => void`](#deactivate)

`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.

#### <a id="send"></a> [≡](#contents) [`send: (obs: Kefir.Observable, values: Array<Event<T>>) => obs`](#send)

`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.

#### <a id="value"></a> [≡](#contents) [`value: (value, options: ?{ current }) => Event<Value>`](#value)

#### <a id="error"></a> [≡](#contents) [`error: (error, options: ?{ current }) => Event<Error>`](#error)

#### <a id="end"></a> [≡](#contents) [`end: (options: ?{ current }) => Event<End>`](#end)

`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.

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.

#### <a id="stream"></a> [≡](#contents) [`stream: () => Kefir.Stream`](#stream)

#### <a id="prop"></a> [≡](#contents) [`prop: () => Kefir.Property`](#prop)

#### <a id="pool"></a> [≡](#contents) [`pool: () => Kefir.Pool`](#pool)

`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.