title: Spy on a service method call using jasmine Spies
body: <p>I have the following controller <strong>ViewMeetingCtrl.js</strong></p>
  
  <pre><code>(function () {
      'use strict';
      angular.module('MyApp').controller('ViewMeetingCtrl', ViewMeetingCtrl);
  
      ViewMeetingCtrl.$inject = ['$scope', '$state', '$http', '$translate', 'notificationService', 'meetingService', '$modal', 'meeting', 'attachmentService'];
  
      function ViewMeetingCtrl($scope, $state, $http, $translate, notificationService, meetingService, $modal, meeting, attachmentService) {
          $scope.meeting = meeting; 
  
          $scope.cancelMeeting = cancelMeeting;
  
          function cancelMeeting(meetingId, companyId) {
              meetingService.sendCancelNotices(companyId, meetingId)
                  .success(function () {
                      $state.go('company.view');
                  });
          }      
      }
  })();
  </code></pre>
  
  <p>I was able to succussfully invoke the spyOn for <strong>cancelMeeting()</strong> but not with the calling of <strong>sendCancelNotices</strong> method. What i want to do is , i want to test that whenever <strong>cancelMeeting()</strong> gets called , it calls <strong>sendCancelNotices()</strong> method . I know that i should go with createSpy method to do this . But i am not sure how to do it .</p>
  
  <p>Below is the test case ViewMeetingCtrlSpec.js</p>
  
  <pre><code>describe('ViewMeetingCtrl CreateSpy --&gt; Spying --&gt; cancelMeeting', function () {
          var $rootScope, scope, $controller , $q  ;
  
  
          var sendCancelNoticesSpy = jasmine.createSpy('sendCancelNoticesSpy');
  
  
          beforeEach(angular.mock.module('MyApp'));
  
          beforeEach(inject(function ($rootScope, $controller ) {
              scope = $rootScope.$new();
              createController = function() {
                  return $controller('ViewMeetingCtrl', {
                  $scope: scope,
                  meeting : {}
                  }); 
              };
              var controller = new createController();
          }));
  
          it("tracks that the cancelMeeting spy was called", function() {
              //some assertion
          });
  
  });
  </code></pre>