@@ -254,31 +254,30 @@ describe('withUndoRedo', () => {
254
254
} ) ;
255
255
256
256
it ( 'can undo after clearing and setting the same value again' , fakeAsync ( ( ) => {
257
- const recordState = { customer : { firstname : 'Santa' } } ;
258
-
259
257
const Store = signalStore (
260
258
{ providedIn : 'root' } ,
261
- withState ( recordState ) ,
259
+ withState ( testState ) ,
262
260
withMethods ( ( store ) => ( {
263
- update : ( value : typeof recordState ) => patchState ( store , value ) ,
261
+ update : ( value : string ) => patchState ( store , { test : value } ) ,
264
262
} ) ) ,
265
- withUndoRedo ( { keys : [ 'customer' ] } )
263
+ withUndoRedo ( { keys : testKeys } )
266
264
) ;
267
265
268
266
const store = TestBed . inject ( Store ) ;
269
267
270
- store . update ( { customer : { firstname : 'Alan' } } ) ;
268
+ store . update ( 'Alan' ) ;
271
269
tick ( 1 ) ;
272
270
273
- store . update ( { customer : { firstname : 'Gordon' } } ) ;
271
+ store . update ( 'Gordon' ) ;
274
272
tick ( 1 ) ;
275
273
276
274
store . clearStack ( ) ;
277
275
tick ( 1 ) ;
278
276
279
- // After clearing the undo/redo stack, there is no previous item any more
280
- // The following update is the very first value.
281
- store . update ( { customer : { firstname : 'Hugh' } } ) ;
277
+ // After clearing the undo/redo stack, there is no previous item anymore.
278
+ // The following update becomes the first value.
279
+ // Since there is no other value before, it cannot be undone.
280
+ store . update ( 'Hugh' ) ;
282
281
tick ( 1 ) ;
283
282
284
283
expect ( store . canUndo ( ) ) . toBe ( false ) ;
0 commit comments