title: How to write a karma-jasmine test case for $http.get in angularJS?
body: <p>I have a service:</p>
  
  <pre><code>(function () {
      angular.module('app').service('MyAppService', MyAppService);
      MyAppService.$inject = ['$http', 'testUrl'];
      function MyAppService($http, testUrl) {
          var service = {
              testFunction: testFunction        
          };
          return service;
          function testFunction() {
              /*testurl is my backend API*/
              return $http.get(testUrl)                
                  .error(function(){
                      return;
                  })
                  .then(function (response) {
                      return response.data;
                  });
          }
      }
  })();
  </code></pre>
  
  <p>I call this in my controller as:</p>
  
  <pre><code>        testControllerFunction();
          function testControllerFunction() {
               MyAppService.testFunction().then(function (response) {
                  app.testResponse = response;  //This my http response
                  console.log(app.testResponse);
              });
          }
  </code></pre>
  
  <p>I am writing a karma test case for successful $http.get request in the MyAppService as:</p>
  
  <pre><code>describe('MyAppService', function () {
          var MyAppService,http;
          beforeEach(function() {
              module('app');
              inject(function ($injector) {
                  MyAppService = $injector.get('MyAppService');
                  testUrl = $injector.get('testUrl');
                  http = $injector.get('$httpBackend');
              });
          });
  
          it('should call the backend testurl ', function () {
              MyAppService.testFunction();
              http.expectGET(testUrl);
          });
      });
  </code></pre>
  
  <p>But this does not seem to be working? Where did I go wrong?
  Thanks!</p>