UNPKG

redux-mock-store

Version:

A mock store for testing your redux async action creators and middleware

2 lines (1 loc) 2.99 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.ReduxMockStore={})}(this,function(t){"use strict";var e,n="object"==typeof global&&global&&global.Object===Object&&global,r="object"==typeof self&&self&&self.Object===Object&&self;n||r||Function("return this")(),Function.prototype.toString.call(Object);e="undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof module?module:Function("return this")();var o,c;"function"==typeof(c=e.Symbol)?c.observable?o=c.observable:(o=c("observable"),c.observable=o):o="@@observable";var i=Object.assign||function(t){for(var e=1;arguments.length>e;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t};function u(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];return function(t){return function(n,r,o){var c,u=t(n,r,o),f=u.dispatch,a={getState:u.getState,dispatch:function(t){return f(t)}};return c=e.map(function(t){return t(a)}),f=function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];return 0===e.length?function(t){return t}:1===e.length?e[0]:e.reduce(function(t,e){return function(){return t(e.apply(void 0,arguments))}})}.apply(void 0,c)(u.dispatch),i({},u,{dispatch:f})}}}var f="[object Object]";var a,l,p=Object.prototype,s=Function.prototype.toString,d=p.hasOwnProperty,y=s.call(Object),b=p.toString,v=(a=Object.getPrototypeOf,l=Object,function(t){return a(l(t))});var g=function(t){if(!(e=t)||"object"!=typeof e||b.call(t)!=f||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t))return!1;var e,n=v(t);if(null===n)return!0;var r=d.call(n,"constructor")&&n.constructor;return"function"==typeof r&&r instanceof r&&s.call(r)==y},h=function(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);t.length>e;e++)n[e]=t[e];return n}return Array.from(t)},j=function(t){return"function"==typeof t};function O(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return u.apply(void 0,h(t))(function(){var t=[],n=[];return{getState:function(){return j(e)?e(t):e},getActions:function(){return t},dispatch:function(e){if(!g(e))throw Error("Actions must be plain objects. Use custom middleware for async actions.");if(void 0===e.type)throw Error('Actions may not have an undefined "type" property. Have you misspelled a constant? Action: '+JSON.stringify(e));t.push(e);for(var r=0;n.length>r;r++)n[r]();return e},clearActions:function(){t=[]},subscribe:function(t){return j(t)&&n.push(t),function(){var e=n.indexOf(t);0>e||n.splice(e,1)}},replaceReducer:function(t){if(!j(t))throw Error("Expected the nextReducer to be a function.")}}})()}}var m=O;t.configureStore=O,t.legacy_configureStore=m,t.default=O,Object.defineProperty(t,"__esModule",{value:!0})});