how to test javascript chain of promises?
<p>I have a javascript promise similar to this:</p>

<pre><code>function a(){
return new Promise(function(resolve, reject){
    b().then(function(result){
        if(result.name == 'sampletest1'){
            resolve({
                'data': 'testdata1'
            });
        }else if(result.name=='sampletest2'){
            resolve({
                'data': 'testdata2'
            });
        }
    }, reject);
})
}
</code></pre>

<p>I want to write test in jasmine to test functionality of function <code>a</code>. But I am having trouble as this function is dependent on the result of function <code>b</code>, which is also a promise. So, how to mock function <code>b</code> , so that I would be able to test functionality of function <code>a</code>.</p>