title: mocking bootstrap datepicker in jasmine
body: <p>I am trying to access datepicker onClose method via mocking its not working.i have injected all required bootstrap module in spec file  </p>
  
  <pre><code>define(['angular', 'app'], function(angular, myApp) {
  myApp.directive('customdate', function() {
      var linkFn = function(scope, element, attrs, ngModelCtrl) {
          element.datepicker({
              dateFormat: attrs.format || 'yy/mm/dd',
              changeMonth: true,
              changeYear: true,
              onClose: function(date) {
                  if (attrs.datetype === 'fromField') {
                      var elem = angular.element('#' + attrs.todateid);
                      elem.datepicker("option", "minDate", date).datepicker('setDate', date).focus();
                      var toDate = date || '';
                      scope.dateRange[attrs.todateid] = toDate;
                      setTimeout(function() {
                          elem.datepicker('show')
                      }, 0);
                  }
              }
          });
      };
  
      return {
          restrict: 'A',
          require: 'ngModel',
          link: linkFn
      };
  });});
  </code></pre>
  
  <p>and in spec file i m trying to validate directive which is using datepicker in link function </p>
  
  <pre><code>define(
  ['jquery', 'angular', 'app', 'uiBootstrap',
      'datepicker_drtv'
  ],
  function() {
      'use strict';
      describe('Test Suit', function() {
          var datePickerElement;
          var $compile, $rootScope, scope;
          var tpl;
  
  
          beforeEach(function() {
              angular.mock.module('myApp');
              angular.mock.inject(function(_$rootScope_, _$compile_) {
                  $compile = _$compile_;
                  $rootScope = _$rootScope_;
                  scope = $rootScope.$new();
  
  
              });
          });
  
          it('- check initial setup', function() {
              scope.startDate = '2016-09-29T00:00:00.000+0000';
              tpl = "&lt;input type='text' id='startdateFrom' customdate datetype='fromField' todateid='startdateTo' class='fromTxt' ng-model='startDate' readonly /&gt;";
              var element = $compile(tpl)(scope);
              scope.$digest();
              element.val(scope.startDate).trigger("input");
  
              element.datepicker('option', 'onClose');
              var eVal = element.val();
  
              expect(angular.element(element).val()).toEqual(eVal);
          });
  
      });
  });
  </code></pre>
  
  <p>test case is not failing  but in coverage report, link function is not covering </p>