]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Port #20198 to v3 20259/head
authorDave Methvin <dave.methvin@gmail.com>
Tue, 28 Jun 2016 20:24:28 +0000 (13:24 -0700)
committerChris Rebert <code@chrisrebert.com>
Fri, 8 Jul 2016 06:32:50 +0000 (23:32 -0700)
ScrollSpy unit test: Use single done() in a then() instead of multiple done()s

Fixes test flakiness on OS X Safari and Android when using jQuery 3.
Fixes #20182 more
Refs #20191

js/tests/unit/scrollspy.js

index d50573f27a194276c51b78e59b5be7f593907aae..be6808e2e670438a4bf0923321a23eb72d8097a7 100644 (file)
@@ -131,13 +131,12 @@ $(function () {
       .appendTo('#qunit-fixture')
       .bootstrapScrollspy({ offset: 0, target: '.navbar' })
 
+    var done = assert.async()
     var testElementIsActiveAfterScroll = function (element, target) {
       var deferred = $.Deferred()
       var scrollHeight = Math.ceil($content.scrollTop() + $(target).position().top)
-      var done = assert.async()
       $content.one('scroll', function () {
         assert.ok($(element).hasClass('active'), 'target:' + target + ', element' + element)
-        done()
         deferred.resolve()
       })
       $content.scrollTop(scrollHeight)
@@ -146,6 +145,7 @@ $(function () {
 
     $.when(testElementIsActiveAfterScroll('#li-1', '#div-1'))
       .then(function () { return testElementIsActiveAfterScroll('#li-2', '#div-2') })
+      .then(function () { done() })
   })
 
   QUnit.test('should add the active class correctly when there are nested elements at 0 scroll offset', function (assert) {