Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bootstrap
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
bootstrap
Commits
b3a125e9
Commit
b3a125e9
authored
Jun 18, 2014
by
Heinrich Fenkart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean tab unit tests up
parent
05ba1e49
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
19 deletions
+27
-19
js/tests/unit/tab.js
js/tests/unit/tab.js
+27
-19
No files found.
js/tests/unit/tab.js
View file @
b3a125e9
...
@@ -19,11 +19,14 @@ $(function () {
...
@@ -19,11 +19,14 @@ $(function () {
})
})
test
(
'
should provide no conflict
'
,
function
()
{
test
(
'
should provide no conflict
'
,
function
()
{
ok
(
!
$
.
fn
.
tab
,
'
tab was set back to undefined (org value)
'
)
strictEqual
(
$
.
fn
.
tab
,
undefined
,
'
tab was set back to undefined (org value)
'
)
})
})
test
(
'
should return element
'
,
function
()
{
test
(
'
should return jquery collection containing the element
'
,
function
()
{
ok
(
$
(
document
.
body
).
bootstrapTab
()[
0
]
==
document
.
body
,
'
document.body returned
'
)
var
$el
=
$
(
'
<div/>
'
)
var
$tab
=
$el
.
bootstrapTab
()
ok
(
$tab
instanceof
$
,
'
returns jquery collection
'
)
strictEqual
(
$tab
[
0
],
$el
[
0
],
'
collection contains element
'
)
})
})
test
(
'
should activate element by tab id
'
,
function
()
{
test
(
'
should activate element by tab id
'
,
function
()
{
...
@@ -32,7 +35,7 @@ $(function () {
...
@@ -32,7 +35,7 @@ $(function () {
'
<li><a href="#profile">Profile</a></li>
'
+
'
<li><a href="#profile">Profile</a></li>
'
+
'
</ul>
'
'
</ul>
'
$
(
'
<ul><li id="home"
></li><li id="profile"></li
></ul>
'
).
appendTo
(
'
#qunit-fixture
'
)
$
(
'
<ul><li id="home"
/><li id="profile"/
></ul>
'
).
appendTo
(
'
#qunit-fixture
'
)
$
(
tabsHTML
).
find
(
'
li:last a
'
).
bootstrapTab
(
'
show
'
)
$
(
tabsHTML
).
find
(
'
li:last a
'
).
bootstrapTab
(
'
show
'
)
equal
(
$
(
'
#qunit-fixture
'
).
find
(
'
.active
'
).
attr
(
'
id
'
),
'
profile
'
)
equal
(
$
(
'
#qunit-fixture
'
).
find
(
'
.active
'
).
attr
(
'
id
'
),
'
profile
'
)
...
@@ -47,7 +50,7 @@ $(function () {
...
@@ -47,7 +50,7 @@ $(function () {
'
<li><a href="#profile">Profile</a></li>
'
+
'
<li><a href="#profile">Profile</a></li>
'
+
'
</ul>
'
'
</ul>
'
$
(
'
<ul><li id="home"
></li><li id="profile"></li
></ul>
'
).
appendTo
(
'
#qunit-fixture
'
)
$
(
'
<ul><li id="home"
/><li id="profile"/
></ul>
'
).
appendTo
(
'
#qunit-fixture
'
)
$
(
pillsHTML
).
find
(
'
li:last a
'
).
bootstrapTab
(
'
show
'
)
$
(
pillsHTML
).
find
(
'
li:last a
'
).
bootstrapTab
(
'
show
'
)
equal
(
$
(
'
#qunit-fixture
'
).
find
(
'
.active
'
).
attr
(
'
id
'
),
'
profile
'
)
equal
(
$
(
'
#qunit-fixture
'
).
find
(
'
.active
'
).
attr
(
'
id
'
),
'
profile
'
)
...
@@ -56,23 +59,24 @@ $(function () {
...
@@ -56,23 +59,24 @@ $(function () {
equal
(
$
(
'
#qunit-fixture
'
).
find
(
'
.active
'
).
attr
(
'
id
'
),
'
home
'
)
equal
(
$
(
'
#qunit-fixture
'
).
find
(
'
.active
'
).
attr
(
'
id
'
),
'
home
'
)
})
})
test
(
'
should not fire shown when show is prevented
'
,
function
()
{
test
(
'
should not fire closed when close is prevented
'
,
function
()
{
$
.
support
.
transition
=
false
stop
()
stop
()
$
(
'
<div class="tab"/>
'
)
$
(
'
<div class="tab"/>
'
)
.
on
(
'
show.bs.tab
'
,
function
(
e
)
{
.
on
(
'
show.bs.tab
'
,
function
(
e
)
{
e
.
preventDefault
()
e
.
preventDefault
()
ok
(
true
)
ok
(
true
,
'
show event fired
'
)
start
()
start
()
})
})
.
on
(
'
shown.bs.tab
'
,
function
()
{
.
on
(
'
shown.bs.tab
'
,
function
()
{
ok
(
false
)
ok
(
false
,
'
shown event fired
'
)
})
})
.
bootstrapTab
(
'
show
'
)
.
bootstrapTab
(
'
show
'
)
})
})
test
(
'
show and shown events should reference correct relatedTarget
'
,
function
()
{
test
(
'
show and shown events should reference correct relatedTarget
'
,
function
()
{
stop
()
var
dropHTML
=
'
<ul class="drop">
'
+
var
dropHTML
=
'
<ul class="drop">
'
+
'
<li class="dropdown"><a data-toggle="dropdown" href="#">1</a>
'
+
'
<li class="dropdown"><a data-toggle="dropdown" href="#">1</a>
'
+
'
<ul class="dropdown-menu">
'
+
'
<ul class="dropdown-menu">
'
+
...
@@ -82,15 +86,19 @@ $(function () {
...
@@ -82,15 +86,19 @@ $(function () {
'
</li>
'
+
'
</li>
'
+
'
</ul>
'
'
</ul>
'
$
(
dropHTML
).
find
(
'
ul>li:first a
'
).
bootstrapTab
(
'
show
'
).
end
()
$
(
dropHTML
)
.
find
(
'
ul>li:last a
'
)
.
find
(
'
ul > li:first a
'
)
.
on
(
'
show.bs.tab
'
,
function
(
event
)
{
.
bootstrapTab
(
'
show
'
)
equal
(
event
.
relatedTarget
.
hash
,
'
#1-1
'
)
.
end
()
})
.
find
(
'
ul > li:last a
'
)
.
on
(
'
show.bs.tab
'
,
function
(
event
)
{
.
on
(
'
show.bs.tab
'
,
function
(
e
)
{
equal
(
event
.
relatedTarget
.
hash
,
'
#1-1
'
)
equal
(
e
.
relatedTarget
.
hash
,
'
#1-1
'
,
'
references correct element as relatedTarget
'
)
})
start
()
.
bootstrapTab
(
'
show
'
)
})
.
on
(
'
shown.bs.tab
'
,
function
(
e
)
{
equal
(
e
.
relatedTarget
.
hash
,
'
#1-1
'
,
'
references correct element as relatedTarget
'
)
})
.
bootstrapTab
(
'
show
'
)
})
})
})
})
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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