title: getting error in calling a service while running angular2 unit tests with jasmine
body: <p>I'm working on testing an angular service, I've written code in typescript but when I run my test cases, I get error for "this.someFunction.show()" is not a function, and "this.someFunction.show()" is in my actual service.
  Here is what I'm trying to do.</p>
  
  <p><strong>myService.spec.ts</strong></p>
  
  <pre><code>import { dep1, dep......m dep-n } from '../../../../some-modules';
  describe('ServiceTest', () =&gt; {
  let cashPaymentHandlerService : CashPaymentHandlerService;
  it('for cash, when pick list enabled, 1 cash drawer, adds payment line', () =&gt; {
    methodOne(); //work fine
    methodTwo(false); //work fine
    methodThree(true); //work fine      
    methodFour(); //work fine
    methodFive(1); //work fine
    methodSix(); //work fine
    givenDependanciesAreMocked();
    whenHandlePaymentIsInvoked();
    expect(cashDrawerService.openCashDrawer).toHaveBeenCalled();
  });
  
  function givenDependanciesAreMocked(){
    TestBed.configureTestingModule({
   providers: [
     {provide: ServiceOne, useValue: serviceOne},
     {provide: ServiceTwo, useValue: serviceTwo},
     {provide: ServiceN, useValue: serviceN},
     CashPaymentHandlerService
   ]
  });
  cashPaymentHandlerService = TestBed.get(CashPaymentHandlerService);
  }
  
  function whenHandlePaymentIsInvoked() : any {
    cashPaymentHandlerService.handlePayment(cashPaymentRequest);
  }
  </code></pre>
  
  <p>Here is my <strong>cash-payment-handler.service.ts</strong> file</p>
  
  <pre><code>import { dep1, dep......m dep-n } from '../../../../some-modules';
  
  export class CashPaymentHandlerService {
  constructor(private service1 : Service1,
            private service2: Service2,
            private serviceN: ServiceN){
  }
  
  handlePayment(cashPaymentRequest: CashPaymentRequest) {
    let request = new service1();
    request.initialAmount = this.service2.dataModel.transactionDataModel.balance();
    request.onValueEntered = (response: AmountPromptResponse) =&gt; {
      if (!response.cancelled){
        this.addCashPaymentLine(response.value, cashPaymentRequest); // runs fine
      }
    };
    this.serviceN.show(request); //getting error on this line
  }
  </code></pre>
  
  <p>}</p>
  
  <p>and code from <strong>ServiceN.ts</strong> is</p>
  
  <pre><code>constructor(
  private someController: SomeController){
  }
  
  show(options?: NewRequest): void {
  if (!options){
    options = new NewRequest();
  }
  
  this.someController.show(PromptComponent, options); // PromptComponent imported from some other component
  }
  </code></pre>
  
  <p>I've searched for solutions on many forums and spent a whole day on it but couldn't get is resolved. Any help would be highly appreciated. Meherbani hosi nay. </p>