@@ -215,4 +215,40 @@ describe('instrument', () => {
215215 monitoredInstrumentedStore . dispatch ( ActionCreators . jumpToState ( 3 ) ) ;
216216 expect ( reducerCalls ) . toBe ( 4 ) ;
217217 } ) ;
218+
219+ describe ( 'Import State' , ( ) => {
220+ let monitoredStore ;
221+ let monitoredLiftedStore ;
222+ let exportedState ;
223+
224+ beforeEach ( ( ) => {
225+ monitoredStore = instrument ( ) ( createStore ) ( counter ) ;
226+ monitoredLiftedStore = monitoredStore . liftedStore ;
227+ // Set up state to export
228+ monitoredStore . dispatch ( { type : 'INCREMENT' } ) ;
229+ monitoredStore . dispatch ( { type : 'INCREMENT' } ) ;
230+ monitoredStore . dispatch ( { type : 'INCREMENT' } ) ;
231+
232+ exportedState = monitoredLiftedStore . getState ( ) ;
233+ } ) ;
234+
235+ it ( 'should replay all the steps when a state is imported' , ( ) => {
236+ let importMonitoredStore = instrument ( ) ( createStore ) ( counter ) ;
237+ let importMonitoredLiftedStore = importMonitoredStore . liftedStore ;
238+ // Import exported state
239+ importMonitoredLiftedStore . dispatch ( ActionCreators . importState ( exportedState ) ) ;
240+ expect ( importMonitoredLiftedStore . getState ( ) ) . toEqual ( exportedState ) ;
241+ } ) ;
242+
243+ it ( 'should replace the existing action log with the one imported' , ( ) => {
244+ let importMonitoredStore = instrument ( ) ( createStore ) ( counter ) ;
245+ let importMonitoredLiftedStore = importMonitoredStore . liftedStore ;
246+
247+ importMonitoredStore . dispatch ( { type : 'DECREMENT' } ) ;
248+ importMonitoredStore . dispatch ( { type : 'DECREMENT' } ) ;
249+
250+ importMonitoredLiftedStore . dispatch ( ActionCreators . importState ( exportedState ) ) ;
251+ expect ( importMonitoredLiftedStore . getState ( ) ) . toEqual ( exportedState ) ;
252+ } ) ;
253+ } ) ;
218254} ) ;
0 commit comments