$(function () { 'use strict'; QUnit.module('affix plugin') QUnit.test('should be defined on jquery object', function (assert) { assert.expect(1) assert.ok($(document.body).affix, 'affix method is defined') }) QUnit.module('affix', { beforeEach: function () { // Run all tests in noConflict mode -- it's the only way to ensure that the plugin works in noConflict mode $.fn.bootstrapAffix = $.fn.affix.noConflict() }, afterEach: function () { $.fn.affix = $.fn.bootstrapAffix delete $.fn.bootstrapAffix } }) QUnit.test('should provide no conflict', function (assert) { assert.expect(1) assert.strictEqual($.fn.affix, undefined, 'affix was set back to undefined (org value)') }) QUnit.test('should return jquery collection containing the element', function (assert) { assert.expect(2) var $el = $('
').appendTo('#qunit-fixture') var $affix = $el.bootstrapAffix() assert.ok($affix instanceof $, 'returns jquery collection') assert.strictEqual($affix[0], $el[0], 'collection contains element') }) QUnit.test('should exit early if element is not visible', function (assert) { assert.expect(1) var $affix = $('').bootstrapAffix() $affix.data('bs.affix').checkPosition() assert.ok(!$affix.hasClass('affix'), 'affix class was not added') }) QUnit.test('should trigger affixed event after affix', function (assert) { assert.expect(2) var done = assert.async() var templateHTML = 'Testing affix-top class is added
' + '