info@54: $(function () { info@54: info@54: module("carousel") info@54: info@54: test("should provide no conflict", function () { info@54: var carousel = $.fn.carousel.noConflict() info@54: ok(!$.fn.carousel, 'carousel was set back to undefined (org value)') info@54: $.fn.carousel = carousel info@54: }) info@54: info@54: test("should be defined on jquery object", function () { info@54: ok($(document.body).carousel, 'carousel method is defined') info@54: }) info@54: info@54: test("should return element", function () { info@54: ok($(document.body).carousel()[0] == document.body, 'document.body returned') info@54: }) info@54: info@54: test("should not fire sliden when slide is prevented", function () { info@54: $.support.transition = false info@54: stop() info@54: $('
') info@54: .on('slide.bs.carousel', function (e) { info@54: e.preventDefault(); info@54: ok(true); info@54: start(); info@54: }) info@54: .on('slid.bs.carousel', function () { info@54: ok(false); info@54: }) info@54: .carousel('next') info@54: }) info@54: info@54: test("should fire slide event with direction", function () { info@54: var template = ' ' info@54: $.support.transition = false info@54: stop() info@54: $(template).on('slide.bs.carousel', function (e) { info@54: e.preventDefault() info@54: ok(e.direction) info@54: ok(e.direction === 'right' || e.direction === 'left') info@54: start() info@54: }).carousel('next') info@54: }) info@54: info@54: test("should fire slide event with relatedTarget", function () { info@54: var template = ' ' info@54: $.support.transition = false info@54: stop() info@54: $(template) info@54: .on('slide.bs.carousel', function (e) { info@54: e.preventDefault(); info@54: ok(e.relatedTarget); info@54: ok($(e.relatedTarget).hasClass('item')); info@54: start(); info@54: }) info@54: .carousel('next') info@54: }) info@54: info@54: test("should set interval from data attribute", 4, function () { info@54: var template = $(' '); info@54: template.attr("data-interval", 1814); info@54: info@54: template.appendTo("body"); info@54: $('[data-slide]').first().click(); info@54: ok($('#myCarousel').data('bs.carousel').options.interval == 1814); info@54: $('#myCarousel').remove(); info@54: info@54: template.appendTo("body").attr("data-modal", "foobar"); info@54: $('[data-slide]').first().click(); info@54: ok($('#myCarousel').data('bs.carousel').options.interval == 1814, "even if there is an data-modal attribute set"); info@54: $('#myCarousel').remove(); info@54: info@54: template.appendTo("body"); info@54: $('[data-slide]').first().click(); info@54: $('#myCarousel').attr('data-interval', 1860); info@54: $('[data-slide]').first().click(); info@54: ok($('#myCarousel').data('bs.carousel').options.interval == 1814, "attributes should be read only on intitialization"); info@54: $('#myCarousel').remove(); info@54: info@54: template.attr("data-interval", false); info@54: template.appendTo("body"); info@54: $('#myCarousel').carousel(1); info@54: ok($('#myCarousel').data('bs.carousel').options.interval === false, "data attribute has higher priority than default options"); info@54: $('#myCarousel').remove(); info@54: }) info@54: })