Skip to content

Commit

Permalink
add unit test for affix-top for padding issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick O'Donoghue authored and cvrebert committed Nov 17, 2014
1 parent 1a2baf4 commit 3037b10
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions js/tests/unit/affix.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,34 @@ $(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 = '<div id="padding-offset" style="padding-top: 20px;">'
+ '<div id="affixTopTarget">'
+ '<p>Testing affix-top class is added</p>'
+ '</div>'
+ '<div style="height: 1000px; display: block;"/>'
+ '</div>'
$(templateHTML).appendTo(document.body)

$('#affixTopTarget').bootstrapAffix({
offset: { top: 120, bottom: 0 }
})

$('#affixTopTarget')
.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)
}, 0)
}, 0)
})
})

0 comments on commit 3037b10

Please sign in to comment.