2011-09-10 07:47:49 +02:00
|
|
|
|
$(function () {
|
|
|
|
|
|
|
|
|
|
module("bootstrap-alerts")
|
|
|
|
|
|
|
|
|
|
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-21 03:02:47 +01:00
|
|
|
|
+ '<a class="close" href="#" data-dismiss="alert">×</a>'
|
2012-02-06 09:17:31 +01:00
|
|
|
|
+ '<p><strong>Holy guacamole!</strong> Best check yo self, you\'re not looking too good.</p>'
|
2011-09-10 07:47:49 +02: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-21 03:02:47 +01:00
|
|
|
|
+ '<a class="close" href="#" data-dismiss="alert">×</a>'
|
2012-02-06 09:17:31 +01:00
|
|
|
|
+ '<p><strong>Holy guacamole!</strong> Best check yo self, you\'re not looking too good.</p>'
|
2011-09-10 07:47:49 +02:00
|
|
|
|
+ '</div>'
|
2011-12-21 03:02:47 +01:00
|
|
|
|
, alert = $(alertHTML).appendTo('#qunit-fixture').alert()
|
2011-09-10 07:47:49 +02:00
|
|
|
|
|
2011-12-21 03:02:47 +01:00
|
|
|
|
ok($('#qunit-fixture').find('.alert-message').length, 'element added to dom')
|
2011-09-10 07:47:49 +02:00
|
|
|
|
|
|
|
|
|
alert.find('.close').click()
|
|
|
|
|
|
2011-12-21 03:02:47 +01:00
|
|
|
|
ok(!$('#qunit-fixture').find('.alert-message').length, 'element removed from dom')
|
2011-09-10 07:47:49 +02:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
})
|