Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Bootstrap
bootstrap
Commits
dd992c72
Commit
dd992c72
authored
4 years ago
by
XhmikosR
Browse files
Options
Download
Email Patches
Plain Diff
Add tests
parent
adc857f6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
js/tests/unit/tooltip.spec.js
+53
-0
js/tests/unit/tooltip.spec.js
with
53 additions
and
0 deletions
+53
-0
js/tests/unit/tooltip.spec.js
+
53
-
0
View file @
dd992c72
...
@@ -1050,6 +1050,59 @@ describe('Tooltip', () => {
...
@@ -1050,6 +1050,59 @@ describe('Tooltip', () => {
})
})
})
})
describe
(
'
aria-label
'
,
()
=>
{
it
(
'
should add the aria-label attribute for referencing original title
'
,
done
=>
{
fixtureEl
.
innerHTML
=
'
<a href="#" rel="tooltip" title="Another tooltip"></a>
'
const
tooltipEl
=
fixtureEl
.
querySelector
(
'
a
'
)
const
tooltip
=
new
Tooltip
(
tooltipEl
)
tooltipEl
.
addEventListener
(
'
shown.bs.tooltip
'
,
()
=>
{
const
tooltipShown
=
document
.
querySelector
(
'
.tooltip
'
)
expect
(
tooltipShown
).
toBeDefined
()
expect
(
tooltipEl
.
getAttribute
(
'
aria-label
'
)).
toEqual
(
'
Another tooltip
'
)
done
()
})
tooltip
.
show
()
})
it
(
'
should not add the aria-label attribute if the attribute already exists
'
,
done
=>
{
fixtureEl
.
innerHTML
=
'
<a href="#" rel="tooltip" aria-label="Different label" title="Another tooltip"></a>
'
const
tooltipEl
=
fixtureEl
.
querySelector
(
'
a
'
)
const
tooltip
=
new
Tooltip
(
tooltipEl
)
tooltipEl
.
addEventListener
(
'
shown.bs.tooltip
'
,
()
=>
{
const
tooltipShown
=
document
.
querySelector
(
'
.tooltip
'
)
expect
(
tooltipShown
).
toBeDefined
()
expect
(
tooltipEl
.
getAttribute
(
'
aria-label
'
)).
toEqual
(
'
Different label
'
)
done
()
})
tooltip
.
show
()
})
it
(
'
should not add the aria-label attribute if the element has text content
'
,
done
=>
{
fixtureEl
.
innerHTML
=
'
<a href="#" rel="tooltip" title="Another tooltip">text content</a>
'
const
tooltipEl
=
fixtureEl
.
querySelector
(
'
a
'
)
const
tooltip
=
new
Tooltip
(
tooltipEl
)
tooltipEl
.
addEventListener
(
'
shown.bs.tooltip
'
,
()
=>
{
const
tooltipShown
=
document
.
querySelector
(
'
.tooltip
'
)
expect
(
tooltipShown
).
toBeDefined
()
expect
(
tooltipEl
.
getAttribute
(
'
aria-label
'
)).
toBeNull
()
done
()
})
tooltip
.
show
()
})
})
describe
(
'
jQueryInterface
'
,
()
=>
{
describe
(
'
jQueryInterface
'
,
()
=>
{
it
(
'
should create a tooltip
'
,
()
=>
{
it
(
'
should create a tooltip
'
,
()
=>
{
fixtureEl
.
innerHTML
=
'
<div></div>
'
fixtureEl
.
innerHTML
=
'
<div></div>
'
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment