mirror of
https://github.com/twbs/bootstrap.git
synced 2024-12-01 13:24:25 +01:00
add unit test to test tabs can be removed without throwing error
This commit is contained in:
parent
a282c22fc7
commit
2c2d04aba5
@ -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 = [
|
||||
'<ul class="nav nav-tabs" role="tablist">',
|
||||
' <li class="nav-item">',
|
||||
' <a class="nav-link nav-tab" href="#profile" role="tab" data-toggle="tab">',
|
||||
' <button class="close"><span aria-hidden="true">×</span></button>',
|
||||
' </a>',
|
||||
' </li>',
|
||||
' <li class="nav-item">',
|
||||
' <a id="secondNav" class="nav-link nav-tab" href="#buzz" role="tab" data-toggle="tab">',
|
||||
' <button class="close"><span aria-hidden="true">×</span></button>',
|
||||
' </a>',
|
||||
' </li>',
|
||||
' <li class="nav-item">',
|
||||
' <a class="nav-link nav-tab" href="#references" role="tab" data-toggle="tab">',
|
||||
' <button id="btnClose" class="close"><span aria-hidden="true">×</span></button>',
|
||||
' </a>',
|
||||
' </li>',
|
||||
'</ul>',
|
||||
'<div class="tab-content">',
|
||||
' <div role="tabpanel" class="tab-pane fade show active" id="profile">test 1</div>',
|
||||
' <div role="tabpanel" class="tab-pane fade" id="buzz">test 2</div>',
|
||||
' <div role="tabpanel" class="tab-pane fade" id="references">test 3</div>',
|
||||
'</div>'
|
||||
].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'))
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user