aboutsummaryrefslogtreecommitdiff
path: root/js/tests/unit
diff options
context:
space:
mode:
authorJohann-S <[email protected]>2017-11-07 08:18:52 +0100
committerXhmikosR <[email protected]>2017-11-07 09:18:52 +0200
commit26dc17bcd23fd2f5fd762c5cb73c6a670bd5f897 (patch)
tree93738278018f147b14719225a3e3d8aaf060d652 /js/tests/unit
parentb42a38b886e1e1063fc9acf474e58b43e0160829 (diff)
downloadbootstrap-26dc17bcd23fd2f5fd762c5cb73c6a670bd5f897.tar.xz
bootstrap-26dc17bcd23fd2f5fd762c5cb73c6a670bd5f897.zip
Popover - call `content` once if it's a function. (#24690)
Diffstat (limited to 'js/tests/unit')
-rw-r--r--js/tests/unit/popover.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/js/tests/unit/popover.js b/js/tests/unit/popover.js
index b5ea714ea..972da7828 100644
--- a/js/tests/unit/popover.js
+++ b/js/tests/unit/popover.js
@@ -410,4 +410,25 @@ $(function () {
$popover.trigger($.Event('click'))
}, 200)
})
+
+ QUnit.test('popover should call content function only once', function (assert) {
+ assert.expect(1)
+ var done = assert.async()
+ var nbCall = 0
+ $('<div id="popover" style="display:none">content</div>').appendTo('#qunit-fixture')
+ var $popover = $('<a href="#">@Johann-S</a>')
+ .appendTo('#qunit-fixture')
+ .bootstrapPopover({
+ content: function () {
+ nbCall++
+ return $('#popover').clone().show().get(0)
+ }
+ })
+ .on('shown.bs.popover', function () {
+ assert.strictEqual(nbCall, 1)
+ done()
+ })
+
+ $popover.trigger($.Event('click'))
+ })
})