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
7627b24c
Commit
7627b24c
authored
May 04, 2014
by
breaddevil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replace js scrollspy test for default behavior
parent
04028cf6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
17 deletions
+37
-17
js/tests/unit/scrollspy.js
js/tests/unit/scrollspy.js
+37
-17
No files found.
js/tests/unit/scrollspy.js
View file @
7627b24c
...
@@ -25,23 +25,6 @@ $(function () {
...
@@ -25,23 +25,6 @@ $(function () {
ok
(
$
(
document
.
body
).
bootstrapScrollspy
()[
0
]
==
document
.
body
,
'
document.body returned
'
)
ok
(
$
(
document
.
body
).
bootstrapScrollspy
()[
0
]
==
document
.
body
,
'
document.body returned
'
)
})
})
test
(
'
should switch active class on scroll
'
,
function
()
{
var
sectionHTML
=
'
<div id="masthead"></div>
'
,
topbarHTML
=
'
<div class="topbar">
'
+
'
<div class="topbar-inner">
'
+
'
<div class="container">
'
+
'
<h3><a href="#">Bootstrap</a></h3>
'
+
'
<li><a href="#masthead">Overview</a></li>
'
+
'
</ul>
'
+
'
</div>
'
+
'
</div>
'
+
'
</div>
'
,
$topbar
=
$
(
topbarHTML
).
bootstrapScrollspy
()
$
(
sectionHTML
).
append
(
'
#qunit-fixture
'
)
ok
(
$topbar
.
find
(
'
.active
'
,
true
))
})
test
(
'
should only switch active class on current target
'
,
function
()
{
test
(
'
should only switch active class on current target
'
,
function
()
{
var
sectionHTML
=
'
<div id="root" class="active">
'
+
var
sectionHTML
=
'
<div id="root" class="active">
'
+
'
<div class="topbar">
'
+
'
<div class="topbar">
'
+
...
@@ -78,4 +61,41 @@ $(function () {
...
@@ -78,4 +61,41 @@ $(function () {
$scrollSpy
.
scrollTop
(
350
);
$scrollSpy
.
scrollTop
(
350
);
ok
(
$section
.
hasClass
(
'
active
'
),
'
Active class still on root node
'
)
ok
(
$section
.
hasClass
(
'
active
'
),
'
Active class still on root node
'
)
})
})
test
(
'
should add the active class to the correct element
'
,
function
()
{
var
navbarHtml
=
'
<div class="navbar">
'
+
'
<ul class="nav">
'
+
'
<li id="li-1"><a href="#div-1">div 1</a></li>
'
+
'
<li id="li-2"><a href="#div-2">div 2</a></li>
'
+
'
</ul>
'
+
'
</div>
'
var
contentHtml
=
'
<div class="content" style="overflow: auto; height: 50px">
'
+
'
<div id="div-1" style="height: 100px; padding: 0; margin: 0">div 1</div>
'
+
'
<div id="div-2" style="height: 200px; padding: 0; margin: 0">div 2</div>
'
+
'
</div>
'
$
(
navbarHtml
).
appendTo
(
'
#qunit-fixture
'
)
var
$content
=
$
(
contentHtml
)
.
appendTo
(
'
#qunit-fixture
'
)
.
bootstrapScrollspy
({
offset
:
0
,
target
:
'
.navbar
'
})
var
testElementIsActiveAfterScroll
=
function
(
element
,
target
)
{
var
deferred
=
$
.
Deferred
()
var
scrollHeight
=
$content
.
scrollTop
()
+
$
(
target
).
position
().
top
stop
()
$content
.
one
(
'
scroll
'
,
function
()
{
ok
(
$
(
element
).
hasClass
(
'
active
'
),
'
target:
'
+
target
+
'
, element
'
+
element
)
start
()
deferred
.
resolve
()
})
$content
.
scrollTop
(
scrollHeight
)
return
deferred
.
promise
()
}
$
.
when
(
testElementIsActiveAfterScroll
(
'
#li-1
'
,
'
#div-1
'
))
.
then
(
function
()
{
return
testElementIsActiveAfterScroll
(
'
#li-2
'
,
'
#div-2
'
)
})
})
})
})
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