Skip to content

Commit 25eab60

Browse files
quicksnapgaearon
authored andcommitted
maxAge should throw error when < 2
1 parent 275f564 commit 25eab60

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/instrument.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,15 @@ function unliftStore(liftedStore, liftReducer) {
411411
* Redux instrumentation store enhancer.
412412
*/
413413
export default function instrument(monitorReducer = () => null, options = {}) {
414+
/* eslint-disable no-eq-null */
415+
if (options.maxAge != null && options.maxAge < 2) {
416+
/* eslint-enable */
417+
throw new Error(
418+
'DevTools.instrument({ maxAge }) option, if specified, ' +
419+
'may not be less than 2.'
420+
);
421+
}
422+
414423
return createStore => (reducer, initialState, enhancer) => {
415424

416425
function liftReducer(r) {

test/instrument.spec.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,12 @@ describe('instrument', () => {
479479

480480
spy.restore();
481481
});
482+
483+
it('should throw error when maxAge < 2', () => {
484+
expect(() => {
485+
createStore(counter, instrument(undefined, { maxAge: 1 }));
486+
}).toThrow(/may not be less than 2/);
487+
});
482488
});
483489

484490
describe('Import State', () => {

0 commit comments

Comments
 (0)