bootstrap-alert.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. $(function () {
  2. module("bootstrap-alerts")
  3. test("should be defined on jquery object", function () {
  4. ok($(document.body).alert, 'alert method is defined')
  5. })
  6. test("should return element", function () {
  7. ok($(document.body).alert()[0] == document.body, 'document.body returned')
  8. })
  9. test("should fade element out on clicking .close", function () {
  10. var alertHTML = '<div class="alert-message warning fade in">'
  11. + '<a class="close" href="#" data-dismiss="alert">×</a>'
  12. + '<p><strong>Holy guacamole!</strong> Best check yo self, you\'re not looking too good.</p>'
  13. + '</div>'
  14. , alert = $(alertHTML).alert()
  15. alert.find('.close').click()
  16. ok(!alert.hasClass('in'), 'remove .in class on .close click')
  17. })
  18. test("should remove element when clicking .close", function () {
  19. $.support.transition = false
  20. var alertHTML = '<div class="alert-message warning fade in">'
  21. + '<a class="close" href="#" data-dismiss="alert">×</a>'
  22. + '<p><strong>Holy guacamole!</strong> Best check yo self, you\'re not looking too good.</p>'
  23. + '</div>'
  24. , alert = $(alertHTML).appendTo('#qunit-fixture').alert()
  25. ok($('#qunit-fixture').find('.alert-message').length, 'element added to dom')
  26. alert.find('.close').click()
  27. ok(!$('#qunit-fixture').find('.alert-message').length, 'element removed from dom')
  28. })
  29. })