title: How to test multiple sequential calls with Jasmine
body: <p>I am trying to test a function that unsubscribes from all subscriptions:</p>
  
  <pre><code>ngOnDestroy() {
          this.tryUnsubscribe(this.carsSubscription);
          this.tryUnsubscribe(this.partsSubscription);
          this.tryUnsubscribe(this.shopsSubscription);
      }
  </code></pre>
  
  <p>This is the test I wrote for the function:</p>
  
  <pre><code>it('should unsubscribe from subscriptions ', () =&gt; { 
        spyOn(component, "tryUnsubscribe");     
        component.ngOnDestroy();
        expect(component.tryUnsubscribe).toHaveBeenCalledWith(component['carsSubscription']);
        expect(component.tryUnsubscribe).toHaveBeenCalledWith(component['partsSubscription']);
        expect(component.tryUnsubscribe).toHaveBeenCalledWith(component['shopsSubscription']);
      });
  </code></pre>
  
  <p>The problem:</p>
  
  <p>If I comment out a function call, the tests still passes.</p>
  
  <pre><code>ngOnDestroy() {
          this.tryUnsubscribe(this.carsSubscription);
          //this.tryUnsubscribe(this.partsSubscription);
          this.tryUnsubscribe(this.shopsSubscription);
      }
  </code></pre>
  
  <p>Only if I comment out all of these function calls, the test fails:</p>
  
  <pre><code>ngOnDestroy() {
          //this.tryUnsubscribe(this.carsSubscription);
          //this.tryUnsubscribe(this.partsSubscription);
          //this.tryUnsubscribe(this.shopsSubscription);
      }
  </code></pre>
  
  <p>How to properly test this kind of function? What am I doing wrong?</p>