-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(StoreDevtools): Add support for custom instance name (#517)
Closes #463
- Loading branch information
1 parent
aedf20e
commit 00be3d1
Showing
9 changed files
with
115 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { ActionReducer, Action } from '@ngrx/store'; | ||
import { StoreDevtoolsConfig } from '../'; | ||
|
||
describe('StoreDevtoolsOptions', () => { | ||
it('can be initialized with name', () => { | ||
const options = new StoreDevtoolsConfig(); | ||
options.name = 'my instance'; | ||
expect(options.name).toBe('my instance'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { | ||
StoreDevtools, | ||
StoreDevtoolsModule, | ||
LiftedState, | ||
StoreDevtoolsConfig, | ||
StoreDevtoolsOptions, | ||
} from '../'; | ||
import { | ||
StoreModule, | ||
Store, | ||
StateObservable, | ||
ActionReducer, | ||
Action, | ||
ReducerManager, | ||
} from '@ngrx/store'; | ||
import { of } from 'rxjs/observable/of'; | ||
import { createConfig, noMonitor } from '../src/instrument'; | ||
import { DevtoolsExtension, ReduxDevtoolsExtension } from '../src/extension'; | ||
|
||
describe('DevtoolsExtension', () => { | ||
let reduxDevtoolsExtension: ReduxDevtoolsExtension; | ||
let devtoolsExtension: DevtoolsExtension; | ||
|
||
beforeEach(() => { | ||
reduxDevtoolsExtension = jasmine.createSpyObj('reduxDevtoolsExtension', [ | ||
'send', | ||
'connect', | ||
]); | ||
(reduxDevtoolsExtension.connect as jasmine.Spy).and.returnValue(of({})); | ||
spyOn(Date, 'now').and.returnValue('1509655064369'); | ||
}); | ||
|
||
describe('notify', () => { | ||
it('should send notification with default options', () => { | ||
devtoolsExtension = new DevtoolsExtension( | ||
reduxDevtoolsExtension, | ||
createConfig({}) | ||
); | ||
const defaultOptions = { | ||
maxAge: false, | ||
monitor: noMonitor, | ||
name: 'NgRx Store DevTools', | ||
serialize: false, | ||
}; | ||
const action = {} as Action; | ||
const state = {} as LiftedState; | ||
devtoolsExtension.notify(action, state); | ||
expect(reduxDevtoolsExtension.send).toHaveBeenCalledWith( | ||
null, | ||
{}, | ||
defaultOptions, | ||
'ngrx-store-1509655064369' | ||
); | ||
}); | ||
it('should send notification with given options', () => { | ||
devtoolsExtension = new DevtoolsExtension( | ||
reduxDevtoolsExtension, | ||
createConfig({ | ||
name: 'ngrx-store-devtool-todolist', | ||
}) | ||
); | ||
const defaultOptions = { | ||
maxAge: false, | ||
monitor: noMonitor, | ||
name: 'ngrx-store-devtool-todolist', | ||
serialize: false, | ||
}; | ||
const action = {} as Action; | ||
const state = {} as LiftedState; | ||
devtoolsExtension.notify(action, state); | ||
expect(reduxDevtoolsExtension.send).toHaveBeenCalledWith( | ||
null, | ||
{}, | ||
defaultOptions, | ||
'ngrx-store-1509655064369' | ||
); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters