spyOn gives method does not exist error
<p>I am running a Karma test on an angular app, in the test I have the following:</p>

<pre><code>return inject(function($injector) {
   this.Service = {
      functionWithPromise: function(postdata){
         var deferred = $q.defer();
         deferred.resolve({
            data: {}
          });
          return deferred.promise;
         }
      };
};
</code></pre>

<p>and</p>

<pre><code>it('should call the functionWithPromise function when the create function is called', function() {
    res = {}
    this.scope.create(res);
    this.scope.$digest();
    spyOn(Service, "functionWithPromise");
    expect(this.Service.functionWithPromise).toHaveBeenCalled();  
  });
</code></pre>

<p>when I run the test it gives this error:  </p>

<pre><code>functionWithPromise() method does not exist
</code></pre>

<p>How can I get the test to recognize the functionWithPromise() function?</p>