UNPKG

redux-actions-assertions

Version:
47 lines (36 loc) 1.56 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.registerAssertions = undefined; var _expect = require('expect.js'); var _expect2 = _interopRequireDefault(_expect); var _reduxActionsAssertionsJs = require('redux-actions-assertions-js'); var _actionWithInitialState = require('./actionWithInitialState'); var _actionWithInitialState2 = _interopRequireDefault(_actionWithInitialState); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function withState(state) { return (0, _expect2.default)(new _actionWithInitialState2.default(this.obj, state)); } function dispatchActions(expectedActions, done) { if (this.obj instanceof _actionWithInitialState2.default) { var action = this.obj.action; var state = this.obj.state; if (this.flags.not) { _reduxActionsAssertionsJs.assertions.toNotDispatchActionsWithState(state, action, expectedActions, done); } else { _reduxActionsAssertionsJs.assertions.toDispatchActionsWithState(state, action, expectedActions, done); } } else { if (this.flags.not) { _reduxActionsAssertionsJs.assertions.toNotDispatchActions(this.obj, expectedActions, done); } else { _reduxActionsAssertionsJs.assertions.toDispatchActions(this.obj, expectedActions, done); } } } function registerAssertions() { _expect2.default.Assertion.prototype.withState = withState; _expect2.default.Assertion.prototype.dispatchActions = dispatchActions; } exports.registerAssertions = registerAssertions;