You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Test failed with error Error: Expected spy setItem not to have been called:
import{TestBed}from'@angular/core/testing';import{NgxsAsyncStoragePluginModule}from'@ngxs-labs/async-storage-plugin';import{Action,NgxsModule,State,StateContext,Store}from'@ngxs/store';describe('save to storage on any state change',()=>{beforeEach(()=>{TestBed.configureTestingModule({imports: [NgxsModule.forRoot([StateToStore,InMemoryState]),NgxsAsyncStoragePluginModule.forRoot(KeyValueStorageMock,{key: [StateToStore.name]})],providers: [KeyValueStorageMock]});});it(`does not save ${StateToStore.name} when ${UpdateInMemoryState.name} dispatched`,async()=>{conststore=TestBed.get(Store)asStore;awaitstore.dispatch(newUpdateInMemoryState).toPromise();expect(setItemSpy).not.toHaveBeenCalled();});});constsetItemSpy=jasmine.createSpy('setItem');classKeyValueStorageMock{getItem(){}setItem(){returnsetItemSpy();}}
@State<string>({defaults: 'default',name: StateToStore.name})
class StateToStore {constructor(){}}
class UpdateInMemoryState {statictype='UpdateInMemoryStore';constructor(){}}
@State<string>({defaults: '',name: InMemoryState.name})
class InMemoryState {constructor(){}
@Action(UpdateInMemoryState)
update(ctx: StateContext<string>) {ctx.setState('some value');}}
The text was updated successfully, but these errors were encountered:
lomchik
changed the title
Plugin saves state A to storage even state B (should not be stored) was changed.
Plugin saves state A to storage when state B (should not be stored) was changed.
May 8, 2020
I have added unit test on this
Test failed with error
Error: Expected spy setItem not to have been called
:The text was updated successfully, but these errors were encountered: