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
8008fe70
Commit
8008fe70
authored
Nov 15, 2014
by
Chris Rebert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add unit tests for Carousel's 'wrap' option
parent
939e759f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
153 additions
and
0 deletions
+153
-0
js/tests/unit/carousel.js
js/tests/unit/carousel.js
+153
-0
No files found.
js/tests/unit/carousel.js
View file @
8008fe70
...
...
@@ -541,4 +541,157 @@ $(function () {
strictEqual
(
type
in
$
.
_data
(
$template
[
0
],
'
events
'
),
!
isMobile
,
'
does
'
+
(
isMobile
?
'
not
'
:
''
)
+
'
listen for
'
+
type
+
'
events
'
)
})
})
test
(
'
should wrap around from end to start when wrap option is true
'
,
function
()
{
var
carouselHTML
=
'
<div id="carousel-example-generic" class="carousel slide" data-wrap="true">
'
+
'
<ol class="carousel-indicators">
'
+
'
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"/>
'
+
'
<li data-target="#carousel-example-generic" data-slide-to="1"/>
'
+
'
<li data-target="#carousel-example-generic" data-slide-to="2"/>
'
+
'
</ol>
'
+
'
<div class="carousel-inner">
'
+
'
<div class="item active" id="one">
'
+
'
<div class="carousel-caption"/>
'
+
'
</div>
'
+
'
<div class="item" id="two">
'
+
'
<div class="carousel-caption"/>
'
+
'
</div>
'
+
'
<div class="item" id="three">
'
+
'
<div class="carousel-caption"/>
'
+
'
</div>
'
+
'
</div>
'
+
'
<a class="left carousel-control" href="#carousel-example-generic" data-slide="prev"/>
'
+
'
<a class="right carousel-control" href="#carousel-example-generic" data-slide="next"/>
'
+
'
</div>
'
var
$carousel
=
$
(
carouselHTML
)
var
getActiveId
=
function
()
{
return
$carousel
.
find
(
'
.item.active
'
).
attr
(
'
id
'
)
}
stop
()
$carousel
.
one
(
'
slid.bs.carousel
'
,
function
()
{
strictEqual
(
getActiveId
(),
'
two
'
,
'
carousel slid from 1st to 2nd slide
'
)
$carousel
.
one
(
'
slid.bs.carousel
'
,
function
()
{
strictEqual
(
getActiveId
(),
'
three
'
,
'
carousel slid from 2nd to 3rd slide
'
)
$carousel
.
one
(
'
slid.bs.carousel
'
,
function
()
{
strictEqual
(
getActiveId
(),
'
one
'
,
'
carousel wrapped around and slid from 3rd to 1st slide
'
)
start
()
})
.
bootstrapCarousel
(
'
next
'
)
})
.
bootstrapCarousel
(
'
next
'
)
})
.
bootstrapCarousel
(
'
next
'
)
})
test
(
'
should wrap around from start to end when wrap option is true
'
,
function
()
{
var
carouselHTML
=
'
<div id="carousel-example-generic" class="carousel slide" data-wrap="true">
'
+
'
<ol class="carousel-indicators">
'
+
'
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"/>
'
+
'
<li data-target="#carousel-example-generic" data-slide-to="1"/>
'
+
'
<li data-target="#carousel-example-generic" data-slide-to="2"/>
'
+
'
</ol>
'
+
'
<div class="carousel-inner">
'
+
'
<div class="item active" id="one">
'
+
'
<div class="carousel-caption"/>
'
+
'
</div>
'
+
'
<div class="item" id="two">
'
+
'
<div class="carousel-caption"/>
'
+
'
</div>
'
+
'
<div class="item" id="three">
'
+
'
<div class="carousel-caption"/>
'
+
'
</div>
'
+
'
</div>
'
+
'
<a class="left carousel-control" href="#carousel-example-generic" data-slide="prev"/>
'
+
'
<a class="right carousel-control" href="#carousel-example-generic" data-slide="next"/>
'
+
'
</div>
'
var
$carousel
=
$
(
carouselHTML
)
stop
()
$carousel
.
on
(
'
slid.bs.carousel
'
,
function
()
{
strictEqual
(
$carousel
.
find
(
'
.item.active
'
).
attr
(
'
id
'
),
'
three
'
,
'
carousel wrapped around and slid from 1st to 3rd slide
'
)
start
()
})
.
bootstrapCarousel
(
'
prev
'
)
})
test
(
'
should stay at the end when the next method is called and wrap is false
'
,
function
()
{
var
carouselHTML
=
'
<div id="carousel-example-generic" class="carousel slide" data-wrap="false">
'
+
'
<ol class="carousel-indicators">
'
+
'
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"/>
'
+
'
<li data-target="#carousel-example-generic" data-slide-to="1"/>
'
+
'
<li data-target="#carousel-example-generic" data-slide-to="2"/>
'
+
'
</ol>
'
+
'
<div class="carousel-inner">
'
+
'
<div class="item active" id="one">
'
+
'
<div class="carousel-caption"/>
'
+
'
</div>
'
+
'
<div class="item" id="two">
'
+
'
<div class="carousel-caption"/>
'
+
'
</div>
'
+
'
<div class="item" id="three">
'
+
'
<div class="carousel-caption"/>
'
+
'
</div>
'
+
'
</div>
'
+
'
<a class="left carousel-control" href="#carousel-example-generic" data-slide="prev"/>
'
+
'
<a class="right carousel-control" href="#carousel-example-generic" data-slide="next"/>
'
+
'
</div>
'
var
$carousel
=
$
(
carouselHTML
)
var
getActiveId
=
function
()
{
return
$carousel
.
find
(
'
.item.active
'
).
attr
(
'
id
'
)
}
stop
()
$carousel
.
one
(
'
slid.bs.carousel
'
,
function
()
{
strictEqual
(
getActiveId
(),
'
two
'
,
'
carousel slid from 1st to 2nd slide
'
)
$carousel
.
one
(
'
slid.bs.carousel
'
,
function
()
{
strictEqual
(
getActiveId
(),
'
three
'
,
'
carousel slid from 2nd to 3rd slide
'
)
$carousel
.
one
(
'
slid.bs.carousel
'
,
function
()
{
ok
(
false
,
'
carousel slid when it should not have slid
'
)
})
.
bootstrapCarousel
(
'
next
'
)
strictEqual
(
getActiveId
(),
'
three
'
,
'
carousel did not wrap around and stayed on 3rd slide
'
)
start
()
})
.
bootstrapCarousel
(
'
next
'
)
})
.
bootstrapCarousel
(
'
next
'
)
})
test
(
'
should stay at the start when the prev method is called and wrap is false
'
,
function
()
{
var
carouselHTML
=
'
<div id="carousel-example-generic" class="carousel slide" data-wrap="false">
'
+
'
<ol class="carousel-indicators">
'
+
'
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"/>
'
+
'
<li data-target="#carousel-example-generic" data-slide-to="1"/>
'
+
'
<li data-target="#carousel-example-generic" data-slide-to="2"/>
'
+
'
</ol>
'
+
'
<div class="carousel-inner">
'
+
'
<div class="item active" id="one">
'
+
'
<div class="carousel-caption"/>
'
+
'
</div>
'
+
'
<div class="item" id="two">
'
+
'
<div class="carousel-caption"/>
'
+
'
</div>
'
+
'
<div class="item" id="three">
'
+
'
<div class="carousel-caption"/>
'
+
'
</div>
'
+
'
</div>
'
+
'
<a class="left carousel-control" href="#carousel-example-generic" data-slide="prev"/>
'
+
'
<a class="right carousel-control" href="#carousel-example-generic" data-slide="next"/>
'
+
'
</div>
'
var
$carousel
=
$
(
carouselHTML
)
$carousel
.
on
(
'
slid.bs.carousel
'
,
function
()
{
ok
(
false
,
'
carousel slid when it should not have slid
'
)
})
.
bootstrapCarousel
(
'
prev
'
)
strictEqual
(
$carousel
.
find
(
'
.item.active
'
).
attr
(
'
id
'
),
'
one
'
,
'
carousel did not wrap around and stayed on 1st slide
'
)
})
})
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