maxAge should throw error when < 2

This commit is contained in:
Dan Schuman 2016-04-13 16:22:54 -07:00 committed by Dan Abramov
parent 275f564c54
commit 25eab60562
2 changed files with 15 additions and 0 deletions

View File

@ -411,6 +411,15 @@ function unliftStore(liftedStore, liftReducer) {
* Redux instrumentation store enhancer.
*/
export default function instrument(monitorReducer = () => null, options = {}) {
/* eslint-disable no-eq-null */
if (options.maxAge != null && options.maxAge < 2) {
/* eslint-enable */
throw new Error(
'DevTools.instrument({ maxAge }) option, if specified, ' +
'may not be less than 2.'
);
}
return createStore => (reducer, initialState, enhancer) => {
function liftReducer(r) {

View File

@ -479,6 +479,12 @@ describe('instrument', () => {
spy.restore();
});
it('should throw error when maxAge < 2', () => {
expect(() => {
createStore(counter, instrument(undefined, { maxAge: 1 }));
}).toThrow(/may not be less than 2/);
});
});
describe('Import State', () => {