title: How to spy on $window.confirm with Karma / Jasmine?
body: <p>I am using Angular and my controller has:</p>
  
  <pre><code>        clearCustom: function () {
              // make sure they are doing this on purpose
              if (!$window.confirm('Are you sure you want to delete this phone number?')) return;
  
              if ($scope.model.originalPhoneSms === $scope.model.phoneCustom) {
                  $scope.model.patient.phoneSms = '';
                  $scope.model.patient.phoneSmsVerified = false;
                  $scope.model.originalPhoneSms = '';
                  cache.set('patient', 'currentPatient', $scope.model.patient);
              }
              $scope.model.phoneCustom = '';
              $scope.save();
          }
  </code></pre>
  
  <p>My test is:</p>
  
  <pre><code>it('should confirm that the user is trying to clear the custom phone number', function() {
      scope.clearCustom();
  
      var windowMock = jasmine.createSpyObj('$window', ['confirm']);
  
      expect(windowMock.confirm).toHaveBeenCalled();
  });
  </code></pre>
  
  <p>But it fails with <code>Expected spy $window.confirm to have been called.</code></p>
  
  <p>What am I doing incorrectly?</p>