title: How to unit test condition in promise then() karma and jasmine
body: <p>I am using AngularJS 1.7 with Karma and Jasmine. And I have started learning Unit Test cases.</p>
  
  <p>I have a sample method below in my controller</p>
  
  <pre><code>_this.method = function () {
      Service.getData().then(function (response) {
          if (response.productId === "ClientAPI") {
              // Some code
          }
          else {
              // Some Code
          }
      }, function (error) {
          _this.inProgress = false;
          if (error.status === 400) {
              // Some Code
          } else {
              // Some Code
          }
      })
  }
  </code></pre>
  
  <p>Below is my test case :</p>
  
  <pre><code>describe('Some Route :: Controller =&gt; ', function () {
      var $componentController;
      var Service;
  
      beforeEach(module('app'));
      beforeEach(inject(function (_$componentController_, _Service_) {
          Service = _Service_;
          spyOn(Service, 'getData').and.callFake(function() {
              var deferred = $q.defer();
              var response = {};
              response.productId = "ClientAPI";
              deferred.resolve(result);
              return deferred.promise;
          });
          ctrl = $componentController('controllerName', { Service: Service });
      }));
  
      it('Ctrl Method : should true', function () {
          ctrl.method();
  
          expect(Service.getData).toHaveBeenCalled();
  
          Service.getData().then(function (response) {
              expect(response.productId).toBe("ClientAPI")
          })
  
      });
  });
  </code></pre>
  
  <p>But my branch coverage is not showing for this condition <code>if (response.productId === "ClientAPI") {</code> </p>
  
  <p>Not sure what I am doing wrong while testing in a promise.</p>