From fc372952e2983934dda338ffefd705112db8008a Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Tue, 21 Apr 2015 17:41:06 -0700 Subject: Throw error when tooltip/popover template has multiple top-level elements Closes #16219. --- js/tests/unit/popover.js | 11 +++++++++++ js/tests/unit/tooltip.js | 10 ++++++++++ 2 files changed, 21 insertions(+) (limited to 'js/tests') diff --git a/js/tests/unit/popover.js b/js/tests/unit/popover.js index 2c3fd0cb0..a25df3a58 100644 --- a/js/tests/unit/popover.js +++ b/js/tests/unit/popover.js @@ -259,6 +259,16 @@ $(function () { assert.strictEqual($popover.data('bs.popover'), undefined, 'should not initialize the popover') }) + QUnit.test('should throw an error when template contains multiple top-level elements', function (assert) { + assert.expect(1) + assert.throws(function () { + $('some text') + .appendTo('#qunit-fixture') + .bootstrapPopover({ template: '
Foo
Bar
' }) + .bootstrapPopover('show') + }, new Error('popover `template` option must consist of exactly 1 top-level element!')) + }) + QUnit.test('should fire inserted event', function (assert) { assert.expect(2) var done = assert.async() @@ -276,4 +286,5 @@ $(function () { }) .bootstrapPopover('show') }) + }) diff --git a/js/tests/unit/tooltip.js b/js/tests/unit/tooltip.js index 0cb964e9b..2c492a92b 100644 --- a/js/tests/unit/tooltip.js +++ b/js/tests/unit/tooltip.js @@ -1225,4 +1225,14 @@ $(function () { assert.strictEqual($tooltip.data('bs.tooltip'), undefined, 'should not initialize the tooltip') }) + QUnit.test('should throw an error when template contains multiple top-level elements', function (assert) { + assert.expect(1) + assert.throws(function () { + $('') + .appendTo('#qunit-fixture') + .bootstrapTooltip({ template: '
Foo
Bar
' }) + .bootstrapTooltip('show') + }, new Error('tooltip `template` option must consist of exactly 1 top-level element!')) + }) + }) -- cgit v1.2.3