6 test('should be defined on jquery object', function () {
7 ok($(document.body).alert, 'alert method is defined')
12 // Run all tests in noConflict mode -- it's the only way to ensure that the plugin works in noConflict mode
13 $.fn.bootstrapAlert = $.fn.alert.noConflict()
15 teardown: function () {
16 $.fn.alert = $.fn.bootstrapAlert
17 delete $.fn.bootstrapAlert
21 test('should provide no conflict', function () {
22 ok(!$.fn.alert, 'alert was set back to undefined (org value)')
25 test('should return element', function () {
26 ok($(document.body).bootstrapAlert()[0] == document.body, 'document.body returned')
29 test('should fade element out on clicking .close', function () {
30 var alertHTML = '<div class="alert-message warning fade in">' +
31 '<a class="close" href="#" data-dismiss="alert">×</a>' +
32 '<p><strong>Holy guacamole!</strong> Best check yo self, you\'re not looking too good.</p>' +
34 var alert = $(alertHTML).bootstrapAlert()
36 alert.find('.close').click()
38 ok(!alert.hasClass('in'), 'remove .in class on .close click')
41 test('should remove element when clicking .close', function () {
42 $.support.transition = false
44 var alertHTML = '<div class="alert-message warning fade in">' +
45 '<a class="close" href="#" data-dismiss="alert">×</a>' +
46 '<p><strong>Holy guacamole!</strong> Best check yo self, you\'re not looking too good.</p>' +
48 var alert = $(alertHTML).appendTo('#qunit-fixture').bootstrapAlert()
50 ok($('#qunit-fixture').find('.alert-message').length, 'element added to dom')
52 alert.find('.close').click()
54 ok(!$('#qunit-fixture').find('.alert-message').length, 'element removed from dom')
57 test('should not fire closed when close is prevented', function () {
58 $.support.transition = false
60 $('<div class="alert"/>')
61 .on('close.bs.alert', function (e) {
66 .on('closed.bs.alert', function () {
69 .bootstrapAlert('close')