From 88a34aacbee09417252c804f7cded926a496904a Mon Sep 17 00:00:00 2001 From: Jason Golieb Date: Mon, 28 Jan 2019 22:55:21 +0200 Subject: Add support for tooltip offset option to be a function. --- js/tests/unit/tooltip.js | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'js/tests/unit/tooltip.js') diff --git a/js/tests/unit/tooltip.js b/js/tests/unit/tooltip.js index 54dbe57bd8..30829d24d5 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 = $('') + .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 = $('') + .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') + }) }) -- cgit v1.2.3