I have a (dynamic) selector that uses another selector. I thought i could test it with a (fake) state, expecting the tested selector to call the used selector with that state. However i seem to have to test it with data similar to the output of the called selector.
The following code snippet tries to illustrate it:
export class SomeSelectors {
@Selector([SomeState])
static getSomethingFirst(state: SomeModel) {
return state.something;
}
static getSomethingSecond(...categories: string[]) {
return createSelector([SomeSelectors.getSomethingFirst], (somethingsFirst) =>
..
);
}
}
describe('SomeSelectors', () => {
const someFakeState = {
something: 'test me'
};
describe('getSomethingSecond', () => {
it('i would like to test it with a fake state', () => {
const result = SomeSelectors.getSomethingSecond(someFakeState)('test-category');
expect(result).toBeTruthy();
});
it('however i must test it with something that is like ', () => {
const result = SomeSelectors.getSomethingSecond(someFakeState.something)('test-category');
expect(result).toBeTruthy();
});
});
});
I think i miss some understanding about how these selectors really work. Anyone some pointers on how to see them?
Aucun commentaire:
Enregistrer un commentaire