Skip to content

Commit

Permalink
Port #20198 to v3
Browse files Browse the repository at this point in the history
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
  • Loading branch information
dmethvin authored and cvrebert committed Jul 8, 2016
1 parent 4a8b29f commit bc05ef1
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 @@ -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)
Expand All @@ -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) {
Expand Down

0 comments on commit bc05ef1

Please sign in to comment.