Is there a way to test confirm message?

Is there a way to test confirm message?

I am trying to write a test for following method.

  1. $('#clickme').live('click', function() {
  2. if (confirm('Are you sure?')) {
  3. doSomething();
  4. }
  5. return false;
  6. });

I was wondering how to test confirm method. Is there a way to override confirm method.

If not then I was thinking of moving the confirm method to a different method and then I should mock that method to return true or false depending on test case.

Just want to know what others do in such cases to test a method.