From: Nick O'Donoghue Date: Mon, 17 Nov 2014 00:42:55 +0000 (+0000) Subject: add unit test for affix-top for padding issue X-Git-Tag: v3.3.2~50^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=da79ab94889dd72c83245c376e278a4c378f84b4;p=thirdparty%2Fbootstrap.git add unit test for affix-top for padding issue --- diff --git a/js/tests/unit/affix.js b/js/tests/unit/affix.js index ef6ef74b91..2e82a7dbfb 100644 --- a/js/tests/unit/affix.js +++ b/js/tests/unit/affix.js @@ -68,4 +68,33 @@ $(function () { }, 16) // for testing in a browser }, 0) }) + + test('should affix-top when scrolling up to offset when parent has padding', function () { + stop() + + var templateHTML = '
' + + '
' + + '

Testing affix-top class is added

' + + '
' + + '
' + + '
' + $(templateHTML).appendTo(document.body) + + $('#affixTopTarget') + .bootstrapAffix({ + offset: { top: 120, bottom: 0 } + }) + .on('affixed-top.bs.affix', function () { + ok($('#affixTopTarget').hasClass('affix-top'), 'affix-top class applied') + start() + }) + + setTimeout(function () { + window.scrollTo(0, document.body.scrollHeight) + + setTimeout(function () { + window.scroll(0, 119) + }, 250) + }, 250) + }) })