JavaScript how to mock confirm method
<p>I have following code in my JavaScript code.</p>

<pre><code>if (window.confirm('Are you sure?')) {
    AdminData.actOnResult('delete');
}
</code></pre>

<p>I am writing test for this piece of code. How do I mock window.confirm method? I tried following code but it did not work.</p>

<pre><code>window.confirm = function(arg) {
    return true;
};
</code></pre>

<p>I can move the window.confirm method to another function and then I can mock that method. However I was wondering if there is a better solution.</p>
