title: Jasmine Test: How to mock a method inside a controller in AngularJS
body: <p>I am using angularjs and my controller looks like this:</p>
  
  <pre><code>(function (app) {
  
  var myController = function ($scope, myService) {
  
      var onData = function (response) {
  
          if (!response.data || response.data.length === 0) {
  
              app.showErrorMessage('Error');
  
          } else {
              $scope.myData = response.data;
  
              drawChart();
          }
  
          $scope.loading = false;
      };
  
      var init = function () {
          $scope.loading = true;
          myService.getContBreakdown().then(onData, onError);
      };
  
  
      var drawChart = function () {
      // Some Code
  
      };
  
      init();
  };
  
    app.controller('myController', ['$scope', 'myService', myController]);
  }(angular.module('app')));
  </code></pre>
  
  <p>I am writing a jasmine test suit to test the data received from the myService, and mock the call to  drawChart() method. How should I write the a simple jasmine test suit to mock the call to the drawChart() method?  </p>