diff options
| author | Jason Golieb <[email protected]> | 2019-01-28 22:55:21 +0200 |
|---|---|---|
| committer | XhmikosR <[email protected]> | 2019-02-05 10:24:49 +0200 |
| commit | 88a34aacbee09417252c804f7cded926a496904a (patch) | |
| tree | d604f307ea420b376b4a41f8f32052faaab7804c /js/tests | |
| parent | 1accd37aa07fa15485a85a9e2ff316aaba51333e (diff) | |
| download | bootstrap-88a34aacbee09417252c804f7cded926a496904a.tar.xz bootstrap-88a34aacbee09417252c804f7cded926a496904a.zip | |
Add support for tooltip offset option to be a function.
Diffstat (limited to 'js/tests')
| -rw-r--r-- | js/tests/unit/tooltip.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/js/tests/unit/tooltip.js b/js/tests/unit/tooltip.js index 54dbe57bd..30829d24d 100644 --- a/js/tests/unit/tooltip.js +++ b/js/tests/unit/tooltip.js @@ -1069,4 +1069,41 @@ $(function () { assert.strictEqual(tooltip._isEnabled, true) }) + + 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 $trigger = $('<a href="#" rel="tooltip" data-trigger="click" title="Another tooltip"/>') + .appendTo('#qunit-fixture') + .bootstrapTooltip({ + offset: getOffset + }) + + var tooltip = $trigger.data('bs.tooltip') + var offset = tooltip._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 myOffset = 42 + var $trigger = $('<a href="#" rel="tooltip" data-trigger="click" title="Another tooltip"/>') + .appendTo('#qunit-fixture') + .bootstrapTooltip({ + offset: myOffset + }) + + var tooltip = $trigger.data('bs.tooltip') + var offset = tooltip._getOffset() + + assert.strictEqual(offset.offset, myOffset) + assert.ok(typeof offset.fn === 'undefined') + }) }) |
