diff options
| author | fat <[email protected]> | 2015-05-06 13:34:14 -0700 |
|---|---|---|
| committer | fat <[email protected]> | 2015-05-06 13:34:14 -0700 |
| commit | d1fbe200f46002431cdeebf965c4b789ef7ed267 (patch) | |
| tree | 43a7cc7667492e519b906f8a428935da2972ac14 /js/tests/unit/carousel.js | |
| parent | 09fb80568a52af6c440db971cdc6fd88eab8f8b5 (diff) | |
| download | bootstrap-d1fbe200f46002431cdeebf965c4b789ef7ed267.tar.xz bootstrap-d1fbe200f46002431cdeebf965c4b789ef7ed267.zip | |
remove closureness from plugins
Diffstat (limited to 'js/tests/unit/carousel.js')
| -rw-r--r-- | js/tests/unit/carousel.js | 300 |
1 files changed, 160 insertions, 140 deletions
diff --git a/js/tests/unit/carousel.js b/js/tests/unit/carousel.js index 2ad2c6734..39d250598 100644 --- a/js/tests/unit/carousel.js +++ b/js/tests/unit/carousel.js @@ -1,49 +1,54 @@ $(function () { 'use strict'; - module('carousel plugin') + QUnit.module('carousel plugin') - test('should be defined on jQuery object', function () { - ok($(document.body).carousel, 'carousel method is defined') + QUnit.test('should be defined on jQuery object', function (assert) { + assert.expect(1) + assert.ok($(document.body).carousel, 'carousel method is defined') }) - module('carousel', { - setup: function () { + QUnit.module('carousel', { + beforeEach: function () { // Run all tests in noConflict mode -- it's the only way to ensure that the plugin works in noConflict mode $.fn.bootstrapCarousel = $.fn.carousel.noConflict() }, - teardown: function () { + afterEach: function () { $.fn.carousel = $.fn.bootstrapCarousel delete $.fn.bootstrapCarousel } }) - test('should provide no conflict', function () { - strictEqual($.fn.carousel, undefined, 'carousel was set back to undefined (orig value)') + QUnit.test('should provide no conflict', function (assert) { + assert.expect(1) + assert.strictEqual($.fn.carousel, undefined, 'carousel was set back to undefined (orig value)') }) - test('should return jquery collection containing the element', function () { + QUnit.test('should return jquery collection containing the element', function (assert) { + assert.expect(2) var $el = $('<div/>') var $carousel = $el.bootstrapCarousel() - ok($carousel instanceof $, 'returns jquery collection') - strictEqual($carousel[0], $el[0], 'collection contains element') + assert.ok($carousel instanceof $, 'returns jquery collection') + assert.strictEqual($carousel[0], $el[0], 'collection contains element') }) - test('should not fire slid when slide is prevented', function (assert) { + QUnit.test('should not fire slid when slide is prevented', function (assert) { + assert.expect(1) var done = assert.async() $('<div class="carousel"/>') .on('slide.bs.carousel', function (e) { e.preventDefault() - ok(true, 'slide event fired') + assert.ok(true, 'slide event fired') done() }) .on('slid.bs.carousel', function () { - ok(false, 'slid event fired') + assert.ok(false, 'slid event fired') }) .bootstrapCarousel('next') }) - test('should reset when slide is prevented', function (assert) { + QUnit.test('should reset when slide is prevented', function (assert) { + assert.expect(6) var carouselHTML = '<div id="carousel-example-generic" class="carousel slide">' + '<ol class="carousel-indicators">' + '<li data-target="#carousel-example-generic" data-slide-to="0" class="active"/>' @@ -51,13 +56,13 @@ $(function () { + '<li data-target="#carousel-example-generic" data-slide-to="2"/>' + '</ol>' + '<div class="carousel-inner">' - + '<div class="carousel-item active">' + + '<div class="item active">' + '<div class="carousel-caption"/>' + '</div>' - + '<div class="carousel-item">' + + '<div class="item">' + '<div class="carousel-caption"/>' + '</div>' - + '<div class="carousel-item">' + + '<div class="item">' + '<div class="carousel-caption"/>' + '</div>' + '</div>' @@ -71,27 +76,28 @@ $(function () { .one('slide.bs.carousel', function (e) { e.preventDefault() setTimeout(function () { - ok($carousel.find('.carousel-item:eq(0)').is('.active'), 'first item still active') - ok($carousel.find('.carousel-indicators li:eq(0)').is('.active'), 'first indicator still active') + assert.ok($carousel.find('.item:eq(0)').is('.active'), 'first item still active') + assert.ok($carousel.find('.carousel-indicators li:eq(0)').is('.active'), 'first indicator still active') $carousel.bootstrapCarousel('next') }, 0) }) .one('slid.bs.carousel', function () { setTimeout(function () { - ok(!$carousel.find('.carousel-item:eq(0)').is('.active'), 'first item still active') - ok(!$carousel.find('.carousel-indicators li:eq(0)').is('.active'), 'first indicator still active') - ok($carousel.find('.carousel-item:eq(1)').is('.active'), 'second item active') - ok($carousel.find('.carousel-indicators li:eq(1)').is('.active'), 'second indicator active') + assert.ok(!$carousel.find('.item:eq(0)').is('.active'), 'first item still active') + assert.ok(!$carousel.find('.carousel-indicators li:eq(0)').is('.active'), 'first indicator still active') + assert.ok($carousel.find('.item:eq(1)').is('.active'), 'second item active') + assert.ok($carousel.find('.carousel-indicators li:eq(1)').is('.active'), 'second indicator active') done() }, 0) }) .bootstrapCarousel('next') }) - test('should fire slide event with direction', function (assert) { + QUnit.test('should fire slide event with direction', function (assert) { + assert.expect(4) var carouselHTML = '<div id="myCarousel" class="carousel slide">' + '<div class="carousel-inner">' - + '<div class="carousel-item active">' + + '<div class="item active">' + '<img alt="">' + '<div class="carousel-caption">' + '<h4>First Thumbnail label</h4>' @@ -100,7 +106,7 @@ $(function () { + 'ultricies vehicula ut id elit.</p>' + '</div>' + '</div>' - + '<div class="carousel-item">' + + '<div class="item">' + '<img alt="">' + '<div class="carousel-caption">' + '<h4>Second Thumbnail label</h4>' @@ -109,7 +115,7 @@ $(function () { + 'ultricies vehicula ut id elit.</p>' + '</div>' + '</div>' - + '<div class="carousel-item">' + + '<div class="item">' + '<img alt="">' + '<div class="carousel-caption">' + '<h4>Third Thumbnail label</h4>' @@ -128,13 +134,13 @@ $(function () { $carousel .one('slide.bs.carousel', function (e) { - ok(e.direction, 'direction present on next') - strictEqual(e.direction, 'left', 'direction is left on next') + assert.ok(e.direction, 'direction present on next') + assert.strictEqual(e.direction, 'left', 'direction is left on next') $carousel .one('slide.bs.carousel', function (e) { - ok(e.direction, 'direction present on prev') - strictEqual(e.direction, 'right', 'direction is right on prev') + assert.ok(e.direction, 'direction present on prev') + assert.strictEqual(e.direction, 'right', 'direction is right on prev') done() }) .bootstrapCarousel('prev') @@ -142,10 +148,11 @@ $(function () { .bootstrapCarousel('next') }) - test('should fire slid event with direction', function (assert) { + QUnit.test('should fire slid event with direction', function (assert) { + assert.expect(4) var carouselHTML = '<div id="myCarousel" class="carousel slide">' + '<div class="carousel-inner">' - + '<div class="carousel-item active">' + + '<div class="item active">' + '<img alt="">' + '<div class="carousel-caption">' + '<h4>First Thumbnail label</h4>' @@ -154,7 +161,7 @@ $(function () { + 'ultricies vehicula ut id elit.</p>' + '</div>' + '</div>' - + '<div class="carousel-item">' + + '<div class="item">' + '<img alt="">' + '<div class="carousel-caption">' + '<h4>Second Thumbnail label</h4>' @@ -163,7 +170,7 @@ $(function () { + 'ultricies vehicula ut id elit.</p>' + '</div>' + '</div>' - + '<div class="carousel-item">' + + '<div class="item">' + '<img alt="">' + '<div class="carousel-caption">' + '<h4>Third Thumbnail label</h4>' @@ -182,13 +189,13 @@ $(function () { $carousel .one('slid.bs.carousel', function (e) { - ok(e.direction, 'direction present on next') - strictEqual(e.direction, 'left', 'direction is left on next') + assert.ok(e.direction, 'direction present on next') + assert.strictEqual(e.direction, 'left', 'direction is left on next') $carousel .one('slid.bs.carousel', function (e) { - ok(e.direction, 'direction present on prev') - strictEqual(e.direction, 'right', 'direction is right on prev') + assert.ok(e.direction, 'direction present on prev') + assert.strictEqual(e.direction, 'right', 'direction is right on prev') done() }) .bootstrapCarousel('prev') @@ -196,10 +203,11 @@ $(function () { .bootstrapCarousel('next') }) - test('should fire slide event with relatedTarget', function (assert) { + QUnit.test('should fire slide event with relatedTarget', function (assert) { + assert.expect(2) var template = '<div id="myCarousel" class="carousel slide">' + '<div class="carousel-inner">' - + '<div class="carousel-item active">' + + '<div class="item active">' + '<img alt="">' + '<div class="carousel-caption">' + '<h4>First Thumbnail label</h4>' @@ -208,7 +216,7 @@ $(function () { + 'ultricies vehicula ut id elit.</p>' + '</div>' + '</div>' - + '<div class="carousel-item">' + + '<div class="item">' + '<img alt="">' + '<div class="carousel-caption">' + '<h4>Second Thumbnail label</h4>' @@ -217,7 +225,7 @@ $(function () { + 'ultricies vehicula ut id elit.</p>' + '</div>' + '</div>' - + '<div class="carousel-item">' + + '<div class="item">' + '<img alt="">' + '<div class="carousel-caption">' + '<h4>Third Thumbnail label</h4>' @@ -235,17 +243,18 @@ $(function () { $(template) .on('slide.bs.carousel', function (e) { - ok(e.relatedTarget, 'relatedTarget present') - ok($(e.relatedTarget).hasClass('carousel-item'), 'relatedTarget has class "carousel-item"') + assert.ok(e.relatedTarget, 'relatedTarget present') + assert.ok($(e.relatedTarget).hasClass('item'), 'relatedTarget has class "item"') done() }) .bootstrapCarousel('next') }) - test('should fire slid event with relatedTarget', function (assert) { + QUnit.test('should fire slid event with relatedTarget', function (assert) { + assert.expect(2) var template = '<div id="myCarousel" class="carousel slide">' + '<div class="carousel-inner">' - + '<div class="carousel-item active">' + + '<div class="item active">' + '<img alt="">' + '<div class="carousel-caption">' + '<h4>First Thumbnail label</h4>' @@ -254,7 +263,7 @@ $(function () { + 'ultricies vehicula ut id elit.</p>' + '</div>' + '</div>' - + '<div class="carousel-item">' + + '<div class="item">' + '<img alt="">' + '<div class="carousel-caption">' + '<h4>Second Thumbnail label</h4>' @@ -263,7 +272,7 @@ $(function () { + 'ultricies vehicula ut id elit.</p>' + '</div>' + '</div>' - + '<div class="carousel-item">' + + '<div class="item">' + '<img alt="">' + '<div class="carousel-caption">' + '<h4>Third Thumbnail label</h4>' @@ -281,17 +290,18 @@ $(function () { $(template) .on('slid.bs.carousel', function (e) { - ok(e.relatedTarget, 'relatedTarget present') - ok($(e.relatedTarget).hasClass('carousel-item'), 'relatedTarget has class "carousel-item"') + assert.ok(e.relatedTarget, 'relatedTarget present') + assert.ok($(e.relatedTarget).hasClass('item'), 'relatedTarget has class "item"') done() }) .bootstrapCarousel('next') }) - test('should set interval from data attribute', function () { + QUnit.test('should set interval from data attribute', function (assert) { + assert.expect(4) var templateHTML = '<div id="myCarousel" class="carousel slide">' + '<div class="carousel-inner">' - + '<div class="carousel-item active">' + + '<div class="item active">' + '<img alt="">' + '<div class="carousel-caption">' + '<h4>First Thumbnail label</h4>' @@ -300,7 +310,7 @@ $(function () { + 'ultricies vehicula ut id elit.</p>' + '</div>' + '</div>' - + '<div class="carousel-item">' + + '<div class="item">' + '<img alt="">' + '<div class="carousel-caption">' + '<h4>Second Thumbnail label</h4>' @@ -309,7 +319,7 @@ $(function () { + 'ultricies vehicula ut id elit.</p>' + '</div>' + '</div>' - + '<div class="carousel-item">' + + '<div class="item">' + '<img alt="">' + '<div class="carousel-caption">' + '<h4>Third Thumbnail label</h4>' @@ -322,45 +332,45 @@ $(function () { + '<a class="left carousel-control" href="#myCarousel" data-slide="prev">‹</a>' + '<a class="right carousel-control" href="#myCarousel" data-slide="next">›</a>' + '</div>' - var $carousel = $(templateHTML) $carousel.attr('data-interval', 1814) $carousel.appendTo('body') - $('[data-slide]').first().click() - equal($carousel.data('bs.carousel').getConfig().interval, 1814) + $('[data-slide]').first().trigger('click') + assert.strictEqual($carousel.data('bs.carousel').options.interval, 1814) $carousel.remove() $carousel.appendTo('body').attr('data-modal', 'foobar') - $('[data-slide]').first().click() - equal($carousel.data('bs.carousel').getConfig().interval, 1814, 'even if there is an data-modal attribute set') + $('[data-slide]').first().trigger('click') + assert.strictEqual($carousel.data('bs.carousel').options.interval, 1814, 'even if there is an data-modal attribute set') $carousel.remove() $carousel.appendTo('body') - $('[data-slide]').first().click() + $('[data-slide]').first().trigger('click') $carousel.attr('data-interval', 1860) - $('[data-slide]').first().click() - equal($carousel.data('bs.carousel').getConfig().interval, 1814, 'attributes should be read only on initialization') + $('[data-slide]').first().trigger('click') + assert.strictEqual($carousel.data('bs.carousel').options.interval, 1814, 'attributes should be read only on initialization') $carousel.remove() $carousel.attr('data-interval', false) $carousel.appendTo('body') $carousel.bootstrapCarousel(1) - strictEqual($carousel.data('bs.carousel').getConfig().interval, false, 'data attribute has higher priority than default options') + assert.strictEqual($carousel.data('bs.carousel').options.interval, false, 'data attribute has higher priority than default options') $carousel.remove() }) - test('should skip over non-items when using item indices', function () { + QUnit.test('should skip over non-items when using item indices', function (assert) { + assert.expect(2) var templateHTML = '<div id="myCarousel" class="carousel" data-interval="1814">' + '<div class="carousel-inner">' - + '<div class="carousel-item active">' + + '<div class="item active">' + '<img alt="">' + '</div>' + '<script type="text/x-metamorph" id="thingy"/>' - + '<div class="carousel-item">' + + '<div class="item">' + '<img alt="">' + '</div>' - + '<div class="carousel-item">' + + '<div class="item">' + '</div>' + '</div>' + '</div>' @@ -368,24 +378,25 @@ $(function () { $template.bootstrapCarousel() - strictEqual($template.find('.carousel-item')[0], $template.find('.active')[0], 'first item active') + assert.strictEqual($template.find('.item')[0], $template.find('.active')[0], 'first item active') $template.bootstrapCarousel(1) - strictEqual($template.find('.carousel-item')[1], $template.find('.active')[0], 'second item active') + assert.strictEqual($template.find('.item')[1], $template.find('.active')[0], 'second item active') }) - test('should skip over non-items when using next/prev methods', function () { + QUnit.test('should skip over non-items when using next/prev methods', function (assert) { + assert.expect(2) var templateHTML = '<div id="myCarousel" class="carousel" data-interval="1814">' + '<div class="carousel-inner">' - + '<div class="carousel-item active">' + + '<div class="item active">' + '<img alt="">' + '</div>' + '<script type="text/x-metamorph" id="thingy"/>' - + '<div class="carousel-item">' + + '<div class="item">' + '<img alt="">' + '</div>' - + '<div class="carousel-item">' + + '<div class="item">' + '</div>' + '</div>' + '</div>' @@ -393,23 +404,24 @@ $(function () { $template.bootstrapCarousel() - strictEqual($template.find('.carousel-item')[0], $template.find('.active')[0], 'first item active') + assert.strictEqual($template.find('.item')[0], $template.find('.active')[0], 'first item active') $template.bootstrapCarousel('next') - strictEqual($template.find('.carousel-item')[1], $template.find('.active')[0], 'second item active') + assert.strictEqual($template.find('.item')[1], $template.find('.active')[0], 'second item active') }) - test('should go to previous item if left arrow key is pressed', function () { + QUnit.test('should go to previous item if left arrow key is pressed', function (assert) { + assert.expect(2) var templateHTML = '<div id="myCarousel" class="carousel" data-interval="false">' + '<div class="carousel-inner">' - + '<div id="first" class="carousel-item">' + + '<div id="first" class="item">' + '<img alt="">' + '</div>' - + '<div id="second" class="carousel-item active">' + + '<div id="second" class="item active">' + '<img alt="">' + '</div>' - + '<div id="third" class="carousel-item">' + + '<div id="third" class="item">' + '<img alt="">' + '</div>' + '</div>' @@ -418,23 +430,24 @@ $(function () { $template.bootstrapCarousel() - strictEqual($template.find('.carousel-item')[1], $template.find('.active')[0], 'second item active') + assert.strictEqual($template.find('.item')[1], $template.find('.active')[0], 'second item active') $template.trigger($.Event('keydown', { which: 37 })) - strictEqual($template.find('.carousel-item')[0], $template.find('.active')[0], 'first item active') + assert.strictEqual($template.find('.item')[0], $template.find('.active')[0], 'first item active') }) - test('should go to next item if right arrow key is pressed', function () { + QUnit.test('should go to next item if right arrow key is pressed', function (assert) { + assert.expect(2) var templateHTML = '<div id="myCarousel" class="carousel" data-interval="false">' + '<div class="carousel-inner">' - + '<div id="first" class="carousel-item active">' + + '<div id="first" class="item active">' + '<img alt="">' + '</div>' - + '<div id="second" class="carousel-item">' + + '<div id="second" class="item">' + '<img alt="">' + '</div>' - + '<div id="third" class="carousel-item">' + + '<div id="third" class="item">' + '<img alt="">' + '</div>' + '</div>' @@ -443,23 +456,24 @@ $(function () { $template.bootstrapCarousel() - strictEqual($template.find('.carousel-item')[0], $template.find('.active')[0], 'first item active') + assert.strictEqual($template.find('.item')[0], $template.find('.active')[0], 'first item active') $template.trigger($.Event('keydown', { which: 39 })) - strictEqual($template.find('.carousel-item')[1], $template.find('.active')[0], 'second item active') + assert.strictEqual($template.find('.item')[1], $template.find('.active')[0], 'second item active') }) - test('should support disabling the keyboard navigation', function () { + QUnit.test('should support disabling the keyboard navigation', function (assert) { + assert.expect(3) var templateHTML = '<div id="myCarousel" class="carousel" data-interval="false" data-keyboard="false">' + '<div class="carousel-inner">' - + '<div id="first" class="carousel-item active">' + + '<div id="first" class="item active">' + '<img alt="">' + '</div>' - + '<div id="second" class="carousel-item">' + + '<div id="second" class="item">' + '<img alt="">' + '</div>' - + '<div id="third" class="carousel-item">' + + '<div id="third" class="item">' + '<img alt="">' + '</div>' + '</div>' @@ -468,29 +482,30 @@ $(function () { $template.bootstrapCarousel() - strictEqual($template.find('.carousel-item')[0], $template.find('.active')[0], 'first item active') + assert.strictEqual($template.find('.item')[0], $template.find('.active')[0], 'first item active') $template.trigger($.Event('keydown', { which: 39 })) - strictEqual($template.find('.carousel-item')[0], $template.find('.active')[0], 'first item still active after right arrow press') + assert.strictEqual($template.find('.item')[0], $template.find('.active')[0], 'first item still active after right arrow press') $template.trigger($.Event('keydown', { which: 37 })) - strictEqual($template.find('.carousel-item')[0], $template.find('.active')[0], 'first item still active after left arrow press') + assert.strictEqual($template.find('.item')[0], $template.find('.active')[0], 'first item still active after left arrow press') }) - test('should ignore keyboard events within <input>s and <textarea>s', function () { + QUnit.test('should ignore keyboard events within <input>s and <textarea>s', function (assert) { + assert.expect(7) var templateHTML = '<div id="myCarousel" class="carousel" data-interval="false">' + '<div class="carousel-inner">' - + '<div id="first" class="carousel-item active">' + + '<div id="first" class="item active">' + '<img alt="">' + '<input type="text" id="in-put">' + '<textarea id="text-area"></textarea>' + '</div>' - + '<div id="second" class="carousel-item">' + + '<div id="second" class="item">' + '<img alt="">' + '</div>' - + '<div id="third" class="carousel-item">' + + '<div id="third" class="item">' + '<img alt="">' + '</div>' + '</div>' @@ -499,39 +514,40 @@ $(function () { var $input = $template.find('#in-put') var $textarea = $template.find('#text-area') - strictEqual($input.length, 1, 'found <input>') - strictEqual($textarea.length, 1, 'found <textarea>') + assert.strictEqual($input.length, 1, 'found <input>') + assert.strictEqual($textarea.length, 1, 'found <textarea>') $template.bootstrapCarousel() - strictEqual($template.find('.carousel-item')[0], $template.find('.active')[0], 'first item active') + assert.strictEqual($template.find('.item')[0], $template.find('.active')[0], 'first item active') $input.trigger($.Event('keydown', { which: 39 })) - strictEqual($template.find('.carousel-item')[0], $template.find('.active')[0], 'first item still active after right arrow press in <input>') + assert.strictEqual($template.find('.item')[0], $template.find('.active')[0], 'first item still active after right arrow press in <input>') $input.trigger($.Event('keydown', { which: 37 })) - strictEqual($template.find('.carousel-item')[0], $template.find('.active')[0], 'first item still active after left arrow press in <input>') + assert.strictEqual($template.find('.item')[0], $template.find('.active')[0], 'first item still active after left arrow press in <input>') $textarea.trigger($.Event('keydown', { which: 39 })) - strictEqual($template.find('.carousel-item')[0], $template.find('.active')[0], 'first item still active after right arrow press in <textarea>') + assert.strictEqual($template.find('.item')[0], $template.find('.active')[0], 'first item still active after right arrow press in <textarea>') $textarea.trigger($.Event('keydown', { which: 37 })) - strictEqual($template.find('.carousel-item')[0], $template.find('.active')[0], 'first item still active after left arrow press in <textarea>') + assert.strictEqual($template.find('.item')[0], $template.find('.active')[0], 'first item still active after left arrow press in <textarea>') }) - test('should only add mouseenter and mouseleave listeners when not on mobile', function () { + QUnit.test('should only add mouseenter and mouseleave listeners when not on mobile', function (assert) { + assert.expect(2) var isMobile = 'ontouchstart' in document.documentElement var templateHTML = '<div id="myCarousel" class="carousel" data-interval="false" data-pause="hover">' + '<div class="carousel-inner">' - + '<div id="first" class="carousel-item active">' + + '<div id="first" class="item active">' + '<img alt="">' + '</div>' - + '<div id="second" class="carousel-item">' + + '<div id="second" class="item">' + '<img alt="">' + '</div>' - + '<div id="third" class="carousel-item">' + + '<div id="third" class="item">' + '<img alt="">' + '</div>' + '</div>' @@ -539,11 +555,12 @@ $(function () { var $template = $(templateHTML).bootstrapCarousel() $.each(['mouseover', 'mouseout'], function (i, type) { - strictEqual(type in $._data($template[0], 'events'), !isMobile, 'does' + (isMobile ? ' not' : '') + ' listen for ' + type + ' events') + assert.strictEqual(type in $._data($template[0], 'events'), !isMobile, 'does' + (isMobile ? ' not' : '') + ' listen for ' + type + ' events') }) }) - test('should wrap around from end to start when wrap option is true', function (assert) { + QUnit.test('should wrap around from end to start when wrap option is true', function (assert) { + assert.expect(3) var carouselHTML = '<div id="carousel-example-generic" class="carousel slide" data-wrap="true">' + '<ol class="carousel-indicators">' + '<li data-target="#carousel-example-generic" data-slide-to="0" class="active"/>' @@ -551,13 +568,13 @@ $(function () { + '<li data-target="#carousel-example-generic" data-slide-to="2"/>' + '</ol>' + '<div class="carousel-inner">' - + '<div class="carousel-item active" id="one">' + + '<div class="item active" id="one">' + '<div class="carousel-caption"/>' + '</div>' - + '<div class="carousel-item" id="two">' + + '<div class="item" id="two">' + '<div class="carousel-caption"/>' + '</div>' - + '<div class="carousel-item" id="three">' + + '<div class="item" id="three">' + '<div class="carousel-caption"/>' + '</div>' + '</div>' @@ -565,19 +582,19 @@ $(function () { + '<a class="right carousel-control" href="#carousel-example-generic" data-slide="next"/>' + '</div>' var $carousel = $(carouselHTML) - var getActiveId = function () { return $carousel.find('.carousel-item.active').attr('id') } + var getActiveId = function () { return $carousel.find('.item.active').attr('id') } var done = assert.async() $carousel .one('slid.bs.carousel', function () { - strictEqual(getActiveId(), 'two', 'carousel slid from 1st to 2nd slide') + assert.strictEqual(getActiveId(), 'two', 'carousel slid from 1st to 2nd slide') $carousel .one('slid.bs.carousel', function () { - strictEqual(getActiveId(), 'three', 'carousel slid from 2nd to 3rd slide') + assert.strictEqual(getActiveId(), 'three', 'carousel slid from 2nd to 3rd slide') $carousel .one('slid.bs.carousel', function () { - strictEqual(getActiveId(), 'one', 'carousel wrapped around and slid from 3rd to 1st slide') + assert.strictEqual(getActiveId(), 'one', 'carousel wrapped around and slid from 3rd to 1st slide') done() }) .bootstrapCarousel('next') @@ -587,7 +604,8 @@ $(function () { .bootstrapCarousel('next') }) - test('should wrap around from start to end when wrap option is true', function (assert) { + QUnit.test('should wrap around from start to end when wrap option is true', function (assert) { + assert.expect(1) var carouselHTML = '<div id="carousel-example-generic" class="carousel slide" data-wrap="true">' + '<ol class="carousel-indicators">' + '<li data-target="#carousel-example-generic" data-slide-to="0" class="active"/>' @@ -595,13 +613,13 @@ $(function () { + '<li data-target="#carousel-example-generic" data-slide-to="2"/>' + '</ol>' + '<div class="carousel-inner">' - + '<div class="carousel-item active" id="one">' + + '<div class="item active" id="one">' + '<div class="carousel-caption"/>' + '</div>' - + '<div class="carousel-item" id="two">' + + '<div class="item" id="two">' + '<div class="carousel-caption"/>' + '</div>' - + '<div class="carousel-item" id="three">' + + '<div class="item" id="three">' + '<div class="carousel-caption"/>' + '</div>' + '</div>' @@ -614,13 +632,14 @@ $(function () { $carousel .on('slid.bs.carousel', function () { - strictEqual($carousel.find('.carousel-item.active').attr('id'), 'three', 'carousel wrapped around and slid from 1st to 3rd slide') + assert.strictEqual($carousel.find('.item.active').attr('id'), 'three', 'carousel wrapped around and slid from 1st to 3rd slide') done() }) .bootstrapCarousel('prev') }) - test('should stay at the end when the next method is called and wrap is false', function (assert) { + QUnit.test('should stay at the end when the next method is called and wrap is false', function (assert) { + assert.expect(3) var carouselHTML = '<div id="carousel-example-generic" class="carousel slide" data-wrap="false">' + '<ol class="carousel-indicators">' + '<li data-target="#carousel-example-generic" data-slide-to="0" class="active"/>' @@ -628,13 +647,13 @@ $(function () { + '<li data-target="#carousel-example-generic" data-slide-to="2"/>' + '</ol>' + '<div class="carousel-inner">' - + '<div class="carousel-item active" id="one">' + + '<div class="item active" id="one">' + '<div class="carousel-caption"/>' + '</div>' - + '<div class="carousel-item" id="two">' + + '<div class="item" id="two">' + '<div class="carousel-caption"/>' + '</div>' - + '<div class="carousel-item" id="three">' + + '<div class="item" id="three">' + '<div class="carousel-caption"/>' + '</div>' + '</div>' @@ -642,22 +661,22 @@ $(function () { + '<a class="right carousel-control" href="#carousel-example-generic" data-slide="next"/>' + '</div>' var $carousel = $(carouselHTML) - var getActiveId = function () { return $carousel.find('.carousel-item.active').attr('id') } + var getActiveId = function () { return $carousel.find('.item.active').attr('id') } var done = assert.async() $carousel .one('slid.bs.carousel', function () { - strictEqual(getActiveId(), 'two', 'carousel slid from 1st to 2nd slide') + assert.strictEqual(getActiveId(), 'two', 'carousel slid from 1st to 2nd slide') $carousel .one('slid.bs.carousel', function () { - strictEqual(getActiveId(), 'three', 'carousel slid from 2nd to 3rd slide') + assert.strictEqual(getActiveId(), 'three', 'carousel slid from 2nd to 3rd slide') $carousel .one('slid.bs.carousel', function () { - ok(false, 'carousel slid when it should not have slid') + assert.ok(false, 'carousel slid when it should not have slid') }) .bootstrapCarousel('next') - strictEqual(getActiveId(), 'three', 'carousel did not wrap around and stayed on 3rd slide') + assert.strictEqual(getActiveId(), 'three', 'carousel did not wrap around and stayed on 3rd slide') done() }) .bootstrapCarousel('next') @@ -665,7 +684,8 @@ $(function () { .bootstrapCarousel('next') }) - test('should stay at the start when the prev method is called and wrap is false', function () { + QUnit.test('should stay at the start when the prev method is called and wrap is false', function (assert) { + assert.expect(1) var carouselHTML = '<div id="carousel-example-generic" class="carousel slide" data-wrap="false">' + '<ol class="carousel-indicators">' + '<li data-target="#carousel-example-generic" data-slide-to="0" class="active"/>' @@ -673,13 +693,13 @@ $(function () { + '<li data-target="#carousel-example-generic" data-slide-to="2"/>' + '</ol>' + '<div class="carousel-inner">' - + '<div class="carousel-item active" id="one">' + + '<div class="item active" id="one">' + '<div class="carousel-caption"/>' + '</div>' - + '<div class="carousel-item" id="two">' + + '<div class="item" id="two">' + '<div class="carousel-caption"/>' + '</div>' - + '<div class="carousel-item" id="three">' + + '<div class="item" id="three">' + '<div class="carousel-caption"/>' + '</div>' + '</div>' @@ -690,9 +710,9 @@ $(function () { $carousel .on('slid.bs.carousel', function () { - ok(false, 'carousel slid when it should not have slid') + assert.ok(false, 'carousel slid when it should not have slid') }) .bootstrapCarousel('prev') - strictEqual($carousel.find('.carousel-item.active').attr('id'), 'one', 'carousel did not wrap around and stayed on 1st slide') + assert.strictEqual($carousel.find('.item.active').attr('id'), 'one', 'carousel did not wrap around and stayed on 1st slide') }) }) |
