marty-test-utils

0.4.0 • Public • Published

marty-test-utils

A bunch of helpers to aid marty testing.

Build Status

mockStore

Use it to fake a Store.

mockStore('MyStore', {
  method1: spy()
});

mockComponent

Use it to fake a React component.

mockComponent('Test'); // => <div></div>
mockComponent('Test', 'span'); // => <span></span>

onDispatchedAction

Use it to test actions triggered through a dispatcher inside ActionCreators and Queries.

const dispatcher = Marty.dispatcher.getDefault();

it('tests a dispatched action', (done) => {
  onDispatchedAction(dispatcher, wcheck(done, (payload) => {
    assert(true); // <-- here go your tests
  }));

  ActionCreators.doSomething();
});

onStoreChange

Use it to test Store changes after the actions were handled.

const dispatcher = Marty.dispatcher.getDefault();

it('tests a store change', (done) => {
  onStoreChange(Store, wcheck(done, (state) => {
    assert(true); // <-- here go your tests
  }));

  // Fake the dispatcher emitting an action
  dispatcher.dispatchAction({type: Mock.Constants.USER_SET_EMAIL, arguments: [EMAIL]});
});

MIT license.

Readme

Keywords

Package Sidebar

Install

npm i marty-test-utils

Weekly Downloads

0

Version

0.4.0

License

MIT

Last publish

Collaborators

  • dariocravero