Open splincode opened 5 years ago
@aymeric-duchein How about new API for NGXS Testing?
import { NgxsTestingModule, MockedStore, MockedStateContext } from '@ngxs-labs/testing';
import { Store } from '@ngxs/store';
describe('Test', () => {
let store: MockedStore;
beforeAll(() => {
TestBed. configureTestingModule({
imports: [NgxsTestingModule.forRoot([ ZooState ])]
});
store = TestBed.get<MockedStore>(Store);
});
it('patchState have been called', () => {
const ctx: MockedStateContext = store.getStateContextMocks('STATE_NAME');
expect(ctx.patchState).toHaveBeenCalledWith({ animals: 2 });
})
})
This would be nice and help keep tests readable with less lines of codes. Besides all already implemented methods what do you think is missing? Before editing this issue you were talking about mocking state lifecycle, should we add this to this new MockedStore?
mocking state lifecycle Yes