diff options
author | James Remeika <james@remeika.us> | 2020-11-20 12:56:16 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-20 12:56:16 +0300 |
commit | 2d8c02eb1024ef2ce8877d6484a9ea8a4d9cd67f (patch) | |
tree | 1f4a1277f06bd474a76865f301cc1b8c223264fd /js/tests | |
parent | ffa88deb85b406fc32b3abd4b66169405634bfbe (diff) |
tooltip/popover: add a `customClass` option (#31834)
Co-authored-by: XhmikosR <xhmikosr@gmail.com>
Diffstat (limited to 'js/tests')
-rw-r--r-- | js/tests/unit/popover.js | 13 | ||||
-rw-r--r-- | js/tests/unit/tooltip.js | 50 |
2 files changed, 63 insertions, 0 deletions
diff --git a/js/tests/unit/popover.js b/js/tests/unit/popover.js index a5981e45ff..102f37f8df 100644 --- a/js/tests/unit/popover.js +++ b/js/tests/unit/popover.js @@ -61,6 +61,19 @@ $(function () { .bootstrapPopover('show') }) + QUnit.test('should render popover element with additional classes', function (assert) { + assert.expect(2) + var done = assert.async() + $('<a href="#" title="mdo" data-content="https://twitter.com/mdo" data-custom-class="a b">@mdo</a>') + .appendTo('#qunit-fixture') + .on('shown.bs.popover', function () { + assert.strictEqual($('.popover').hasClass('popover fade bs-popover-right show'), true, 'has default classes') + assert.strictEqual($('.popover').hasClass('a b'), true, 'has custom classes') + done() + }) + .bootstrapPopover('show') + }) + QUnit.test('should store popover instance in popover data object', function (assert) { assert.expect(1) var $popover = $('<a href="#" title="mdo" data-content="https://twitter.com/mdo">@mdo</a>').bootstrapPopover() diff --git a/js/tests/unit/tooltip.js b/js/tests/unit/tooltip.js index 4f55007c71..b6a40b8736 100644 --- a/js/tests/unit/tooltip.js +++ b/js/tests/unit/tooltip.js @@ -1283,4 +1283,54 @@ $(function () { assert.strictEqual(popperConfig.placement, 'left') }) + + QUnit.test('additional classes can be applied via data attribute', function (assert) { + assert.expect(2) + + $('<a href="#" rel="tooltip" data-trigger="click" title="Another tooltip" data-custom-class="a b"/>') + .appendTo('#qunit-fixture') + .bootstrapTooltip() + .bootstrapTooltip('show') + + var tooltip = $('.tooltip') + + assert.strictEqual(tooltip.hasClass('a b'), true) + assert.strictEqual(tooltip.hasClass('tooltip fade bs-tooltip-top show'), true) + }) + + QUnit.test('additional classes can be applied via config string', function (assert) { + assert.expect(2) + + $('<a href="#" rel="tooltip" data-trigger="click" title="Another tooltip" />') + .appendTo('#qunit-fixture') + .bootstrapTooltip({ + customClass: 'a b' + }) + .bootstrapTooltip('show') + + var tooltip = $('.tooltip') + + assert.strictEqual(tooltip.hasClass('a b'), true) + assert.strictEqual(tooltip.hasClass('tooltip fade bs-tooltip-top show'), true) + }) + + QUnit.test('additional classes can be applied via function', function (assert) { + assert.expect(2) + + var getClasses = function () { + return 'a b' + } + + $('<a href="#" rel="tooltip" data-trigger="click" title="Another tooltip" />') + .appendTo('#qunit-fixture') + .bootstrapTooltip({ + customClass: getClasses + }) + .bootstrapTooltip('show') + + var tooltip = $('.tooltip') + + assert.strictEqual(tooltip.hasClass('a b'), true) + assert.strictEqual(tooltip.hasClass('tooltip fade bs-tooltip-top show'), true) + }) }) |