Skip to content

Commit 14b5763

Browse files
committed
Add test for when $.rails.confirm throws
1 parent 77567e7 commit 14b5763

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/public/test/data-confirm.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,27 @@ asyncTest('clicking on a button with data-confirm attribute. Confirm No.', 3, fu
117117
}, 50);
118118
});
119119

120+
asyncTest('clicking on a button with data-confirm attribute. Confirm error.', 3, function() {
121+
var message;
122+
// auto-decline:
123+
window.confirm = function(msg) { message = msg; throw "some random error"; };
124+
125+
$('button[data-confirm]')
126+
.bind('confirm:complete', function(e, data) {
127+
App.assertCallbackInvoked('confirm:complete');
128+
ok(data == false, 'confirm:complete passes in confirm answer (false)');
129+
})
130+
.bind('ajax:beforeSend', function(e, data, status, xhr) {
131+
App.assertCallbackNotInvoked('ajax:beforeSend');
132+
})
133+
.trigger('click');
134+
135+
setTimeout(function() {
136+
equal(message, 'Are you absolutely sure?');
137+
start();
138+
}, 50);
139+
});
140+
120141
asyncTest('clicking on a submit button with form and data-confirm attributes. Confirm No.', 3, function() {
121142
var message;
122143
// auto-decline:

0 commit comments

Comments
 (0)