From c7b48513fb2cb0cdd0e4ec0050b8dbcbddc698f5 Mon Sep 17 00:00:00 2001 From: hardythe1 Date: Tue, 22 Oct 2013 17:31:15 +0530 Subject: Adding the project initial commit --- tbc/static/js/tests/unit/bootstrap-alert.js | 62 +++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100755 tbc/static/js/tests/unit/bootstrap-alert.js (limited to 'tbc/static/js/tests/unit/bootstrap-alert.js') diff --git a/tbc/static/js/tests/unit/bootstrap-alert.js b/tbc/static/js/tests/unit/bootstrap-alert.js new file mode 100755 index 0000000..9a6b514 --- /dev/null +++ b/tbc/static/js/tests/unit/bootstrap-alert.js @@ -0,0 +1,62 @@ +$(function () { + + module("bootstrap-alerts") + + 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 + }) + + 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 = '
' + , 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 = ' ' + , alert = $(alertHTML).appendTo('#qunit-fixture').alert() + + ok($('#qunit-fixture').find('.alert-message').length, 'element added to dom') + + alert.find('.close').click() + + ok(!$('#qunit-fixture').find('.alert-message').length, 'element removed from dom') + }) + + test("should not fire closed when close is prevented", function () { + $.support.transition = false + stop(); + $('') + .bind('close', function (e) { + e.preventDefault(); + ok(true); + start(); + }) + .bind('closed', function () { + ok(false); + }) + .alert('close') + }) + +}) \ No newline at end of file -- cgit