aboutsummaryrefslogtreecommitdiff
path: root/js/tests
diff options
context:
space:
mode:
authorChris Rebert <[email protected]>2014-05-23 14:11:15 -0700
committerChris Rebert <[email protected]>2014-05-23 14:11:15 -0700
commitef6225491729ee3ec3804250e3dddb69cc95fba0 (patch)
tree78ccf7531d9dc79343ac370bc36a2e763f42d858 /js/tests
parent66bc4d1c677cf83032c4b40563630910c911aca9 (diff)
parenta70da16f6fb8c665f22b78b49a1dff998f1da8a7 (diff)
downloadbootstrap-ef6225491729ee3ec3804250e3dddb69cc95fba0.tar.xz
bootstrap-ef6225491729ee3ec3804250e3dddb69cc95fba0.zip
Merge pull request #13557 from bassettsj/aria-describedby-tooltip-13480
Aria describedby tooltip: #13480
Diffstat (limited to 'js/tests')
-rw-r--r--js/tests/unit/tooltip.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/js/tests/unit/tooltip.js b/js/tests/unit/tooltip.js
index e579a9ef7..e95b91cbb 100644
--- a/js/tests/unit/tooltip.js
+++ b/js/tests/unit/tooltip.js
@@ -41,6 +41,36 @@ $(function () {
equal(tooltip.attr('data-original-title'), 'Another tooltip', 'original title preserved in data attribute')
})
+ test('should add set set aria describedby to the element called on show', function() {
+ var tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"></a>').bootstrapTooltip()
+ .appendTo('#qunit-fixture')
+ .bootstrapTooltip('show')
+ ok(tooltip.attr('aria-describedby'), 'has the right attributes')
+ var id = $('.tooltip').attr('id')
+
+ ok($('#' + id).length == 1, 'has a unique id')
+ ok($('.tooltip').attr('aria-describedby') === tooltip.attr('id'), 'they match!')
+ ok(tooltip.attr('aria-describedby') !== undefined, 'has the right attributes')
+ })
+
+ test('should remove the aria-describedby attributes on hide', function() {
+ var tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"></a>').bootstrapTooltip()
+ .appendTo('#qunit-fixture')
+ .bootstrapTooltip('show')
+ ok(tooltip.attr('aria-describedby'), 'has the right attributes')
+ tooltip.bootstrapTooltip('hide')
+ ok(!tooltip.attr('aria-describedby'), 'removed the attributes on hide')
+ })
+
+ test('should assign a unique id tooltip element', function () {
+ $('<a href="#" rel="tooltip" title="Another tooltip"></a>')
+ .appendTo('#qunit-fixture')
+ .bootstrapTooltip('show'),
+ id = $('.tooltip').attr('id')
+
+ ok( $('#' + id).length == 1 && id.indexOf('tooltip') === 0, 'generated prefixed and unique tooltip id')
+ })
+
test('should place tooltips relative to placement option', function () {
$.support.transition = false
var tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"></a>')