-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added support for actionSanitiser and stateSanitiser in @ngrx/store-devtools #544
Changes from 11 commits
3b6da60
2299430
577434c
10ddaaa
99333d6
b08fc95
9a64b96
0c7a8d4
2ba38f4
0906638
07c72ca
c49bdb8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,21 @@ describe('StoreDevtoolsOptions', () => { | |
options.name = 'my instance'; | ||
expect(options.name).toBe('my instance'); | ||
}); | ||
|
||
it('can be initialized with actionSanitizer', () => { | ||
const options = new StoreDevtoolsConfig(); | ||
function sanitizer(action: Action, id: number): Action { | ||
return action; | ||
} | ||
options.actionSanitizer = sanitizer; | ||
expect(options.actionSanitizer).toEqual(sanitizer); | ||
}); | ||
it('can be initialized with stateSanitizer', () => { | ||
const options = new StoreDevtoolsConfig(); | ||
function stateSanitizer(state: any, index: number): any { | ||
return state; | ||
} | ||
options.actionSanitizer = stateSanitizer; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes |
||
expect(options.actionSanitizer).toEqual(stateSanitizer); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,14 @@ | ||
import { | ||
StoreDevtools, | ||
StoreDevtoolsModule, | ||
LiftedState, | ||
StoreDevtoolsConfig, | ||
StoreDevtoolsOptions, | ||
} from '../'; | ||
import { | ||
StoreModule, | ||
Store, | ||
StateObservable, | ||
ActionReducer, | ||
Action, | ||
ReducerManager, | ||
} from '@ngrx/store'; | ||
import { Action } from '@ngrx/store'; | ||
import { of } from 'rxjs/observable/of'; | ||
import { createConfig, noMonitor } from '../src/instrument'; | ||
|
||
import { LiftedState } from '../'; | ||
import { DevtoolsExtension, ReduxDevtoolsExtension } from '../src/extension'; | ||
import { | ||
createConfig, | ||
noActionSanitizer, | ||
noMonitor, | ||
noStateSanitizer, | ||
} from '../src/instrument'; | ||
|
||
describe('DevtoolsExtension', () => { | ||
let reduxDevtoolsExtension: ReduxDevtoolsExtension; | ||
|
@@ -39,6 +32,8 @@ describe('DevtoolsExtension', () => { | |
const defaultOptions = { | ||
maxAge: false, | ||
monitor: noMonitor, | ||
actionSanitizer: noActionSanitizer, | ||
stateSanitizer: noStateSanitizer, | ||
name: 'NgRx Store DevTools', | ||
serialize: false, | ||
}; | ||
|
@@ -52,16 +47,28 @@ describe('DevtoolsExtension', () => { | |
'ngrx-store-1509655064369' | ||
); | ||
}); | ||
|
||
function myActionSanitizer() { | ||
return { type: 'sanitizer' }; | ||
} | ||
function myStateSanitizer() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a line in between these functions There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure |
||
return { state: 'new state' }; | ||
} | ||
|
||
it('should send notification with given options', () => { | ||
devtoolsExtension = new DevtoolsExtension( | ||
reduxDevtoolsExtension, | ||
createConfig({ | ||
actionSanitizer: myActionSanitizer, | ||
stateSanitizer: myStateSanitizer, | ||
name: 'ngrx-store-devtool-todolist', | ||
}) | ||
); | ||
const defaultOptions = { | ||
maxAge: false, | ||
monitor: noMonitor, | ||
actionSanitizer: myActionSanitizer, | ||
stateSanitizer: myStateSanitizer, | ||
name: 'ngrx-store-devtool-todolist', | ||
serialize: false, | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a line in between these tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure