]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Scrollspy test: Allow for async .then() in jQuery 3; fixes #20182
authorDave Methvin <dave.methvin@gmail.com>
Tue, 28 Jun 2016 01:41:00 +0000 (21:41 -0400)
committerChris Rebert <code@chrisrebert.com>
Tue, 28 Jun 2016 05:37:31 +0000 (22:37 -0700)
Instead of doing a new assert.async(), just do a single one for the entire test
and let the .then() be async as well.

Closes #20190

js/tests/unit/scrollspy.js

index b04a9d863148a2b770a570a85b944ed321aef716..772fedc2ec31a1e1396db306bb4f2d3ced7d1046 100644 (file)
@@ -314,21 +314,21 @@ $(function () {
     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)
       return deferred.promise()
     }
 
+    var done = assert.async()
     $.when(testElementIsActiveAfterScroll('#li-100-5', '#div-100-5'))
       .then(function () { return testElementIsActiveAfterScroll('#li-100-4', '#div-100-4') })
       .then(function () { return testElementIsActiveAfterScroll('#li-100-3', '#div-100-3') })
       .then(function () { return testElementIsActiveAfterScroll('#li-100-2', '#div-100-2') })
       .then(function () { return testElementIsActiveAfterScroll('#li-100-1', '#div-100-1') })
+      .then(function () { done() })
   })
 
   QUnit.test('should allow passed in option offset method: offset', function (assert) {