redux-observable-test-helper

1.3.0 • Public • Published

redux-observable-test-helper

install

This has peer dependencies of rxjs 5 and redux-observable, which will have to be installed as well.

npm install --save-dev redux-observable-test-helper

Usage

// epic.js
export const show = () => ({
  type: 'SHOW',
});
 
export const close = data => ({
  type: 'CLOSE',
  payload: data,
});
 
export const delayEpic = action$ =>
  action$.ofType('SHOW').delay(3000).map(x => close());
// epic.test.js
import {
  delayEpic,
  show,
  close,
} from './epic.js';
import { createExpectedEpic, mockDelay } from 'redux-observable-test-helper';
 
const expectedEpic = createExpectedEpic((actual, expected) => {
  // here use Jest, you can use your assertion library
  expect(actual).toEqual(expected);
});
 
test('test delay', () => {
  expectedEpic(
    delayEpic,
    {
      expect: ['--a', { a: close() }],
      action: ['a', { a: show() }],
    },
    mockDelay('--|')
  );
});

API docs

read here

Readme

Keywords

Package Sidebar

Install

npm i redux-observable-test-helper

Weekly Downloads

0

Version

1.3.0

License

MIT

Last publish

Collaborators

  • s6323859