Skip to content

Commit

Permalink
ngrx#853 explicitely setting default features according to https://gi…
Browse files Browse the repository at this point in the history
dummdidumm committed Aug 8, 2018
1 parent 3266a83 commit c250d66
Showing 3 changed files with 42 additions and 5 deletions.
17 changes: 15 additions & 2 deletions modules/store-devtools/spec/config.spec.ts
Original file line number Diff line number Diff line change
@@ -6,6 +6,19 @@ import {
DEFAULT_NAME,
} from '../src/config';

const defaultFeatures = {
pause: true,
lock: true,
persist: true,
export: true,
import: 'custom',
jump: true,
skip: true,
reorder: true,
dispatch: true,
test: true,
};

describe('StoreDevtoolsOptions', () => {
it('creates default options with empty object given', () => {
const config = createConfig({});
@@ -17,7 +30,7 @@ describe('StoreDevtoolsOptions', () => {
name: DEFAULT_NAME,
serialize: false,
logOnly: false,
features: false,
features: defaultFeatures,
});
});

@@ -62,7 +75,7 @@ describe('StoreDevtoolsOptions', () => {
name: DEFAULT_NAME,
serialize: false,
logOnly: false,
features: false,
features: defaultFeatures,
});
});

13 changes: 12 additions & 1 deletion modules/store-devtools/spec/extension.spec.ts
Original file line number Diff line number Diff line change
@@ -14,7 +14,18 @@ import { unliftState } from '../src/utils';

function createOptions(
name: string = 'NgRx Store DevTools',
features: any = false,
features: any = {
pause: true,
lock: true,
persist: true,
export: true,
import: 'custom',
jump: true,
skip: true,
reorder: true,
dispatch: true,
test: true,
},
serialize: boolean | undefined = false,
maxAge: false | number = false
) {
17 changes: 15 additions & 2 deletions modules/store-devtools/src/config.ts
Original file line number Diff line number Diff line change
@@ -50,14 +50,27 @@ export function createConfig(
name: DEFAULT_NAME,
serialize: false,
logOnly: false,
features: false,
// Add all features explicitely. This prevent buggy behavior for
// options like "lock" which might otherwise not show up.
features: {
pause: true, // start/pause recording of dispatched actions
lock: true, // lock/unlock dispatching actions and side effects
persist: true, // persist states on page reloading
export: true, // export history of actions in a file
import: 'custom', // import history of actions from a file
jump: true, // jump back and forth (time travelling)
skip: true, // skip (cancel) actions
reorder: true, // drag and drop actions in the history list
dispatch: true, // dispatch custom actions or action creators
test: true, // generate tests for the selected actions
},
};

let options = typeof _options === 'function' ? _options() : _options;
const logOnly = options.logOnly
? { pause: true, export: true, test: true }
: false;
const features = options.features || logOnly;
const features = options.features || logOnly || DEFAULT_OPTIONS.features;
const config = Object.assign({}, DEFAULT_OPTIONS, { features }, options);

if (config.maxAge && config.maxAge < 2) {

0 comments on commit c250d66

Please sign in to comment.