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
import{Injectable}from'@angular/core';import{ComponentStore}from'@ngrx/component-store';import{WorkerJobStatus}from'../../types';exportinterfaceWorkerJobStatusDetailState{/** * A unique ID for this record */jobId: string;/** * The status of the given job */status: WorkerJobStatus;}constinitialState: WorkerJobStatusDetailState={jobId: '',status: {worker: '',job: '',jobStatus: '',expiration: newDate(),statusDate: newDate(),},};
@Injectable()exportclassWorkerJobStatusDetailStoreextendsComponentStore<WorkerJobStatusDetailState>{constructor(){super(initialState);}/* *** SELECTORS *** * These produce a subset of the total component state */readonlyjobId$=this.select(({ jobId })=>jobId);readonlystatus$=this.select(({ status })=>status);readonlysetJobId=this.updater((state,jobId: string|null): WorkerJobStatusDetailState=>({
...state,jobId: jobId||'',}));readonlysetStatus=this.updater((state,status: WorkerJobStatus|null): WorkerJobStatusDetailState=>({
...state,status: status||initialState.status,}));}
When I run the test, the mocked ComponentStore instance is not being injected into the component. Instead it appears that an unmocked instance is being inserted. What am I doing wrong?
The text was updated successfully, but these errors were encountered:
Discussed in #7792
Originally posted by kpeters-cbsi December 23, 2023
What's the recommended way of mocking a ComponentStore instance?
I have the following Component:
The store:
And the corresponding test:
When I run the test, the mocked ComponentStore instance is not being injected into the component. Instead it appears that an unmocked instance is being inserted. What am I doing wrong?
The text was updated successfully, but these errors were encountered: