I have a function which consists of saga effect calls i want to coverage the full function with out missing any line of code how can i test if condition here
export function* fetchFromSource() {
const dataTypeName = mapDataTypes(dataType);
Iif (dataTypeName.length === 0) {
return;
}
yield put(sourceActions.onRdsmSourcePlantRequestStarted());
}
how i test the dataTypeName.length using jest this is my mapDataTypes unit test method
it('should return appropriate dataType when mapDataTypes triggered', () => {
const expected = 'Items';
const actionDataType = action.payload.name;
expect(expected).toEqual(saga.mapDataTypes(actionDataType));
});
this is my next put test method
it('should return onRdsmSourcePlantRequestStarted action', () => {
const expectedAction = {
type: 'rdsm/sourceView/ON_RDSM_SOURCE_PLANT_REQUEST_STARTED',
};
const dataTypeName = '';
const genNext = generator.next(dataTypeName);
expect(genNext.value).toEqual(put(expectedAction));
});
here test is passing to verify the put call without entering to if block. my question is how to verify the if block