title: Jasmine Expected Spy to have been called
body: <p>Here is my angular factory written in typescript: </p>
  
  <pre><code>export class DataService { 
  
  constructor () {
     this.setYear(2015);
   }
  setYear = (year:number) =&gt; {
          this._selectedYear =year;
       }
  }
  </code></pre>
  
  <p>Here is my test file.</p>
  
  <pre><code> import {DataService } from ' ./sharedData.Service';
   export function main() {
      describe("DataService", () =&gt; {
          let service: DataService;
          beforeEach(function () {
              service = new DataService();
          });
  
          it("should initialize shared data service", () =&gt; {
              spyOn(service, "setYear");
              expect(service).toBeDefined();
              expect(service.setYear).toHaveBeenCalled(2015);
          });
      });
  }
  </code></pre>
  
  <p>When I run the file the test failing saying that</p>
  
  <pre><code>**Expected spy setSelectedCropYear to have been called.
  Error: Expected spy setSelectedCropYear to have been called.**
  </code></pre>
  
  <p>I am not able to figure what is wrong. Can anyone tell me what is wrong with the test please.</p>