$(function () { 'use strict'; QUnit.module('carousel plugin') QUnit.test('should be defined on jQuery object', function (assert) { assert.expect(1) assert.ok($(document.body).carousel, 'carousel method is defined') }) 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() }, afterEach: function () { $.fn.carousel = $.fn.bootstrapCarousel delete $.fn.bootstrapCarousel } }) QUnit.test('should provide no conflict', function (assert) { assert.expect(1) assert.strictEqual($.fn.carousel, undefined, 'carousel was set back to undefined (orig value)') }) QUnit.test('should return jquery collection containing the element', function (assert) { assert.expect(2) var $el = $('
') var $carousel = $el.bootstrapCarousel() assert.ok($carousel instanceof $, 'returns jquery collection') assert.strictEqual($carousel[0], $el[0], 'collection contains element') }) QUnit.test('should type check config options', function (assert) { assert.expect(2) var message var expectedMessage = 'CAROUSEL: Option "interval" provided type "string" but expected type "(number|boolean)".' var config = { interval: 'fat sux' } try { $('
').bootstrapCarousel(config) } catch (e) { message = e.message } assert.ok(message === expectedMessage, 'correct error message') config = { keyboard: document.createElement('div') } expectedMessage = 'CAROUSEL: Option "keyboard" provided type "element" but expected type "boolean".' try { $('
').bootstrapCarousel(config) } catch (e) { message = e.message } assert.ok(message === expectedMessage, 'correct error message') }) QUnit.test('should not fire slid when slide is prevented', function (assert) { assert.expect(1) var done = assert.async() $('