1
0

bootstrap-scrollspy.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. $(function () {
  2. module("bootstrap-scrollspy")
  3. test("should provide no conflict", function () {
  4. var scrollspy = $.fn.scrollspy.noConflict()
  5. ok(!$.fn.scrollspy, 'scrollspy was set back to undefined (org value)')
  6. $.fn.scrollspy = scrollspy
  7. })
  8. test("should be defined on jquery object", function () {
  9. ok($(document.body).scrollspy, 'scrollspy method is defined')
  10. })
  11. test("should return element", function () {
  12. ok($(document.body).scrollspy()[0] == document.body, 'document.body returned')
  13. })
  14. test("should switch active class on scroll", function () {
  15. var sectionHTML = '<div id="masthead"></div>'
  16. , $section = $(sectionHTML).append('#qunit-fixture')
  17. , topbarHTML ='<div class="topbar">'
  18. + '<div class="topbar-inner">'
  19. + '<div class="container">'
  20. + '<h3><a href="#">Bootstrap</a></h3>'
  21. + '<ul class="nav">'
  22. + '<li><a href="#masthead">Overview</a></li>'
  23. + '</ul>'
  24. + '</div>'
  25. + '</div>'
  26. + '</div>'
  27. , $topbar = $(topbarHTML).scrollspy()
  28. ok($topbar.find('.active', true))
  29. })
  30. })