diff options
| author | Mark Otto <[email protected]> | 2013-12-26 21:40:15 -0800 |
|---|---|---|
| committer | Mark Otto <[email protected]> | 2013-12-26 21:40:15 -0800 |
| commit | 5b02dbd97a0a480b0f800cb1011089dab9980300 (patch) | |
| tree | 7eb7ffdc3bf67d303b95ab2ab05bfbf3f76503d1 /js/tests | |
| parent | 12980e7ea47057d7e17c3606604c79c6450b272e (diff) | |
| parent | 201088cb5f9ab4af062b62ac3a10a2e8f07a6ec5 (diff) | |
| download | bootstrap-5b02dbd97a0a480b0f800cb1011089dab9980300.tar.xz bootstrap-5b02dbd97a0a480b0f800cb1011089dab9980300.zip | |
Merge branch 'master' into docs_derp
Conflicts:
_config.yml
Diffstat (limited to 'js/tests')
| -rw-r--r-- | js/tests/unit/affix.js | 25 | ||||
| -rw-r--r-- | js/tests/unit/carousel.js | 25 |
2 files changed, 49 insertions, 1 deletions
diff --git a/js/tests/unit/affix.js b/js/tests/unit/affix.js index 6085a141e..3c8105bce 100644 --- a/js/tests/unit/affix.js +++ b/js/tests/unit/affix.js @@ -22,4 +22,29 @@ $(function () { ok(!$affix.hasClass('affix'), 'affix class was not added') }) + test('should trigger affixed event after affix', function () { + stop() + + var template = $('<div id="affixTarget"><ul><li>Please affix</li><li>And unaffix</li></ul></div><div id="affixAfter" style="height: 20000px; display:block;"></div>') + template.appendTo('body') + + var affixer = $('#affixTarget').affix({ + offset: $('#affixTarget ul').position() + }) + + $('#affixTarget') + .on('affix.bs.affix', function (e) { + ok(true, 'affix event triggered') + }).on('affixed.bs.affix', function (e) { + ok(true,'affixed event triggered') + $('#affixTarget').remove() + $('#affixAfter').remove() + start() + }) + + setTimeout(function () { + window.scrollTo(0, document.body.scrollHeight) + setTimeout(function () { window.scroll(0,0) }, 0) + },0) + }) }) diff --git a/js/tests/unit/carousel.js b/js/tests/unit/carousel.js index 8d1726b71..5edec68ad 100644 --- a/js/tests/unit/carousel.js +++ b/js/tests/unit/carousel.js @@ -16,7 +16,7 @@ $(function () { ok($(document.body).carousel()[0] == document.body, 'document.body returned') }) - test('should not fire sliden when slide is prevented', function () { + test('should not fire slide when slide is prevented', function () { $.support.transition = false stop() $('<div class="carousel"/>') @@ -31,6 +31,29 @@ $(function () { .carousel('next') }) + test('should reset when slide is prevented', function () { + var template = '<div id="carousel-example-generic" class="carousel slide"><ol class="carousel-indicators"><li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li><li data-target="#carousel-example-generic" data-slide-to="1"></li><li data-target="#carousel-example-generic" data-slide-to="2"></li></ol><div class="carousel-inner"><div class="item active"><div class="carousel-caption"></div></div><div class="item"><div class="carousel-caption"></div></div><div class="item"><div class="carousel-caption"></div></div></div><a class="left carousel-control" href="#carousel-example-generic" data-slide="prev"></a><a class="right carousel-control" href="#carousel-example-generic" data-slide="next"></a></div>' + var $carousel = $(template) + $.support.transition = false + stop() + $carousel.one('slide.bs.carousel', function (e) { + e.preventDefault() + setTimeout(function () { + ok($carousel.find('.item:eq(0)').is('.active')) + ok($carousel.find('.carousel-indicators li:eq(0)').is('.active')) + $carousel.carousel('next') + }, 1); + }) + $carousel.one('slid.bs.carousel', function () { + setTimeout(function () { + ok($carousel.find('.item:eq(1)').is('.active')) + ok($carousel.find('.carousel-indicators li:eq(1)').is('.active')) + start() + }, 1); + }) + $carousel.carousel('next') + }) + test('should fire slide event with direction', function () { var template = '<div id="myCarousel" class="carousel slide"><div class="carousel-inner"><div class="item active"><img alt=""><div class="carousel-caption"><h4>{{_i}}First Thumbnail label{{/i}}</h4><p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p></div></div><div class="item"><img alt=""><div class="carousel-caption"><h4>{{_i}}Second Thumbnail label{{/i}}</h4><p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p></div></div><div class="item"><img alt=""><div class="carousel-caption"><h4>{{_i}}Third Thumbnail label{{/i}}</h4><p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p></div></div></div><a class="left carousel-control" href="#myCarousel" data-slide="prev">‹</a><a class="right carousel-control" href="#myCarousel" data-slide="next">›</a></div>' $.support.transition = false |
