From 2c2d04aba58d081ffa0c376c5c5d23bd3f07c071 Mon Sep 17 00:00:00 2001 From: Johann-S Date: Mon, 29 Oct 2018 13:29:37 +0100 Subject: add unit test to test tabs can be removed without throwing error --- js/tests/unit/tab.js | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'js/tests/unit/tab.js') diff --git a/js/tests/unit/tab.js b/js/tests/unit/tab.js index e28ca83a75..3ce29b6624 100644 --- a/js/tests/unit/tab.js +++ b/js/tests/unit/tab.js @@ -414,4 +414,49 @@ $(function () { }) .trigger($.Event('click')) }) + + QUnit.test('should handle removed tabs', function (assert) { + assert.expect(1) + var done = assert.async() + + var html = [ + '', + '
', + '
test 1
', + '
test 2
', + '
test 3
', + '
' + ].join('') + + $(html).appendTo('#qunit-fixture') + + $('#secondNav').on('shown.bs.tab', function () { + assert.strictEqual($('.nav-tab').length, 2) + done() + }) + + $('#btnClose').one('click', function () { + var tabId = $(this).parents('a').attr('href') + $(this).parents('li').remove() + $(tabId).remove() + $('.nav-tabs a:last').bootstrapTab('show') + }) + .trigger($.Event('click')) + }) }) -- cgit v1.2.3