title: Angular 5 Unit Testing Service UPDATE Method
body: <p>I am using stepper back step next step and at last step when user clicks done I called a service to update user data I have tested <code>backStep()</code> and <code>nextStep()</code> methods however I want to test <code>updateAdmin()</code> method to update a boolean value. Here is my code</p>
  
  <p>P.S: How to test a service which UPDATE data and returns the response?</p>
  
  <p>Controller:</p>
  
  <pre><code>backStep(step: number) {
  this.currentStep = --step;
  this.currentSlide.emit(this.currentStep);
  }
  
  nextStep(step: number) {
  if (++step &lt;= this.totalSteps.length) {
    this.currentStep = step;
    this.currentSlide.emit(this.currentStep);
  } else {
    this.updateAdmin();
   }
  }
  
  updateAdmin() {
    const body = {
     is_admin: true
    }
  
  this.adminService.updateAdmin(user_id, body).subscribe(
    (response) =&gt; {
      console.log(response);
     }
   );
  }
  </code></pre>
  
  <p>Unite Tests</p>
  
  <pre><code>it('backStep() should decrement current step', () =&gt; {
    comp.backStep(2);
    expect(comp.currentStep).toEqual(1);
  });
  
  it('nextStep() should increment current step', () =&gt; {
    const start = 1;
    comp.totalSteps = Array.from(Array(4), (_, i) =&gt; start + i);
    comp.nextStep(1);
    expect(comp.currentStep).toEqual(2);
   });
  
  it('Should call updateAdmin method and test mock service', () =&gt; {
    const start = 1;
    comp.totalSteps = Array.from(Array(4), (_, i) =&gt; start + i);
    comp.nextStep(4);
  //when steps reached to max limit (4) I need to call a mock service which should update a field and return response, here I dont know how to test updateAdmin() method.
    });
  });
  </code></pre>
  
  <p>Thanks in advance.</p>