Skip to content

Mocking NgRx ComponentStore? #7792

Answered by satanTime
kpeters-cbsi asked this question in Q&A
Discussion options

You must be logged in to vote

MockBuilder.provide() doesn't mock, but simply adds a provider to TestBed, so in your example WorkerJobStatusDetailStore is exactly an object with 2 properties:

{
  setJobId: mockSetJobId,
  setStatus: mockSetStatus,
}

I assume you need MockProvider, then WorkerJobStatusDetailStore is a mock with customized properties:

MockBuilder(WorkerJobStatusDetailContainerComponent)
  .provide(MockProvider(WorkerJobStatusService, { getWorkerJobStatus: mockGetWorkerJobStatus })
  .provide(MockProvider(WorkerJobStatusDetailStore, {
    setJobId: mockSetJobId,
    setStatus: mockSetStatus,
  }))
  .provide(MockProvider(ActivatedRoute, new mockActivatedRoute());

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@kpeters-cbsi
Comment options

@satanTime
Comment options

@kpeters-cbsi
Comment options

Answer selected by kpeters-cbsi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants