unit test angular bootstrap modal service
<p>I have created a common <code>ModalService</code> and this is used for two diferrnt type of dialogs. <code>CancelDialog</code> and <code>ErrorDialog</code> will be popped up as per parameter passed to service.</p>

<p><strong><em>Why do we Unit Test when functionality is working fine??</em></strong></p>

<p>i.e This will show an <code>ErrorDialog</code></p>

<pre><code>ModalService.openModal('Analysis Error', 'I am Error Type', 'Error');
</code></pre>

<p>All is working fine but am stuck with Unit Test. Here is working <a href="https://plnkr.co/edit/3YdnkT4vPASzdYf44btX" rel="nofollow">PLUNKER</a>.
Please help in covering Unit Test for this.</p>

<p>How to do Unit Test for <code>openErrorModal</code> &amp; <code>openCancelModal</code> in below service.</p>

<p><strong>ModalService</strong></p>

<pre><code>// common modal service
validationApp.service('ModalService',
  function($uibModal) {

    return {
      openModal: openModal
    };

    function openErrorModal(title, message, callback) {
      $uibModal.open({
        templateUrl: 'ErrorDialog.html',
        controller: 'ErrorDialogCtrl',
        controllerAs: 'vm',
        backdrop: 'static',
        size: 'md',
        resolve: {
          message: function() {
            return message;
          },
          title: function() {
            return title;
          },
          callback: function() {
            return callback;
          }
        }
      });
    }

    function openCancelModal(title, message, callback) {
      $uibModal.open({
        templateUrl: 'CancelDialog.html',
        controller: 'ErrorDialogCtrl',
        controllerAs: 'vm',
        backdrop: 'static',
        size: 'md',
        resolve: {
          message: function() {
            return message;
          },
          title: function() {
            return title;
          },
          callback: function() {
            return callback;
          }
        }
      });
    }

    function openModal(title, message, modalType, callback) {
      if (modalType === "Error") {
        openErrorModal(title, message, callback);
      } else {
        openCancelModal(title, message, callback);
      }
    }
  }
);
</code></pre>

<p>How to Unit Test <code>onOk</code> , <code>onContinue</code> &amp; <code>onDiscard</code> in below controller.</p>

<p><strong>DialogController</strong></p>

<pre><code>//controller fot dialog
validationApp.controller('ErrorDialogCtrl',
  function($uibModalInstance, message, title, callback) {
    alert('from controller');
    var vm = this;
    vm.message = message;
    vm.onOk = onOk;
    vm.onContinue = onContinue;
    vm.onDiscard = onDiscard;
    vm.callback = callback;
    vm.title = title;

    function onOk() {
      $uibModalInstance.close();
    }

    function onContinue() {
      $uibModalInstance.close();
    }

    function onDiscard() {
      vm.callback();
      $uibModalInstance.close();
    }
  });
</code></pre>