2011-09-10 01:47:49 -04:00
|
|
|
|
$(function () {
|
|
|
|
|
|
2013-05-16 23:19:51 -04:00
|
|
|
|
module("alert")
|
2011-09-10 01:47:49 -04:00
|
|
|
|
|
2012-12-07 17:06:01 -05:00
|
|
|
|
test("should provide no conflict", function () {
|
|
|
|
|
var alert = $.fn.alert.noConflict()
|
|
|
|
|
ok(!$.fn.alert, 'alert was set back to undefined (org value)')
|
|
|
|
|
$.fn.alert = alert
|
|
|
|
|
})
|
|
|
|
|
|
2011-09-10 01:47:49 -04:00
|
|
|
|
test("should be defined on jquery object", function () {
|
|
|
|
|
ok($(document.body).alert, 'alert method is defined')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test("should return element", function () {
|
|
|
|
|
ok($(document.body).alert()[0] == document.body, 'document.body returned')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test("should fade element out on clicking .close", function () {
|
|
|
|
|
var alertHTML = '<div class="alert-message warning fade in">'
|
2011-12-20 21:02:47 -05:00
|
|
|
|
+ '<a class="close" href="#" data-dismiss="alert">×</a>'
|
2012-02-06 03:17:31 -05:00
|
|
|
|
+ '<p><strong>Holy guacamole!</strong> Best check yo self, you\'re not looking too good.</p>'
|
2011-09-10 01:47:49 -04:00
|
|
|
|
+ '</div>'
|
|
|
|
|
, alert = $(alertHTML).alert()
|
|
|
|
|
|
|
|
|
|
alert.find('.close').click()
|
|
|
|
|
|
|
|
|
|
ok(!alert.hasClass('in'), 'remove .in class on .close click')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test("should remove element when clicking .close", function () {
|
|
|
|
|
$.support.transition = false
|
|
|
|
|
|
|
|
|
|
var alertHTML = '<div class="alert-message warning fade in">'
|
2011-12-20 21:02:47 -05:00
|
|
|
|
+ '<a class="close" href="#" data-dismiss="alert">×</a>'
|
2012-02-06 03:17:31 -05:00
|
|
|
|
+ '<p><strong>Holy guacamole!</strong> Best check yo self, you\'re not looking too good.</p>'
|
2011-09-10 01:47:49 -04:00
|
|
|
|
+ '</div>'
|
2011-12-20 21:02:47 -05:00
|
|
|
|
, alert = $(alertHTML).appendTo('#qunit-fixture').alert()
|
2011-09-10 01:47:49 -04:00
|
|
|
|
|
2011-12-20 21:02:47 -05:00
|
|
|
|
ok($('#qunit-fixture').find('.alert-message').length, 'element added to dom')
|
2011-09-10 01:47:49 -04:00
|
|
|
|
|
|
|
|
|
alert.find('.close').click()
|
|
|
|
|
|
2011-12-20 21:02:47 -05:00
|
|
|
|
ok(!$('#qunit-fixture').find('.alert-message').length, 'element removed from dom')
|
2011-09-10 01:47:49 -04:00
|
|
|
|
})
|
|
|
|
|
|
2012-03-24 21:20:09 -04:00
|
|
|
|
test("should not fire closed when close is prevented", function () {
|
|
|
|
|
$.support.transition = false
|
|
|
|
|
stop();
|
|
|
|
|
$('<div class="alert"/>')
|
2013-05-16 23:19:51 -04:00
|
|
|
|
.on('close.bs.alert', function (e) {
|
2012-03-24 21:20:09 -04:00
|
|
|
|
e.preventDefault();
|
|
|
|
|
ok(true);
|
|
|
|
|
start();
|
|
|
|
|
})
|
2013-05-16 23:19:51 -04:00
|
|
|
|
.on('closed.bs.alert', function () {
|
2012-03-24 21:20:09 -04:00
|
|
|
|
ok(false);
|
|
|
|
|
})
|
|
|
|
|
.alert('close')
|
|
|
|
|
})
|
|
|
|
|
|
2013-04-23 03:34:27 -04:00
|
|
|
|
})
|