Skip to content

Commit

Permalink
Port #20190 to v3
Browse files Browse the repository at this point in the history
Scrollspy test: Allow for async .then() in jQuery 3; fixes #20182

Instead of doing a new assert.async(), just do a single one for the entire test
and let the .then() be async as well.
  • Loading branch information
dmethvin authored and cvrebert committed Jul 8, 2016
1 parent daad359 commit 4a8b29f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions js/tests/unit/scrollspy.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,21 +258,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() })
})

})

0 comments on commit 4a8b29f

Please sign in to comment.