'else path not taken in sinon unit testing

I have react component, passed props,

downloadReport={ee => downloadHandler(ee, props, i, flag)}

function downloadHandler(ee, props, i, flag) {
    props.setSelectedExport(ee);
    if (flag) {
        props.doSetLastExportType(ee);
        saveLastViewedData(ee, router, flag);
    }
}

this test case only works for if condition coverage and on coverage it shows else path not taken, i need 100% coverage with branches too, branch coverage is not happening

describe('testQualToggle is false', () => {
    beforeEach(() => {
        flag = false;
        reduxStub
            .onCall(6)
            .returns(flag);
    });
    afterEach(() => {
        sinon.restore();
    });
    it('should call closeHandler is called', () => {
        const closeHandler = comp.props().closeHandler;
        closeHandler(ee);
        expect(flag).to.have.eq(false);
    });
    it('should call only is called', () => {
        const downloadReport = comp.props().downloadReport;
        saveLastViewedData(false, false, false);
        downloadReport(ee, null, router, false);
        expect(flag).to.have.eq(false);
        expect(false).toEqual(false);
    });
});


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source