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 {
17
17
} from '../' ;
18
18
import { IS_EXTENSION_OR_MONITOR_PRESENT } from '../src/instrument' ;
19
19
import { PerformAction } from '../src/actions' ;
20
+ import { RECOMPUTE_STATE } from '../src/reducer' ;
20
21
21
22
const counter = jasmine
22
23
. createSpy ( 'counter' )
@@ -126,6 +127,20 @@ function createStore<T>(
126
127
}
127
128
128
129
describe ( '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
+
129
144
describe ( 'Instrumentation' , ( ) => {
130
145
let fixture : Fixture < number > ;
131
146
let store : Store < number > ;
Original file line number Diff line number Diff line change @@ -25,6 +25,9 @@ export type Actions = DevtoolsActions.All | CoreActions;
25
25
26
26
export const INIT_ACTION = { type : INIT } ;
27
27
28
+ export const RECOMPUTE_STATE = '@ngrx/devtools/recompute-state' as '@ngrx/devtools/recompute-state' ;
29
+ export const RECOMPUTE_STATE_ACTION = { type : RECOMPUTE_STATE } ;
30
+
28
31
export interface ComputedState {
29
32
state : any ;
30
33
error : any ;
@@ -501,7 +504,7 @@ export function liftReducerWith(
501
504
// Recompute state history with latest reducer and update action
502
505
computedStates = computedStates . map ( cmp => ( {
503
506
...cmp ,
504
- state : reducer ( cmp . state , liftedAction ) ,
507
+ state : reducer ( cmp . state , RECOMPUTE_STATE_ACTION ) ,
505
508
} ) ) ;
506
509
507
510
currentStateIndex = stagedActionIds . length - 1 ;
You can’t perform that action at this time.
0 commit comments