I'm very new to writing test cases and would like some help. I have a selector tag that looks like this
export const selectSearchQueriesById = (id: string) =>
createSelector(
SomeRootSelector,
SearchData => SearchData.entities[id]
);
How should I go about writing a unit test case for something like this? Any help is greatly appreciated
CodePudding user response:
I will leave how I ended up solving it for future reference. I made a mock state (to mimic search data) and passed that inside the projector function of the selector like this :
it('Should have selectSearchQueriesById defined', () => {
const mockUrl:string = 'test';
const state = {
entities: { url: mockUrl}
};
selectSearchQueriesById(mockUrl).projector(state)
expect(selectSearchQueriesById).toBeDefined()
});