File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ import {
1717} from '../' ;
1818import { IS_EXTENSION_OR_MONITOR_PRESENT } from '../src/instrument' ;
1919import { PerformAction } from '../src/actions' ;
20+ import { RECOMPUTE_STATE } from '../src/reducer' ;
2021
2122const counter = jasmine
2223 . createSpy ( 'counter' )
@@ -126,6 +127,20 @@ function createStore<T>(
126127}
127128
128129describe ( 'Store Devtools' , ( ) => {
130+ describe ( 'reducer' , ( ) => {
131+ it ( 'should call @ngrx/devtools/recompute-state action' , ( ) => {
132+ const fixture = createStore ( doubleCounter ) ;
133+ counter . calls . reset ( ) ;
134+ fixture . replaceReducer ( counter ) ;
135+
136+ const allArgs = counter . calls . allArgs ( ) ;
137+ expect ( allArgs . length ) . toEqual ( 3 ) ;
138+ expect ( allArgs [ 0 ] [ 1 ] . type ) . toEqual ( UPDATE ) ;
139+ expect ( allArgs [ 1 ] [ 1 ] . type ) . toEqual ( RECOMPUTE_STATE ) ;
140+ expect ( allArgs [ 2 ] [ 1 ] . type ) . toEqual ( RECOMPUTE_STATE ) ;
141+ } ) ;
142+ } ) ;
143+
129144 describe ( 'Instrumentation' , ( ) => {
130145 let fixture : Fixture < number > ;
131146 let store : Store < number > ;
Original file line number Diff line number Diff line change @@ -25,6 +25,9 @@ export type Actions = DevtoolsActions.All | CoreActions;
2525
2626export const INIT_ACTION = { type : INIT } ;
2727
28+ export const RECOMPUTE_STATE = '@ngrx/devtools/recompute-state' as '@ngrx/devtools/recompute-state' ;
29+ export const RECOMPUTE_STATE_ACTION = { type : RECOMPUTE_STATE } ;
30+
2831export interface ComputedState {
2932 state : any ;
3033 error : any ;
@@ -501,7 +504,7 @@ export function liftReducerWith(
501504 // Recompute state history with latest reducer and update action
502505 computedStates = computedStates . map ( cmp => ( {
503506 ...cmp ,
504- state : reducer ( cmp . state , liftedAction ) ,
507+ state : reducer ( cmp . state , RECOMPUTE_STATE_ACTION ) ,
505508 } ) ) ;
506509
507510 currentStateIndex = stagedActionIds . length - 1 ;
You can’t perform that action at this time.
0 commit comments