' +
@@ -985,7 +985,7 @@ $(function () {
}, 80)
})
- QUnit.test('Should not go to the next item when the parent of the carousel is not visible', function (assert) {
+ QUnit.test('should not go to the next item when the parent of the carousel is not visible', function (assert) {
assert.expect(2)
var done = assert.async()
var html = '
' +
@@ -1270,4 +1270,64 @@ $(function () {
assert.strictEqual(spy.called, true)
sandbox.restore()
})
+
+ QUnit.test('should not cycle when there is no attribute data-ride', function (assert) {
+ assert.expect(1)
+
+ var spy = sinon.spy(Carousel.prototype, 'cycle')
+
+ var carouselHTML = '
'
+ var $carousel = $(carouselHTML)
+ $carousel.appendTo('#qunit-fixture')
+ $carousel.bootstrapCarousel()
+
+ assert.strictEqual(spy.called, false)
+ spy.restore()
+ })
+
+ QUnit.test('should cycle when there is data-ride attribute', function (assert) {
+ assert.expect(1)
+
+ var spy = sinon.spy(Carousel.prototype, 'cycle')
+
+ var carouselHTML = '
'
+ var $carousel = $(carouselHTML)
+ $carousel.appendTo('#qunit-fixture')
+ $carousel.bootstrapCarousel()
+
+ assert.strictEqual(spy.called, true)
+ spy.restore()
+ })
+
+ QUnit.test('should init carousels with data-ride on load event', function (assert) {
+ assert.expect(1)
+
+ var done = assert.async()
+ var spy = sinon.spy(Carousel, '_jQueryInterface')
+
+ var carouselHTML = '
'
+ var $carousel = $(carouselHTML)
+ $carousel.appendTo('#qunit-fixture')
+
+ $(window).trigger($.Event('load'))
+
+ setTimeout(function () {
+ assert.strictEqual(spy.called, true)
+ spy.restore()
+ done()
+ }, 5)
+ })
+
+ QUnit.test('should not add touch event listeners when touch option set to false', function (assert) {
+ assert.expect(1)
+
+ var spy = sinon.spy(Carousel.prototype, '_addTouchEventListeners')
+ var $carousel = $('
')
+
+ $carousel.appendTo('#qunit-fixture')
+ $carousel.bootstrapCarousel()
+
+ assert.strictEqual(spy.called, false)
+ spy.restore()
+ })
})
diff --git a/static/plugin/bootstrap/js/tests/unit/dropdown.js b/static/plugin/bootstrap/js/tests/unit/dropdown.js
index fd9b7f96..1ecfd1f8 100755
--- a/static/plugin/bootstrap/js/tests/unit/dropdown.js
+++ b/static/plugin/bootstrap/js/tests/unit/dropdown.js
@@ -1361,4 +1361,59 @@ $(function () {
$dropdown.hide()
assert.ok($dropdown.parent('.dropdown').hasClass('show'))
})
+
+ QUnit.test('should create offset modifier correctly when offset option is a function', function (assert) {
+ assert.expect(2)
+
+ var getOffset = function (offsets) {
+ return offsets
+ }
+
+ var dropdownHTML =
+ '
'
+
+ var $dropdown = $(dropdownHTML)
+ .appendTo('#qunit-fixture')
+ .find('[data-toggle="dropdown"]')
+ .bootstrapDropdown({
+ offset: getOffset
+ })
+
+ var dropdown = $dropdown.data('bs.dropdown')
+ var offset = dropdown._getOffset()
+
+ assert.ok(typeof offset.offset === 'undefined')
+ assert.ok(typeof offset.fn === 'function')
+ })
+
+ QUnit.test('should create offset modifier correctly when offset option is not a function', function (assert) {
+ assert.expect(2)
+
+ var dropdownHTML =
+ '
'
+
+ var myOffset = 42
+ var $dropdown = $(dropdownHTML)
+ .appendTo('#qunit-fixture')
+ .find('[data-toggle="dropdown"]')
+ .bootstrapDropdown({
+ offset: myOffset
+ })
+
+ var dropdown = $dropdown.data('bs.dropdown')
+ var offset = dropdown._getOffset()
+
+ assert.strictEqual(offset.offset, myOffset)
+ assert.ok(typeof offset.fn === 'undefined')
+ })
})
diff --git a/static/plugin/bootstrap/js/tests/unit/modal.js b/static/plugin/bootstrap/js/tests/unit/modal.js
index 782a86ee..9b7fb0aa 100755
--- a/static/plugin/bootstrap/js/tests/unit/modal.js
+++ b/static/plugin/bootstrap/js/tests/unit/modal.js
@@ -619,40 +619,37 @@ $(function () {
assert.expect(1)
var done = assert.async()
- try {
- var $toggleBtn = $('
')
- .appendTo('#qunit-fixture')
+ var $toggleBtn = $('
')
+ .appendTo('#qunit-fixture')
- $toggleBtn.trigger('click')
- } catch (e) {
+ $toggleBtn.trigger('click')
+ setTimeout(function () {
assert.strictEqual($('#modal-test').length, 0, 'target has not been parsed and added to the document')
done()
- }
+ }, 0)
})
QUnit.test('should not execute js from target', function (assert) {
assert.expect(0)
var done = assert.async()
- try {
- // This toggle button contains XSS payload in its data-target
- // Note: it uses the onerror handler of an img element to execute the js, because a simple script element does not work here
- // a script element works in manual tests though, so here it is likely blocked by the qunit framework
- var $toggleBtn = $('
')
- .appendTo('#qunit-fixture')
- // The XSS payload above does not have a closure over this function and cannot access the assert object directly
- // However, it can send a click event to the following control button, which will then fail the assert
- $('