diff options
| author | James Remeika <[email protected]> | 2020-11-20 04:56:16 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-11-20 11:56:16 +0200 |
| commit | 2d8c02eb1024ef2ce8877d6484a9ea8a4d9cd67f (patch) | |
| tree | 1f4a1277f06bd474a76865f301cc1b8c223264fd /js/tests/unit/tooltip.js | |
| parent | ffa88deb85b406fc32b3abd4b66169405634bfbe (diff) | |
| download | bootstrap-2d8c02eb1024ef2ce8877d6484a9ea8a4d9cd67f.tar.xz bootstrap-2d8c02eb1024ef2ce8877d6484a9ea8a4d9cd67f.zip | |
tooltip/popover: add a `customClass` option (#31834)
Co-authored-by: XhmikosR <[email protected]>
Diffstat (limited to 'js/tests/unit/tooltip.js')
| -rw-r--r-- | js/tests/unit/tooltip.js | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/js/tests/unit/tooltip.js b/js/tests/unit/tooltip.js index 4f55007c7..b6a40b873 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) + }) }) |
