title: How I can test $broadcast which is present is $http post method
body: <p>Below is code in my service class.</p>
  
  <pre><code>$timeout(function() {
      $rootScope.$broadcast('transfer:fileTransferInProgress');
      debugger 
      $http.post("/api/fileTransfer", data, {
          transformRequest: angular.identity,
          headers: {'Content-Type': undefined}                   
      }).success(function(response){
          console.log("I am here");
          $rootScope.$broadcast('transfer:readyState', response);
      }).error(function(){
          $rootScope.$broadcast('transfer:error');
      });
  }, 0);
  </code></pre>
  
  <p>I am trying below code to test the <code>$broadcast</code></p>
  
  <pre><code>'use strict';
  
  describe('upload service test ', function () {
  
      var mockXhr, uploadSvc;
      var $scope, $rootScope, $mockHttp, $httpBackend,$timeout;
      var mockfile = {"name":"File 1", "body":"abcd121212"}; 
      var mockfileType = {"id":"1"}; 
      var mockfileTypeName="test";
  
      beforeEach(module('questApp'));
  
      it('should invoke send method of upload service with right paramaeters', function () {
  
          inject(function($injector) {
              $rootScope = $injector.get('$rootScope');
              // $scope = $rootScope.$new();
              $mockHttp = $injector.get('$http');            
              uploadSvc=$injector.get('uploadService');
              $httpBackend = $injector.get('$httpBackend');
              spyOn($rootScope, '$broadcast');
              $timeout = $injector.get('$timeout');
          })
          $rootScope.globals = {
              currentUser : function() {
                  return {
                      username : "admin"
                  };
              }
          };
          $httpBackend.expectPOST('/api/fileTransfer', {
              'file':mockfile ,
              'fileType':mockfileType,
              'fileTypeName'  :mockfileTypeName   
          }).respond({});
          debugger 
          uploadSvc.send('file','fileType','fileTypeName'); 
          $timeout.flush();
          expect($rootScope.$broadcast).toHaveBeenCalled();
      });
  });
  </code></pre>
  
  <p>I am not sure what is the wrong but it gives me below error.</p>
  
  <blockquote>
    <p>Error: Unexpected request: POST
    /api/fileTransfer?cacheBuster=1455661017032  Expected POST
    /api/fileTransfer</p>
  </blockquote>