]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
fix up tests
authorfat <fat@folders.local>
Wed, 13 May 2015 20:46:08 +0000 (13:46 -0700)
committerfat <fat@folders.local>
Wed, 13 May 2015 20:46:08 +0000 (13:46 -0700)
js/tests/unit/scrollspy.js

index a4407ece96ab6a9e149ddd79c85c2f0acb093700..063dfabcfbba5c4f3567b8253aaf49fba23b0da3 100644 (file)
@@ -112,7 +112,7 @@ $(function () {
     var $scrollspy = $section
       .show()
       .find('#scrollspy-example')
-      .bootstrapScrollspy({ target: $('#ss-target') })
+      .bootstrapScrollspy({ target: document.getElementById('#ss-target') })
 
     $scrollspy.on('scroll.bs.scrollspy', function () {
       assert.ok($section.hasClass('active'), '"active" class still on root node')
@@ -321,89 +321,89 @@ $(function () {
   })
 
   QUnit.test('should allow passed in option offset method: offset', function (assert) {
-      assert.expect(4)
-
-      var testOffsetMethod = function (type) {
-        var deferred = $.Deferred()
-        var navbarHtml =
-            '<nav class="navbar"' + (type === 'data' ? ' id="navbar-offset-method-menu"' : '') + '>'
-          + '<ul class="nav">'
-          + '<li id="li-' + type + 'm-1"><a href="#div-' + type + 'm-1">div 1</a></li>'
-          + '<li id="li-' + type + 'm-2"><a href="#div-' + type + 'm-2">div 2</a></li>'
-          + '<li id="li-' + type + 'm-3"><a href="#div-' + type + 'm-3">div 3</a></li>'
-          + '</ul>'
-          + '</nav>'
-        var contentHtml =
-            '<div class="content"' + (type === 'data' ? ' data-spy="scroll" data-target="#navbar-offset-method-menu" data-offset="0" data-method="offset"' : '') + ' style="position: relative; overflow: auto; height: 100px">'
-          + '<div id="div-' + type + 'm-1" style="position: relative; height: 200px; padding: 0; margin: 0">div 1</div>'
-          + '<div id="div-' + type + 'm-2" style="position: relative; height: 150px; padding: 0; margin: 0">div 2</div>'
-          + '<div id="div-' + type + 'm-3" style="position: relative; height: 250px; padding: 0; margin: 0">div 3</div>'
-          + '</div>'
-
-
-        $(navbarHtml).appendTo('#qunit-fixture')
-        var $content = $(contentHtml)
-          .appendTo('#qunit-fixture')
-
-        if (type === 'js') $content.bootstrapScrollspy({ target: '.navbar', offset: 0, method: 'offset' })
-        else if (type === 'data') $(window).trigger('load.bs.scrollspy.data-api')
-
-        var $target = $('#div-' + type + 'm-2')
-        var scrollspy = $content.data('bs.scrollspy')
-
-        assert.ok(scrollspy._offsets[1] === $target.offset().top, 'offsed method with ' + type + ' option')
-        assert.ok(scrollspy._offsets[1] !== $target.position().top, 'position method with ' + type + ' option')
+    assert.expect(4)
 
-        deferred.resolve()
+    var testOffsetMethod = function (type) {
+      var deferred = $.Deferred()
+      var navbarHtml =
+          '<nav class="navbar"' + (type === 'data' ? ' id="navbar-offset-method-menu"' : '') + '>'
+        + '<ul class="nav">'
+        + '<li id="li-' + type + 'm-1"><a href="#div-' + type + 'm-1">div 1</a></li>'
+        + '<li id="li-' + type + 'm-2"><a href="#div-' + type + 'm-2">div 2</a></li>'
+        + '<li id="li-' + type + 'm-3"><a href="#div-' + type + 'm-3">div 3</a></li>'
+        + '</ul>'
+        + '</nav>'
+      var contentHtml =
+          '<div class="content"' + (type === 'data' ? ' data-spy="scroll" data-target="#navbar-offset-method-menu" data-offset="0" data-method="offset"' : '') + ' style="position: relative; overflow: auto; height: 100px">'
+        + '<div id="div-' + type + 'm-1" style="position: relative; height: 200px; padding: 0; margin: 0">div 1</div>'
+        + '<div id="div-' + type + 'm-2" style="position: relative; height: 150px; padding: 0; margin: 0">div 2</div>'
+        + '<div id="div-' + type + 'm-3" style="position: relative; height: 250px; padding: 0; margin: 0">div 3</div>'
+        + '</div>'
 
-        return deferred.promise()
-      }
 
-      $.when(testOffsetMethod('js'))
-        .then(function () { testOffsetMethod('data') })
-    })
+      $(navbarHtml).appendTo('#qunit-fixture')
+      var $content = $(contentHtml)
+        .appendTo('#qunit-fixture')
 
-    QUnit.test('should allow passed in option offset method: position', function (assert) {
-      assert.expect(4)
+      if (type === 'js') $content.bootstrapScrollspy({ target: '.navbar', offset: 0, method: 'offset' })
+      else if (type === 'data') $(window).trigger('load.bs.scrollspy.data-api')
 
-      var testOffsetMethod = function (type) {
-        var deferred = $.Deferred()
-        var navbarHtml =
-            '<nav class="navbar"' + (type === 'data' ? ' id="navbar-offset-method-menu"' : '') + '>'
-          + '<ul class="nav">'
-          + '<li id="li-' + type + 'm-1"><a href="#div-' + type + 'm-1">div 1</a></li>'
-          + '<li id="li-' + type + 'm-2"><a href="#div-' + type + 'm-2">div 2</a></li>'
-          + '<li id="li-' + type + 'm-3"><a href="#div-' + type + 'm-3">div 3</a></li>'
-          + '</ul>'
-          + '</nav>'
-        var contentHtml =
-            '<div class="content"' + (type === 'data' ? ' data-spy="scroll" data-target="#navbar-offset-method-menu" data-offset="0" data-method="position"' : '') + ' style="position: relative; overflow: auto; height: 100px">'
-          + '<div id="div-' + type + 'm-1" style="position: relative; height: 200px; padding: 0; margin: 0">div 1</div>'
-          + '<div id="div-' + type + 'm-2" style="position: relative; height: 150px; padding: 0; margin: 0">div 2</div>'
-          + '<div id="div-' + type + 'm-3" style="position: relative; height: 250px; padding: 0; margin: 0">div 3</div>'
-          + '</div>'
+      var $target = $('#div-' + type + 'm-2')
+      var scrollspy = $content.data('bs.scrollspy')
 
+      assert.ok(scrollspy._offsets[1] === $target.offset().top, 'offsed method with ' + type + ' option')
+      assert.ok(scrollspy._offsets[1] !== $target.position().top, 'position method with ' + type + ' option')
 
-        $(navbarHtml).appendTo('#qunit-fixture')
-        var $content = $(contentHtml)
-          .appendTo('#qunit-fixture')
+      deferred.resolve()
 
-        if (type === 'js') $content.bootstrapScrollspy({ target: '.navbar', offset: 0, method: 'position' })
-        else if (type === 'data') $(window).trigger('load.bs.scrollspy.data-api')
+      return deferred.promise()
+    }
 
-        var $target = $('#div-' + type + 'm-2')
-        var scrollspy = $content.data('bs.scrollspy')
+    $.when(testOffsetMethod('js'))
+      .then(function () { testOffsetMethod('data') })
+  })
 
-        assert.ok(scrollspy._offsets[1] !== $target.offset().top, 'offsed method with ' + type + ' option')
-        assert.ok(scrollspy._offsets[1] === $target.position().top, 'position method with ' + type + ' option')
+  QUnit.test('should allow passed in option offset method: position', function (assert) {
+    assert.expect(4)
 
-        deferred.resolve()
+    var testOffsetMethod = function (type) {
+      var deferred = $.Deferred()
+      var navbarHtml =
+          '<nav class="navbar"' + (type === 'data' ? ' id="navbar-offset-method-menu"' : '') + '>'
+        + '<ul class="nav">'
+        + '<li id="li-' + type + 'm-1"><a href="#div-' + type + 'm-1">div 1</a></li>'
+        + '<li id="li-' + type + 'm-2"><a href="#div-' + type + 'm-2">div 2</a></li>'
+        + '<li id="li-' + type + 'm-3"><a href="#div-' + type + 'm-3">div 3</a></li>'
+        + '</ul>'
+        + '</nav>'
+      var contentHtml =
+          '<div class="content"' + (type === 'data' ? ' data-spy="scroll" data-target="#navbar-offset-method-menu" data-offset="0" data-method="position"' : '') + ' style="position: relative; overflow: auto; height: 100px">'
+        + '<div id="div-' + type + 'm-1" style="position: relative; height: 200px; padding: 0; margin: 0">div 1</div>'
+        + '<div id="div-' + type + 'm-2" style="position: relative; height: 150px; padding: 0; margin: 0">div 2</div>'
+        + '<div id="div-' + type + 'm-3" style="position: relative; height: 250px; padding: 0; margin: 0">div 3</div>'
+        + '</div>'
 
-        return deferred.promise()
-      }
 
-      $.when(testOffsetMethod('js'))
-        .then(function () { testOffsetMethod('data') })
-    })
+      $(navbarHtml).appendTo('#qunit-fixture')
+      var $content = $(contentHtml)
+        .appendTo('#qunit-fixture')
+
+      if (type === 'js') $content.bootstrapScrollspy({ target: '.navbar', offset: 0, method: 'position' })
+      else if (type === 'data') $(window).trigger('load.bs.scrollspy.data-api')
+
+      var $target = $('#div-' + type + 'm-2')
+      var scrollspy = $content.data('bs.scrollspy')
+
+      assert.ok(scrollspy._offsets[1] !== $target.offset().top, 'offsed method with ' + type + ' option')
+      assert.ok(scrollspy._offsets[1] === $target.position().top, 'position method with ' + type + ' option')
+
+      deferred.resolve()
+
+      return deferred.promise()
+    }
+
+    $.when(testOffsetMethod('js'))
+      .then(function () { testOffsetMethod('data') })
+  })
 
 })