title: Jasmine complaining that ".then is not a function" on a function that returns a promise
body: <p>I am testing a function to see if it is calling a function that returns a promise:</p>
  
  <p>The function:</p>
  
  <pre><code>saveNew: (collection, query) -&gt;
    @newId
    .then (id) -&gt;
      $http.post server + "/api/v1/saveJson/#{collection}/#{id}", query
  </code></pre>
  
  <p>The newId function:</p>
  
  <pre><code>newId: () -&gt; $http.get server + "/api/v1/newid"
  </code></pre>
  
  <p>The test:</p>
  
  <pre><code>describe "saveNew", () -&gt;
      it "should call to get a new id", () -&gt;
         spyOn(mySvc,"newId")
         entitySvc.saveNew "myCollection", {data: "stuff"}
         expect(entitySvc.newId).toHaveBeenCalled()
  </code></pre>
  
  <p>This results in </p>
  
  <pre><code>TypeError: this.newId.then is not a function
  </code></pre>
  
  <p>Meanwhile, I test another method that calls a function that returns a promise, and it passes:</p>
  
  <pre><code>findOne: (collection, query) -&gt; @find collection, query
  </code></pre>
  
  <p>The async function:</p>
  
  <pre><code>find: (collection, query) -&gt; 
      $http.post server + "/api/v1/findJson/#{collection}", query
  </code></pre>
  
  <p>The test:</p>
  
  <pre><code>describe "#findOne", () -&gt;
      it "should call #find", () -&gt;
        query = {id:1}
        collection = "myCollection"
        spyOn(mySvc,"find")
        mySvc.findOne collection, query
        expect(mySvc.find).toHaveBeenCalledWith(collection,query)
  </code></pre>