Skip to content
This repository has been archived by the owner on May 27, 2020. It is now read-only.

API 1.0 (in progress) #23

Open
splincode opened this issue Jun 23, 2019 · 3 comments
Open

API 1.0 (in progress) #23

splincode opened this issue Jun 23, 2019 · 3 comments

Comments

@splincode
Copy link
Member

splincode commented Jun 23, 2019

@splincode splincode pinned this issue Jun 23, 2019
@splincode
Copy link
Member Author

@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 });
   })
})

@aymeric-duchein
Copy link
Contributor

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?

@splincode
Copy link
Member Author

mocking state lifecycle
Yes

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants