bootstrap-tab.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. $(function () {
  2. module("bootstrap-tabs")
  3. test("should be defined on jquery object", function () {
  4. ok($(document.body).tab, 'tabs method is defined')
  5. })
  6. test("should return element", function () {
  7. ok($(document.body).tab()[0] == document.body, 'document.body returned')
  8. })
  9. test("should activate element by tab id", function () {
  10. var tabsHTML =
  11. '<ul class="tabs">'
  12. + '<li><a href="#home">Home</a></li>'
  13. + '<li><a href="#profile">Profile</a></li>'
  14. + '</ul>'
  15. $('<ul><li id="home"></li><li id="profile"></li></ul>').appendTo("#qunit-fixture")
  16. $(tabsHTML).find('li:last a').tab('show')
  17. equals($("#qunit-fixture").find('.active').attr('id'), "profile")
  18. $(tabsHTML).find('li:first a').tab('show')
  19. equals($("#qunit-fixture").find('.active').attr('id'), "home")
  20. })
  21. test("should activate element by tab id", function () {
  22. var pillsHTML =
  23. '<ul class="pills">'
  24. + '<li><a href="#home">Home</a></li>'
  25. + '<li><a href="#profile">Profile</a></li>'
  26. + '</ul>'
  27. $('<ul><li id="home"></li><li id="profile"></li></ul>').appendTo("#qunit-fixture")
  28. $(pillsHTML).find('li:last a').tab('show')
  29. equals($("#qunit-fixture").find('.active').attr('id'), "profile")
  30. $(pillsHTML).find('li:first a').tab('show')
  31. equals($("#qunit-fixture").find('.active').attr('id'), "home")
  32. })
  33. })