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
118b8c26
Commit
118b8c26
authored
Feb 23, 2015
by
Chris Rebert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
JS unit tests: use QUnit.module() & QUnit.test() everywhere
[skip validator]
parent
7c19fee3
Changes
11
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
204 additions
and
204 deletions
+204
-204
js/tests/unit/affix.js
js/tests/unit/affix.js
+8
-8
js/tests/unit/alert.js
js/tests/unit/alert.js
+8
-8
js/tests/unit/button.js
js/tests/unit/button.js
+14
-14
js/tests/unit/carousel.js
js/tests/unit/carousel.js
+23
-23
js/tests/unit/collapse.js
js/tests/unit/collapse.js
+21
-21
js/tests/unit/dropdown.js
js/tests/unit/dropdown.js
+14
-14
js/tests/unit/modal.js
js/tests/unit/modal.js
+20
-20
js/tests/unit/popover.js
js/tests/unit/popover.js
+17
-17
js/tests/unit/scrollspy.js
js/tests/unit/scrollspy.js
+9
-9
js/tests/unit/tab.js
js/tests/unit/tab.js
+13
-13
js/tests/unit/tooltip.js
js/tests/unit/tooltip.js
+57
-57
No files found.
js/tests/unit/affix.js
View file @
118b8c26
$
(
function
()
{
'
use strict
'
;
module
(
'
affix plugin
'
)
QUnit
.
module
(
'
affix plugin
'
)
test
(
'
should be defined on jquery object
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should be defined on jquery object
'
,
function
(
assert
)
{
assert
.
ok
(
$
(
document
.
body
).
affix
,
'
affix method is defined
'
)
})
module
(
'
affix
'
,
{
QUnit
.
module
(
'
affix
'
,
{
setup
:
function
()
{
// Run all tests in noConflict mode -- it's the only way to ensure that the plugin works in noConflict mode
$
.
fn
.
bootstrapAffix
=
$
.
fn
.
affix
.
noConflict
()
...
...
@@ -18,24 +18,24 @@ $(function () {
}
})
test
(
'
should provide no conflict
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should provide no conflict
'
,
function
(
assert
)
{
assert
.
strictEqual
(
$
.
fn
.
affix
,
undefined
,
'
affix was set back to undefined (org value)
'
)
})
test
(
'
should return jquery collection containing the element
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should return jquery collection containing the element
'
,
function
(
assert
)
{
var
$el
=
$
(
'
<div/>
'
)
var
$affix
=
$el
.
bootstrapAffix
()
assert
.
ok
(
$affix
instanceof
$
,
'
returns jquery collection
'
)
assert
.
strictEqual
(
$affix
[
0
],
$el
[
0
],
'
collection contains element
'
)
})
test
(
'
should exit early if element is not visible
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should exit early if element is not visible
'
,
function
(
assert
)
{
var
$affix
=
$
(
'
<div style="display: none"/>
'
).
bootstrapAffix
()
$affix
.
data
(
'
bs.affix
'
).
checkPosition
()
assert
.
ok
(
!
$affix
.
hasClass
(
'
affix
'
),
'
affix class was not added
'
)
})
test
(
'
should trigger affixed event after affix
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should trigger affixed event after affix
'
,
function
(
assert
)
{
var
done
=
assert
.
async
()
var
templateHTML
=
'
<div id="affixTarget">
'
...
...
@@ -69,7 +69,7 @@ $(function () {
},
0
)
})
test
(
'
should affix-top when scrolling up to offset when parent has padding
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should affix-top when scrolling up to offset when parent has padding
'
,
function
(
assert
)
{
var
done
=
assert
.
async
()
var
templateHTML
=
'
<div id="padding-offset" style="padding-top: 20px;">
'
...
...
js/tests/unit/alert.js
View file @
118b8c26
$
(
function
()
{
'
use strict
'
;
module
(
'
alert plugin
'
)
QUnit
.
module
(
'
alert plugin
'
)
test
(
'
should be defined on jquery object
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should be defined on jquery object
'
,
function
(
assert
)
{
assert
.
ok
(
$
(
document
.
body
).
alert
,
'
alert method is defined
'
)
})
module
(
'
alert
'
,
{
QUnit
.
module
(
'
alert
'
,
{
setup
:
function
()
{
// Run all tests in noConflict mode -- it's the only way to ensure that the plugin works in noConflict mode
$
.
fn
.
bootstrapAlert
=
$
.
fn
.
alert
.
noConflict
()
...
...
@@ -18,18 +18,18 @@ $(function () {
}
})
test
(
'
should provide no conflict
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should provide no conflict
'
,
function
(
assert
)
{
assert
.
strictEqual
(
$
.
fn
.
alert
,
undefined
,
'
alert was set back to undefined (org value)
'
)
})
test
(
'
should return jquery collection containing the element
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should return jquery collection containing the element
'
,
function
(
assert
)
{
var
$el
=
$
(
'
<div/>
'
)
var
$alert
=
$el
.
bootstrapAlert
()
assert
.
ok
(
$alert
instanceof
$
,
'
returns jquery collection
'
)
assert
.
strictEqual
(
$alert
[
0
],
$el
[
0
],
'
collection contains element
'
)
})
test
(
'
should fade element out on clicking .close
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should fade element out on clicking .close
'
,
function
(
assert
)
{
var
alertHTML
=
'
<div class="alert alert-danger fade in">
'
+
'
<a class="close" href="#" data-dismiss="alert">×</a>
'
+
'
<p><strong>Holy guacamole!</strong> Best check yo self, you
\'
re not looking too good.</p>
'
...
...
@@ -41,7 +41,7 @@ $(function () {
assert
.
equal
(
$alert
.
hasClass
(
'
in
'
),
false
,
'
remove .in class on .close click
'
)
})
test
(
'
should remove element when clicking .close
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should remove element when clicking .close
'
,
function
(
assert
)
{
var
alertHTML
=
'
<div class="alert alert-danger fade in">
'
+
'
<a class="close" href="#" data-dismiss="alert">×</a>
'
+
'
<p><strong>Holy guacamole!</strong> Best check yo self, you
\'
re not looking too good.</p>
'
...
...
@@ -55,7 +55,7 @@ $(function () {
assert
.
equal
(
$
(
'
#qunit-fixture
'
).
find
(
'
.alert
'
).
length
,
0
,
'
element removed from dom
'
)
})
test
(
'
should not fire closed when close is prevented
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should not fire closed when close is prevented
'
,
function
(
assert
)
{
var
done
=
assert
.
async
()
$
(
'
<div class="alert"/>
'
)
.
on
(
'
close.bs.alert
'
,
function
(
e
)
{
...
...
js/tests/unit/button.js
View file @
118b8c26
$
(
function
()
{
'
use strict
'
;
module
(
'
button plugin
'
)
QUnit
.
module
(
'
button plugin
'
)
test
(
'
should be defined on jquery object
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should be defined on jquery object
'
,
function
(
assert
)
{
assert
.
ok
(
$
(
document
.
body
).
button
,
'
button method is defined
'
)
})
module
(
'
button
'
,
{
QUnit
.
module
(
'
button
'
,
{
setup
:
function
()
{
// Run all tests in noConflict mode -- it's the only way to ensure that the plugin works in noConflict mode
$
.
fn
.
bootstrapButton
=
$
.
fn
.
button
.
noConflict
()
...
...
@@ -18,18 +18,18 @@ $(function () {
}
})
test
(
'
should provide no conflict
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should provide no conflict
'
,
function
(
assert
)
{
assert
.
strictEqual
(
$
.
fn
.
button
,
undefined
,
'
button was set back to undefined (org value)
'
)
})
test
(
'
should return jquery collection containing the element
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should return jquery collection containing the element
'
,
function
(
assert
)
{
var
$el
=
$
(
'
<div/>
'
)
var
$button
=
$el
.
bootstrapButton
()
assert
.
ok
(
$button
instanceof
$
,
'
returns jquery collection
'
)
assert
.
strictEqual
(
$button
[
0
],
$el
[
0
],
'
collection contains element
'
)
})
test
(
'
should return set state to loading
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should return set state to loading
'
,
function
(
assert
)
{
var
$btn
=
$
(
'
<button class="btn" data-loading-text="fat">mdo</button>
'
)
assert
.
equal
(
$btn
.
html
(),
'
mdo
'
,
'
btn text equals mdo
'
)
$btn
.
bootstrapButton
(
'
loading
'
)
...
...
@@ -42,7 +42,7 @@ $(function () {
},
0
)
})
test
(
'
should return reset state
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should return reset state
'
,
function
(
assert
)
{
var
$btn
=
$
(
'
<button class="btn" data-loading-text="fat">mdo</button>
'
)
assert
.
equal
(
$btn
.
html
(),
'
mdo
'
,
'
btn text equals mdo
'
)
$btn
.
bootstrapButton
(
'
loading
'
)
...
...
@@ -63,7 +63,7 @@ $(function () {
},
0
)
})
test
(
'
should work with an empty string as reset state
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should work with an empty string as reset state
'
,
function
(
assert
)
{
var
$btn
=
$
(
'
<button class="btn" data-loading-text="fat"/>
'
)
assert
.
equal
(
$btn
.
html
(),
''
,
'
btn text equals ""
'
)
$btn
.
bootstrapButton
(
'
loading
'
)
...
...
@@ -84,14 +84,14 @@ $(function () {
},
0
)
})
test
(
'
should toggle active
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should toggle active
'
,
function
(
assert
)
{
var
$btn
=
$
(
'
<button class="btn" data-toggle="button">mdo</button>
'
)
assert
.
ok
(
!
$btn
.
hasClass
(
'
active
'
),
'
btn does not have active class
'
)
$btn
.
bootstrapButton
(
'
toggle
'
)
assert
.
ok
(
$btn
.
hasClass
(
'
active
'
),
'
btn has class active
'
)
})
test
(
'
should toggle active when btn children are clicked
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should toggle active when btn children are clicked
'
,
function
(
assert
)
{
var
$btn
=
$
(
'
<button class="btn" data-toggle="button">mdo</button>
'
)
var
$inner
=
$
(
'
<i/>
'
)
$btn
...
...
@@ -102,14 +102,14 @@ $(function () {
assert
.
ok
(
$btn
.
hasClass
(
'
active
'
),
'
btn has class active
'
)
})
test
(
'
should toggle aria-pressed
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should toggle aria-pressed
'
,
function
(
assert
)
{
var
$btn
=
$
(
'
<button class="btn" data-toggle="button" aria-pressed="false">redux</button>
'
)
assert
.
equal
(
$btn
.
attr
(
'
aria-pressed
'
),
'
false
'
,
'
btn aria-pressed state is false
'
)
$btn
.
bootstrapButton
(
'
toggle
'
)
assert
.
equal
(
$btn
.
attr
(
'
aria-pressed
'
),
'
true
'
,
'
btn aria-pressed state is true
'
)
})
test
(
'
should toggle aria-pressed when btn children are clicked
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should toggle aria-pressed when btn children are clicked
'
,
function
(
assert
)
{
var
$btn
=
$
(
'
<button class="btn" data-toggle="button" aria-pressed="false">redux</button>
'
)
var
$inner
=
$
(
'
<i/>
'
)
$btn
...
...
@@ -120,7 +120,7 @@ $(function () {
assert
.
equal
(
$btn
.
attr
(
'
aria-pressed
'
),
'
true
'
,
'
btn aria-pressed state is true
'
)
})
test
(
'
should toggle active when btn children are clicked within btn-group
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should toggle active when btn children are clicked within btn-group
'
,
function
(
assert
)
{
var
$btngroup
=
$
(
'
<div class="btn-group" data-toggle="buttons"/>
'
)
var
$btn
=
$
(
'
<button class="btn">fat</button>
'
)
var
$inner
=
$
(
'
<i/>
'
)
...
...
@@ -132,7 +132,7 @@ $(function () {
assert
.
ok
(
$btn
.
hasClass
(
'
active
'
),
'
btn has class active
'
)
})
test
(
'
should check for closest matching toggle
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should check for closest matching toggle
'
,
function
(
assert
)
{
var
groupHTML
=
'
<div class="btn-group" data-toggle="buttons">
'
+
'
<label class="btn btn-primary active">
'
+
'
<input type="radio" name="options" id="option1" checked="true"> Option 1
'
...
...
js/tests/unit/carousel.js
View file @
118b8c26
$
(
function
()
{
'
use strict
'
;
module
(
'
carousel plugin
'
)
QUnit
.
module
(
'
carousel plugin
'
)
test
(
'
should be defined on jQuery object
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should be defined on jQuery object
'
,
function
(
assert
)
{
assert
.
ok
(
$
(
document
.
body
).
carousel
,
'
carousel method is defined
'
)
})
module
(
'
carousel
'
,
{
QUnit
.
module
(
'
carousel
'
,
{
setup
:
function
()
{
// Run all tests in noConflict mode -- it's the only way to ensure that the plugin works in noConflict mode
$
.
fn
.
bootstrapCarousel
=
$
.
fn
.
carousel
.
noConflict
()
...
...
@@ -18,18 +18,18 @@ $(function () {
}
})
test
(
'
should provide no conflict
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should provide no conflict
'
,
function
(
assert
)
{
assert
.
strictEqual
(
$
.
fn
.
carousel
,
undefined
,
'
carousel was set back to undefined (orig value)
'
)
})
test
(
'
should return jquery collection containing the element
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should return jquery collection containing the element
'
,
function
(
assert
)
{
var
$el
=
$
(
'
<div/>
'
)
var
$carousel
=
$el
.
bootstrapCarousel
()
assert
.
ok
(
$carousel
instanceof
$
,
'
returns jquery collection
'
)
assert
.
strictEqual
(
$carousel
[
0
],
$el
[
0
],
'
collection contains element
'
)
})
test
(
'
should not fire slid when slide is prevented
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should not fire slid when slide is prevented
'
,
function
(
assert
)
{
var
done
=
assert
.
async
()
$
(
'
<div class="carousel"/>
'
)
.
on
(
'
slide.bs.carousel
'
,
function
(
e
)
{
...
...
@@ -43,7 +43,7 @@ $(function () {
.
bootstrapCarousel
(
'
next
'
)
})
test
(
'
should reset when slide is prevented
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should reset when slide is prevented
'
,
function
(
assert
)
{
var
carouselHTML
=
'
<div id="carousel-example-generic" class="carousel slide">
'
+
'
<ol class="carousel-indicators">
'
+
'
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"/>
'
...
...
@@ -88,7 +88,7 @@ $(function () {
.
bootstrapCarousel
(
'
next
'
)
})
test
(
'
should fire slide event with direction
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should fire slide event with direction
'
,
function
(
assert
)
{
var
carouselHTML
=
'
<div id="myCarousel" class="carousel slide">
'
+
'
<div class="carousel-inner">
'
+
'
<div class="item active">
'
...
...
@@ -142,7 +142,7 @@ $(function () {
.
bootstrapCarousel
(
'
next
'
)
})
test
(
'
should fire slid event with direction
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should fire slid event with direction
'
,
function
(
assert
)
{
var
carouselHTML
=
'
<div id="myCarousel" class="carousel slide">
'
+
'
<div class="carousel-inner">
'
+
'
<div class="item active">
'
...
...
@@ -196,7 +196,7 @@ $(function () {
.
bootstrapCarousel
(
'
next
'
)
})
test
(
'
should fire slide event with relatedTarget
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should fire slide event with relatedTarget
'
,
function
(
assert
)
{
var
template
=
'
<div id="myCarousel" class="carousel slide">
'
+
'
<div class="carousel-inner">
'
+
'
<div class="item active">
'
...
...
@@ -242,7 +242,7 @@ $(function () {
.
bootstrapCarousel
(
'
next
'
)
})
test
(
'
should fire slid event with relatedTarget
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should fire slid event with relatedTarget
'
,
function
(
assert
)
{
var
template
=
'
<div id="myCarousel" class="carousel slide">
'
+
'
<div class="carousel-inner">
'
+
'
<div class="item active">
'
...
...
@@ -288,7 +288,7 @@ $(function () {
.
bootstrapCarousel
(
'
next
'
)
})
test
(
'
should set interval from data attribute
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should set interval from data attribute
'
,
function
(
assert
)
{
var
templateHTML
=
'
<div id="myCarousel" class="carousel slide">
'
+
'
<div class="carousel-inner">
'
+
'
<div class="item active">
'
...
...
@@ -349,7 +349,7 @@ $(function () {
$carousel
.
remove
()
})
test
(
'
should skip over non-items when using item indices
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should skip over non-items when using item indices
'
,
function
(
assert
)
{
var
templateHTML
=
'
<div id="myCarousel" class="carousel" data-interval="1814">
'
+
'
<div class="carousel-inner">
'
+
'
<div class="item active">
'
...
...
@@ -374,7 +374,7 @@ $(function () {
assert
.
strictEqual
(
$template
.
find
(
'
.item
'
)[
1
],
$template
.
find
(
'
.active
'
)[
0
],
'
second item active
'
)
})
test
(
'
should skip over non-items when using next/prev methods
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should skip over non-items when using next/prev methods
'
,
function
(
assert
)
{
var
templateHTML
=
'
<div id="myCarousel" class="carousel" data-interval="1814">
'
+
'
<div class="carousel-inner">
'
+
'
<div class="item active">
'
...
...
@@ -399,7 +399,7 @@ $(function () {
assert
.
strictEqual
(
$template
.
find
(
'
.item
'
)[
1
],
$template
.
find
(
'
.active
'
)[
0
],
'
second item active
'
)
})
test
(
'
should go to previous item if left arrow key is pressed
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should go to previous item if left arrow key is pressed
'
,
function
(
assert
)
{
var
templateHTML
=
'
<div id="myCarousel" class="carousel" data-interval="false">
'
+
'
<div class="carousel-inner">
'
+
'
<div id="first" class="item">
'
...
...
@@ -424,7 +424,7 @@ $(function () {
assert
.
strictEqual
(
$template
.
find
(
'
.item
'
)[
0
],
$template
.
find
(
'
.active
'
)[
0
],
'
first item active
'
)
})
test
(
'
should go to next item if right arrow key is pressed
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should go to next item if right arrow key is pressed
'
,
function
(
assert
)
{
var
templateHTML
=
'
<div id="myCarousel" class="carousel" data-interval="false">
'
+
'
<div class="carousel-inner">
'
+
'
<div id="first" class="item active">
'
...
...
@@ -449,7 +449,7 @@ $(function () {
assert
.
strictEqual
(
$template
.
find
(
'
.item
'
)[
1
],
$template
.
find
(
'
.active
'
)[
0
],
'
second item active
'
)
})
test
(
'
should support disabling the keyboard navigation
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should support disabling the keyboard navigation
'
,
function
(
assert
)
{
var
templateHTML
=
'
<div id="myCarousel" class="carousel" data-interval="false" data-keyboard="false">
'
+
'
<div class="carousel-inner">
'
+
'
<div id="first" class="item active">
'
...
...
@@ -478,7 +478,7 @@ $(function () {
assert
.
strictEqual
(
$template
.
find
(
'
.item
'
)[
0
],
$template
.
find
(
'
.active
'
)[
0
],
'
first item still active after left arrow press
'
)
})
test
(
'
should ignore keyboard events within <input>s and <textarea>s
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should ignore keyboard events within <input>s and <textarea>s
'
,
function
(
assert
)
{
var
templateHTML
=
'
<div id="myCarousel" class="carousel" data-interval="false">
'
+
'
<div class="carousel-inner">
'
+
'
<div id="first" class="item active">
'
...
...
@@ -520,7 +520,7 @@ $(function () {
assert
.
strictEqual
(
$template
.
find
(
'
.item
'
)[
0
],
$template
.
find
(
'
.active
'
)[
0
],
'
first item still active after left arrow press in <textarea>
'
)
})
test
(
'
should only add mouseenter and mouseleave listeners when not on mobile
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should only add mouseenter and mouseleave listeners when not on mobile
'
,
function
(
assert
)
{
var
isMobile
=
'
ontouchstart
'
in
document
.
documentElement
var
templateHTML
=
'
<div id="myCarousel" class="carousel" data-interval="false" data-pause="hover">
'
+
'
<div class="carousel-inner">
'
...
...
@@ -542,7 +542,7 @@ $(function () {
})
})
test
(
'
should wrap around from end to start when wrap option is true
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should wrap around from end to start when wrap option is true
'
,
function
(
assert
)
{
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"/>
'
...
...
@@ -586,7 +586,7 @@ $(function () {
.
bootstrapCarousel
(
'
next
'
)
})
test
(
'
should wrap around from start to end when wrap option is true
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should wrap around from start to end when wrap option is true
'
,
function
(
assert
)
{
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"/>
'
...
...
@@ -619,7 +619,7 @@ $(function () {
.
bootstrapCarousel
(
'
prev
'
)
})
test
(
'
should stay at the end when the next method is called and wrap is false
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should stay at the end when the next method is called and wrap is false
'
,
function
(
assert
)
{
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"/>
'
...
...
@@ -664,7 +664,7 @@ $(function () {
.
bootstrapCarousel
(
'
next
'
)
})
test
(
'
should stay at the start when the prev method is called and wrap is false
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should stay at the start when the prev method is called and wrap is false
'
,
function
(
assert
)
{
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"/>
'
...
...
js/tests/unit/collapse.js
View file @
118b8c26
$
(
function
()
{
'
use strict
'
;
module
(
'
collapse plugin
'
)
QUnit
.
module
(
'
collapse plugin
'
)
test
(
'
should be defined on jquery object
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should be defined on jquery object
'
,
function
(
assert
)
{
assert
.
ok
(
$
(
document
.
body
).
collapse
,
'
collapse method is defined
'
)
})
module
(
'
collapse
'
,
{
QUnit
.
module
(
'
collapse
'
,
{
setup
:
function
()
{
// Run all tests in noConflict mode -- it's the only way to ensure that the plugin works in noConflict mode
$
.
fn
.
bootstrapCollapse
=
$
.
fn
.
collapse
.
noConflict
()
...
...
@@ -18,32 +18,32 @@ $(function () {
}
})
test
(
'
should provide no conflict
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should provide no conflict
'
,
function
(
assert
)
{
assert
.
strictEqual
(
$
.
fn
.
collapse
,
undefined
,
'
collapse was set back to undefined (org value)
'
)
})
test
(
'
should return jquery collection containing the element
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should return jquery collection containing the element
'
,
function
(
assert
)
{
var
$el
=
$
(
'
<div/>
'
)
var
$collapse
=
$el
.
bootstrapCollapse
()
assert
.
ok
(
$collapse
instanceof
$
,
'
returns jquery collection
'
)
assert
.
strictEqual
(
$collapse
[
0
],
$el
[
0
],
'
collection contains element
'
)
})
test
(
'
should show a collapsed element
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should show a collapsed element
'
,
function
(
assert
)
{
var
$el
=
$
(
'
<div class="collapse"/>
'
).
bootstrapCollapse
(
'
show
'
)
assert
.
ok
(
$el
.
hasClass
(
'
in
'
),
'
has class "in"
'
)
assert
.
ok
(
!
/height/i
.
test
(
$el
.
attr
(
'
style
'
)),
'
has height reset
'
)
})
test
(
'
should hide a collapsed element
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should hide a collapsed element
'
,
function
(
assert
)
{
var
$el
=
$
(
'
<div class="collapse"/>
'
).
bootstrapCollapse
(
'
hide
'
)
assert
.
ok
(
!
$el
.
hasClass
(
'
in
'
),
'
does not have class "in"
'
)
assert
.
ok
(
/height/i
.
test
(
$el
.
attr
(
'
style
'
)),
'
has height set
'
)
})
test
(
'
should not fire shown when show is prevented
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should not fire shown when show is prevented
'
,
function
(
assert
)
{
var
done
=
assert
.
async
()
$
(
'
<div class="collapse"/>
'
)
...
...
@@ -58,7 +58,7 @@ $(function () {
.
bootstrapCollapse
(
'
show
'
)
})
test
(
'
should reset style to auto after finishing opening collapse
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should reset style to auto after finishing opening collapse
'
,
function
(
assert
)
{
var
done
=
assert
.
async
()
$
(
'
<div class="collapse" style="height: 0px"/>
'
)
...
...
@@ -72,7 +72,7 @@ $(function () {
.
bootstrapCollapse
(
'
show
'
)
})
test
(
'
should remove "collapsed" class from target when collapse is shown
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should remove "collapsed" class from target when collapse is shown
'
,
function
(
assert
)
{
var
done
=
assert
.
async
()
var
$target
=
$
(
'
<a data-toggle="collapse" class="collapsed" href="#test1"/>
'
).
appendTo
(
'
#qunit-fixture
'
)
...
...
@@ -87,7 +87,7 @@ $(function () {
$target
.
click
()
})
test
(
'
should add "collapsed" class to target when collapse is hidden
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should add "collapsed" class to target when collapse is hidden
'
,
function
(
assert
)
{
var
done
=
assert
.
async
()
var
$target
=
$
(
'
<a data-toggle="collapse" href="#test1"/>
'
).
appendTo
(
'
#qunit-fixture
'
)
...
...
@@ -102,7 +102,7 @@ $(function () {
$target
.
click
()
})
test
(
'
should not close a collapse when initialized with "show" if already shown
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should not close a collapse when initialized with "show" if already shown
'
,
function
(
assert
)
{
var
done
=
assert
.
async
()
assert
.
expect
(
0
)
...
...
@@ -118,7 +118,7 @@ $(function () {
setTimeout
(
done
,
0
)
})
test
(
'
should open a collapse when initialized with "show" if not already shown
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should open a collapse when initialized with "show" if not already shown
'
,
function
(
assert
)
{
var
done
=
assert
.
async
()
assert
.
expect
(
1
)
...
...
@@ -134,7 +134,7 @@ $(function () {
setTimeout
(
done
,
0
)
})
test
(
'
should remove "collapsed" class from active accordion target
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should remove "collapsed" class from active accordion target
'
,
function
(
assert
)
{
var
done
=
assert
.
async
()
var
accordionHTML
=
'
<div class="panel-group" id="accordion">
'
...
...
@@ -167,7 +167,7 @@ $(function () {
$target3
.
click
()
})
test
(
'
should allow dots in data-parent
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should allow dots in data-parent
'
,
function
(
assert
)
{
var
done
=
assert
.
async
()
var
accordionHTML
=
'
<div class="panel-group accordion">
'
...
...
@@ -200,7 +200,7 @@ $(function () {
$target3
.
click
()
})
test
(
'
should set aria-expanded="true" on target when collapse is shown
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should set aria-expanded="true" on target when collapse is shown
'
,
function
(
assert
)
{
var
done
=
assert
.
async
()
var
$target
=
$
(
'
<a data-toggle="collapse" class="collapsed" href="#test1" aria-expanded="false"/>
'
).
appendTo
(
'
#qunit-fixture
'
)
...
...
@@ -215,7 +215,7 @@ $(function () {
$target
.
click
()
})
test
(
'
should set aria-expanded="false" on target when collapse is hidden
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should set aria-expanded="false" on target when collapse is hidden
'
,
function
(
assert
)
{
var
done
=
assert
.
async
()
var
$target
=
$
(
'
<a data-toggle="collapse" href="#test1" aria-expanded="true"/>
'
).
appendTo
(
'
#qunit-fixture
'
)
...
...
@@ -230,7 +230,7 @@ $(function () {
$target
.
click
()
})
test
(
'
should change aria-expanded from active accordion target to "false" and set the newly active one to "true"
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should change aria-expanded from active accordion target to "false" and set the newly active one to "true"
'
,
function
(
assert
)
{
var
done
=
assert
.
async
()
var
accordionHTML
=
'
<div class="panel-group" id="accordion">
'
...
...
@@ -263,7 +263,7 @@ $(function () {
$target3
.
click
()
})
test
(
'
should not fire show event if show is prevented because other element is still transitioning
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should not fire show event if show is prevented because other element is still transitioning
'
,
function
(
assert
)
{
var
done
=
assert
.
async
()
var
accordionHTML
=
'
<div id="accordion">
'
...
...
@@ -298,7 +298,7 @@ $(function () {
},
1
)
})
test
(
'
should add "collapsed" class to target when collapse is hidden via manual invocation
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should add "collapsed" class to target when collapse is hidden via manual invocation
'
,
function
(
assert
)
{
var
done
=
assert
.
async
()
var
$target
=
$
(
'
<a data-toggle="collapse" href="#test1"/>
'
).
appendTo
(
'
#qunit-fixture
'
)
...
...
@@ -312,7 +312,7 @@ $(function () {
.
bootstrapCollapse
(
'
hide
'
)
})
test
(
'
should remove "collapsed" class from target when collapse is shown via manual invocation
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should remove "collapsed" class from target when collapse is shown via manual invocation
'
,
function
(
assert
)
{
var
done
=
assert
.
async
()
var
$target
=
$
(
'
<a data-toggle="collapse" class="collapsed" href="#test1"/>
'
).
appendTo
(
'
#qunit-fixture
'
)
...
...
js/tests/unit/dropdown.js
View file @
118b8c26
$
(
function
()
{
'
use strict
'
;
module
(
'
dropdowns plugin
'
)
QUnit
.
module
(
'
dropdowns plugin
'
)
test
(
'
should be defined on jquery object
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should be defined on jquery object
'
,
function
(
assert
)
{
assert
.
ok
(
$
(
document
.
body
).
dropdown
,
'
dropdown method is defined
'
)
})
module
(
'
dropdowns
'
,
{
QUnit
.
module
(
'
dropdowns
'
,
{
setup
:
function
()
{
// Run all tests in noConflict mode -- it's the only way to ensure that the plugin works in noConflict mode
$
.
fn
.
bootstrapDropdown
=
$
.
fn
.
dropdown
.
noConflict
()
...
...
@@ -18,18 +18,18 @@ $(function () {
}
})
test
(
'
should provide no conflict
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should provide no conflict
'
,
function
(
assert
)
{
assert
.
strictEqual
(
$
.
fn
.
dropdown
,
undefined
,
'
dropdown was set back to undefined (org value)
'
)
})
test
(
'
should return jquery collection containing the element
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should return jquery collection containing the element
'
,
function
(
assert
)
{
var
$el
=
$
(
'
<div/>
'
)
var
$dropdown
=
$el
.
bootstrapDropdown
()
assert
.
ok
(
$dropdown
instanceof
$
,
'
returns jquery collection
'
)
assert
.
strictEqual
(
$dropdown
[
0
],
$el
[
0
],
'
collection contains element
'
)
})
test
(
'
should not open dropdown if target is disabled via attribute
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should not open dropdown if target is disabled via attribute
'
,
function
(
assert
)
{
var
dropdownHTML
=
'
<ul class="tabs">
'
+
'
<li class="dropdown">
'
+
'
<button disabled href="#" class="btn dropdown-toggle" data-toggle="dropdown">Dropdown</button>
'
...
...
@@ -46,7 +46,7 @@ $(function () {
assert
.
ok
(
!
$dropdown
.
parent
(
'
.dropdown
'
).
hasClass
(
'
open
'
),
'
"open" class added on click
'
)
})
test
(
'
should not open dropdown if target is disabled via class
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should not open dropdown if target is disabled via class
'
,
function
(
assert
)
{
var
dropdownHTML
=
'
<ul class="tabs">
'
+
'
<li class="dropdown">
'
+
'
<button href="#" class="btn dropdown-toggle disabled" data-toggle="dropdown">Dropdown</button>
'
...
...
@@ -63,7 +63,7 @@ $(function () {
assert
.
ok
(
!
$dropdown
.
parent
(
'
.dropdown
'
).
hasClass
(
'
open
'
),
'
"open" class added on click
'
)
})
test
(
'
should add class open to menu if clicked
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should add class open to menu if clicked
'
,
function
(
assert
)
{
var
dropdownHTML
=
'
<ul class="tabs">
'
+
'
<li class="dropdown">
'
+
'
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown</a>
'
...
...
@@ -80,7 +80,7 @@ $(function () {
assert
.
ok
(
$dropdown
.
parent
(
'
.dropdown
'
).
hasClass
(
'
open
'
),
'
"open" class added on click
'
)
})
test
(
'
should test if element has a # before assuming it
\'
s a selector
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should test if element has a # before assuming it
\'
s a selector
'
,
function
(
assert
)
{
var
dropdownHTML
=
'
<ul class="tabs">
'
+
'
<li class="dropdown">
'
+
'
<a href="/foo/" class="dropdown-toggle" data-toggle="dropdown">Dropdown</a>
'
...
...
@@ -98,7 +98,7 @@ $(function () {
})
test
(
'
should remove "open" class if body is clicked
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should remove "open" class if body is clicked
'
,
function
(
assert
)
{
var
dropdownHTML
=
'
<ul class="tabs">
'
+
'
<li class="dropdown">
'
+
'
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown</a>
'
...
...
@@ -121,7 +121,7 @@ $(function () {
assert
.
ok
(
!
$dropdown
.
parent
(
'
.dropdown
'
).
hasClass
(
'
open
'
),
'
"open" class removed
'
)
})
test
(
'
should remove "open" class if body is clicked, with multiple dropdowns
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should remove "open" class if body is clicked, with multiple dropdowns
'
,
function
(
assert
)
{
var
dropdownHTML
=
'
<ul class="nav">
'
+
'
<li><a href="#menu1">Menu 1</a></li>
'
+
'
<li class="dropdown" id="testmenu">
'
...
...
@@ -157,7 +157,7 @@ $(function () {
assert
.
strictEqual
(
$
(
'
#qunit-fixture .open
'
).
length
,
0
,
'
"open" class removed
'
)
})
test
(
'
should fire show and hide event
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should fire show and hide event
'
,
function
(
assert
)
{
var
dropdownHTML
=
'
<ul class="tabs">
'
+
'
<li class="dropdown">
'
+
'
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown</a>
'
...
...
@@ -191,7 +191,7 @@ $(function () {
})
test
(
'
should fire shown and hidden event
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should fire shown and hidden event
'
,
function
(
assert
)
{
var
dropdownHTML
=
'
<ul class="tabs">
'
+
'
<li class="dropdown">
'
+
'
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown</a>
'
...
...
@@ -224,7 +224,7 @@ $(function () {
$
(
document
.
body
).
click
()
})
test
(
'
should ignore keyboard events within <input>s and <textarea>s
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should ignore keyboard events within <input>s and <textarea>s
'
,
function
(
assert
)
{
var
done
=
assert
.
async
()
var
dropdownHTML
=
'
<ul class="tabs">
'
...
...
js/tests/unit/modal.js
View file @
118b8c26
$
(
function
()
{
'
use strict
'
;
module
(
'
modal plugin
'
)
QUnit
.
module
(
'
modal plugin
'
)
test
(
'
should be defined on jquery object
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should be defined on jquery object
'
,
function
(
assert
)
{
assert
.
ok
(
$
(
document
.
body
).
modal
,
'
modal method is defined
'
)
})
module
(
'
modal
'
,
{
QUnit
.
module
(
'
modal
'
,
{
setup
:
function
()
{
// Run all tests in noConflict mode -- it's the only way to ensure that the plugin works in noConflict mode
$
.
fn
.
bootstrapModal
=
$
.
fn
.
modal
.
noConflict
()
...
...
@@ -18,22 +18,22 @@ $(function () {
}
})
test
(
'
should provide no conflict
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should provide no conflict
'
,
function
(
assert
)
{
assert
.
strictEqual
(
$
.
fn
.
modal
,
undefined
,
'
modal was set back to undefined (orig value)
'
)
})
test
(
'
should return jquery collection containing the element
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should return jquery collection containing the element
'
,
function
(
assert
)
{
var
$el
=
$
(
'
<div id="modal-test"/>
'
)
var
$modal
=
$el
.
bootstrapModal
()
assert
.
ok
(
$modal
instanceof
$
,
'
returns jquery collection
'
)
assert
.
strictEqual
(
$modal
[
0
],
$el
[
0
],
'
collection contains element
'
)
})
test
(
'
should expose defaults var for settings
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should expose defaults var for settings
'
,
function
(
assert
)
{
assert
.
ok
(
$
.
fn
.
bootstrapModal
.
Constructor
.
DEFAULTS
,
'
default object exposed
'
)
})
test
(
'
should insert into dom when show method is called
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should insert into dom when show method is called
'
,
function
(
assert
)
{
var
done
=
assert
.
async
()
$
(
'
<div id="modal-test"/>
'
)
...
...
@@ -44,7 +44,7 @@ $(function () {
.
bootstrapModal
(
'
show
'
)
})
test
(
'
should fire show event
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should fire show event
'
,
function
(
assert
)
{
var
done
=
assert
.
async
()
$
(
'
<div id="modal-test"/>
'
)
...
...
@@ -55,7 +55,7 @@ $(function () {
.
bootstrapModal
(
'
show
'
)
})
test
(
'
should not fire shown when show was prevented
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should not fire shown when show was prevented
'
,
function
(
assert
)
{
var
done
=
assert
.
async
()
$
(
'
<div id="modal-test"/>
'
)
...
...
@@ -70,7 +70,7 @@ $(function () {
.
bootstrapModal
(
'
show
'
)
})
test
(
'
should hide modal when hide is called
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should hide modal when hide is called
'
,
function
(
assert
)
{
var
done
=
assert
.
async
()
$
(
'
<div id="modal-test"/>
'
)
...
...
@@ -86,7 +86,7 @@ $(function () {
.
bootstrapModal
(
'
show
'
)
})
test
(
'
should toggle when toggle is called
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should toggle when toggle is called
'
,
function
(
assert
)
{
var
done
=
assert
.
async
()
$
(
'
<div id="modal-test"/>
'
)
...
...
@@ -102,7 +102,7 @@ $(function () {
.
bootstrapModal
(
'
toggle
'
)
})
test
(
'
should remove from dom when click [data-dismiss="modal"]
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should remove from dom when click [data-dismiss="modal"]
'
,
function
(
assert
)
{
var
done
=
assert
.
async
()
$
(
'
<div id="modal-test"><span class="close" data-dismiss="modal"/></div>
'
)
...
...
@@ -118,7 +118,7 @@ $(function () {
.
bootstrapModal
(
'
toggle
'
)
})
test
(
'
should allow modal close with "backdrop:false"
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should allow modal close with "backdrop:false"
'
,
function
(
assert
)
{
var
done
=
assert
.
async
()
$
(
'
<div id="modal-test" data-backdrop="false"/>
'
)
...
...
@@ -133,7 +133,7 @@ $(function () {
.
bootstrapModal
(
'
show
'
)
})
test
(
'
should close modal when clicking outside of modal-content
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should close modal when clicking outside of modal-content
'
,
function
(
assert
)
{
var
done
=
assert
.
async
()
$
(
'
<div id="modal-test"><div class="contents"/></div>
'
)
...
...
@@ -150,7 +150,7 @@ $(function () {
.
bootstrapModal
(
'
show
'
)
})
test
(
'
should close modal when escape key is pressed via keydown
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should close modal when escape key is pressed via keydown
'
,
function
(
assert
)
{
var
done
=
assert
.
async
()
var
div
=
$
(
'
<div id="modal-test"/>
'
)
...
...
@@ -169,7 +169,7 @@ $(function () {
.
bootstrapModal
(
'
show
'
)
})
test
(
'
should not close modal when escape key is pressed via keyup
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should not close modal when escape key is pressed via keyup
'
,
function
(
assert
)
{
var
done
=
assert
.
async
()
var
div
=
$
(
'
<div id="modal-test"/>
'
)
...
...
@@ -188,7 +188,7 @@ $(function () {
.
bootstrapModal
(
'
show
'
)
})
test
(
'
should trigger hide event once when clicking outside of modal-content
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should trigger hide event once when clicking outside of modal-content
'
,
function
(
assert
)
{
var
done
=
assert
.
async
()
var
triggered
...
...
@@ -206,7 +206,7 @@ $(function () {
.
bootstrapModal
(
'
show
'
)
})
test
(
'
should close reopened modal with [data-dismiss="modal"] click
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should close reopened modal with [data-dismiss="modal"] click
'
,
function
(
assert
)
{
var
done
=
assert
.
async
()
$
(
'
<div id="modal-test"><div class="contents"><div id="close" data-dismiss="modal"/></div></div>
'
)
...
...
@@ -229,7 +229,7 @@ $(function () {
.
bootstrapModal
(
'
show
'
)
})
test
(
'
should restore focus to toggling element when modal is hidden after having been opened via data-api
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should restore focus to toggling element when modal is hidden after having been opened via data-api
'
,
function
(
assert
)
{
var
done
=
assert
.
async
()
var
$toggleBtn
=
$
(
'
<button data-toggle="modal" data-target="#modal-test"/>
'
).
appendTo
(
'
#qunit-fixture
'
)
...
...
@@ -249,7 +249,7 @@ $(function () {
$toggleBtn
.
click
()
})
test
(
'
should not restore focus to toggling element if the associated show event gets prevented
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should not restore focus to toggling element if the associated show event gets prevented
'
,
function
(
assert
)
{
var
done
=
assert
.
async
()
var
$toggleBtn
=
$
(
'
<button data-toggle="modal" data-target="#modal-test"/>
'
).
appendTo
(
'
#qunit-fixture
'
)
var
$otherBtn
=
$
(
'
<button id="other-btn"/>
'
).
appendTo
(
'
#qunit-fixture
'
)
...
...
js/tests/unit/popover.js
View file @
118b8c26
$
(
function
()
{
'
use strict
'
;
module
(
'
popover plugin
'
)
QUnit
.
module
(
'
popover plugin
'
)
test
(
'
should be defined on jquery object
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should be defined on jquery object
'
,
function
(
assert
)
{
assert
.
ok
(
$
(
document
.
body
).
popover
,
'
popover method is defined
'
)
})
module
(
'
popover
'
,
{
QUnit
.
module
(
'
popover
'
,
{
setup
:
function
()
{
// Run all tests in noConflict mode -- it's the only way to ensure that the plugin works in noConflict mode
$
.
fn
.
bootstrapPopover
=
$
.
fn
.
popover
.
noConflict
()
...
...
@@ -18,18 +18,18 @@ $(function () {
}
})
test
(
'
should provide no conflict
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should provide no conflict
'
,
function
(
assert
)
{
assert
.
strictEqual
(
$
.
fn
.
popover
,
undefined
,
'
popover was set back to undefined (org value)
'
)
})
test
(
'
should return jquery collection containing the element
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should return jquery collection containing the element
'
,
function
(
assert
)
{
var
$el
=
$
(
'
<div/>
'
)
var
$popover
=
$el
.
bootstrapPopover
()
assert
.
ok
(
$popover
instanceof
$
,
'
returns jquery collection
'
)
assert
.
strictEqual
(
$popover
[
0
],
$el
[
0
],
'
collection contains element
'
)
})
test
(
'
should render popover element
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should render popover element
'
,
function
(
assert
)
{
var
$popover
=
$
(
'
<a href="#" title="mdo" data-content="https://twitter.com/mdo">@mdo</a>
'
)
.
appendTo
(
'
#qunit-fixture
'
)
.
bootstrapPopover
(
'
show
'
)
...
...
@@ -39,13 +39,13 @@ $(function () {
assert
.
equal
(
$
(
'
.popover
'
).
length
,
0
,
'
popover removed
'
)
})
test
(
'
should store popover instance in popover data object
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should store popover instance in popover data object
'
,
function
(
assert
)
{
var
$popover
=
$
(
'
<a href="#" title="mdo" data-content="https://twitter.com/mdo">@mdo</a>
'
).
bootstrapPopover
()
assert
.
ok
(
$popover
.
data
(
'
bs.popover
'
),
'
popover instance exists
'
)
})
test
(
'
should store popover trigger in popover instance data object
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should store popover trigger in popover instance data object
'
,
function
(
assert
)
{
var
$popover
=
$
(
'
<a href="#" title="ResentedHook">@ResentedHook</a>
'
)
.
appendTo
(
'
#qunit-fixture
'
)
.
bootstrapPopover
()
...
...
@@ -55,7 +55,7 @@ $(function () {
assert
.
ok
(
$
(
'
.popover
'
).
data
(
'
bs.popover
'
),
'
popover trigger stored in instance data
'
)
})
test
(
'
should get title and content from options
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should get title and content from options
'
,
function
(
assert
)
{
var
$popover
=
$
(
'
<a href="#">@fat</a>
'
)
.
appendTo
(
'
#qunit-fixture
'
)
.
bootstrapPopover
({
...
...
@@ -77,7 +77,7 @@ $(function () {
assert
.
equal
(
$
(
'
.popover
'
).
length
,
0
,
'
popover was removed
'
)
})
test
(
'
should not duplicate HTML object
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should not duplicate HTML object
'
,
function
(
assert
)
{
var
$div
=
$
(
'
<div/>
'
).
html
(
'
loves writing tests (╯°□°)╯︵ ┻━┻
'
)
var
$popover
=
$
(
'
<a href="#">@fat</a>
'
)
...
...
@@ -103,7 +103,7 @@ $(function () {
assert
.
equal
(
$
(
'
.popover
'
).
length
,
0
,
'
popover was removed
'
)
})
test
(
'
should get title and content from attributes
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should get title and content from attributes
'
,
function
(
assert
)
{
var
$popover
=
$
(
'
<a href="#" title="@mdo" data-content="loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻" >@mdo</a>
'
)
.
appendTo
(
'
#qunit-fixture
'
)
.
bootstrapPopover
()
...
...
@@ -118,7 +118,7 @@ $(function () {
})
test
(
'
should get title and content from attributes ignoring options passed via js
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should get title and content from attributes ignoring options passed via js
'
,
function
(
assert
)
{
var
$popover
=
$
(
'
<a href="#" title="@mdo" data-content="loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻" >@mdo</a>
'
)
.
appendTo
(
'
#qunit-fixture
'
)
.
bootstrapPopover
({
...
...
@@ -135,7 +135,7 @@ $(function () {
assert
.
equal
(
$
(
'
.popover
'
).
length
,
0
,
'
popover was removed
'
)
})
test
(
'
should respect custom template
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should respect custom template
'
,
function
(
assert
)
{
var
$popover
=
$
(
'
<a href="#">@fat</a>
'
)
.
appendTo
(
'
#qunit-fixture
'
)
.
bootstrapPopover
({
...
...
@@ -153,7 +153,7 @@ $(function () {
assert
.
equal
(
$
(
'
.popover
'
).
length
,
0
,
'
popover was removed
'
)
})
test
(
'
should destroy popover
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should destroy popover
'
,
function
(
assert
)
{
var
$popover
=
$
(
'
<div/>
'
)
.
bootstrapPopover
({
trigger
:
'
hover
'
...
...
@@ -173,7 +173,7 @@ $(function () {
assert
.
ok
(
!
$
.
_data
(
$popover
[
0
],
'
events
'
).
mouseover
&&
!
$
.
_data
(
$popover
[
0
],
'
events
'
).
mouseout
,
'
popover does not have any events
'
)
})
test
(
'
should render popover element using delegated selector
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should render popover element using delegated selector
'
,
function
(
assert
)
{
var
$div
=
$
(
'
<div><a href="#" title="mdo" data-content="http://twitter.com/mdo">@mdo</a></div>
'
)
.
appendTo
(
'
#qunit-fixture
'
)
.
bootstrapPopover
({
...
...
@@ -188,7 +188,7 @@ $(function () {
assert
.
equal
(
$
(
'
.popover
'
).
length
,
0
,
'
popover was removed
'
)
})
test
(
'
should detach popover content rather than removing it so that event handlers are left intact
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should detach popover content rather than removing it so that event handlers are left intact
'
,
function
(
assert
)
{
var
$content
=
$
(
'
<div class="content-with-handler"><a class="btn btn-warning">Button with event handler</a></div>
'
).
appendTo
(
'
#qunit-fixture
'
)
var
handlerCalled
=
false
...
...
@@ -226,7 +226,7 @@ $(function () {
.
bootstrapPopover
(
'
show
'
)
})
test
(
'
should throw an error when initializing popover on the document object without specifying a delegation selector
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should throw an error when initializing popover on the document object without specifying a delegation selector
'
,
function
(
assert
)
{
assert
.
throws
(
function
()
{
$
(
document
).
bootstrapPopover
({
title
:
'
What am I on?
'
,
content
:
'
My selector is missing
'
})
},
new
Error
(
'
`selector` option must be specified when initializing popover on the window.document object!
'
))
...
...
js/tests/unit/scrollspy.js
View file @
118b8c26
$
(
function
()
{
'
use strict
'
;
module
(
'
scrollspy plugin
'
)
QUnit
.
module
(
'
scrollspy plugin
'
)
test
(
'
should be defined on jquery object
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should be defined on jquery object
'
,
function
(
assert
)
{
assert
.
ok
(
$
(
document
.
body
).
scrollspy
,
'
scrollspy method is defined
'
)
})
module
(
'
scrollspy
'
,
{
QUnit
.
module
(
'
scrollspy
'
,
{
setup
:
function
()
{
// Run all tests in noConflict mode -- it's the only way to ensure that the plugin works in noConflict mode
$
.
fn
.
bootstrapScrollspy
=
$
.
fn
.
scrollspy
.
noConflict
()
...
...
@@ -18,18 +18,18 @@ $(function () {
}
})
test
(
'
should provide no conflict
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should provide no conflict
'
,
function
(
assert
)
{
assert
.
strictEqual
(
$
.
fn
.
scrollspy
,
undefined
,
'
scrollspy was set back to undefined (org value)
'
)
})
test
(
'
should return jquery collection containing the element
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should return jquery collection containing the element
'
,
function
(
assert
)
{
var
$el
=
$
(
'
<div/>
'
)
var
$scrollspy
=
$el
.
bootstrapScrollspy
()
assert
.
ok
(
$scrollspy
instanceof
$
,
'
returns jquery collection
'
)
assert
.
strictEqual
(
$scrollspy
[
0
],
$el
[
0
],
'
collection contains element
'
)
})
test
(
'
should only switch "active" class on current target
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should only switch "active" class on current target
'
,
function
(
assert
)
{
var
done
=
assert
.
async
()
var
sectionHTML
=
'
<div id="root" class="active">
'
...
...
@@ -73,7 +73,7 @@ $(function () {
$scrollspy
.
scrollTop
(
350
)
})
test
(
'
should correctly select middle navigation option when large offset is used
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should correctly select middle navigation option when large offset is used
'
,
function
(
assert
)
{
var
done
=
assert
.
async
()
var
sectionHTML
=
'
<div id="header" style="height: 500px;"></div>
'
...
...
@@ -106,7 +106,7 @@ $(function () {
$scrollspy
.
scrollTop
(
550
)
})
test
(
'
should add the active class to the correct element
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should add the active class to the correct element
'
,
function
(
assert
)
{
var
navbarHtml
=
'
<nav class="navbar">
'
+
'
<ul class="nav">
'
...
...
@@ -142,7 +142,7 @@ $(function () {
.
then
(
function
()
{
return
testElementIsActiveAfterScroll
(
'
#li-2
'
,
'
#div-2
'
)
})
})
test
(
'
should clear selection if above the first section
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should clear selection if above the first section
'
,
function
(
assert
)
{
var
done
=
assert
.
async
()
var
sectionHTML
=
'
<div id="header" style="height: 500px;"></div>
'
...
...
js/tests/unit/tab.js
View file @
118b8c26
$
(
function
()
{
'
use strict
'
;
module
(
'
tabs plugin
'
)
QUnit
.
module
(
'
tabs plugin
'
)
test
(
'
should be defined on jquery object
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should be defined on jquery object
'
,
function
(
assert
)
{
assert
.
ok
(
$
(
document
.
body
).
tab
,
'
tabs method is defined
'
)
})
module
(
'
tabs
'
,
{
QUnit
.
module
(
'
tabs
'
,
{
setup
:
function
()
{
// Run all tests in noConflict mode -- it's the only way to ensure that the plugin works in noConflict mode
$
.
fn
.
bootstrapTab
=
$
.
fn
.
tab
.
noConflict
()
...
...
@@ -18,18 +18,18 @@ $(function () {
}
})
test
(
'
should provide no conflict
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should provide no conflict
'
,
function
(
assert
)
{
assert
.
strictEqual
(
$
.
fn
.
tab
,
undefined
,
'
tab was set back to undefined (org value)
'
)
})
test
(
'
should return jquery collection containing the element
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should return jquery collection containing the element
'
,
function
(
assert
)
{
var
$el
=
$
(
'
<div/>
'
)
var
$tab
=
$el
.
bootstrapTab
()
assert
.
ok
(
$tab
instanceof
$
,
'
returns jquery collection
'
)
assert
.
strictEqual
(
$tab
[
0
],
$el
[
0
],
'
collection contains element
'
)
})
test
(
'
should activate element by tab id
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should activate element by tab id
'
,
function
(
assert
)
{
var
tabsHTML
=
'
<ul class="tabs">
'
+
'
<li><a href="#home">Home</a></li>
'
+
'
<li><a href="#profile">Profile</a></li>
'
...
...
@@ -44,7 +44,7 @@ $(function () {
assert
.
equal
(
$
(
'
#qunit-fixture
'
).
find
(
'
.active
'
).
attr
(
'
id
'
),
'
home
'
)
})
test
(
'
should activate element by tab id
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should activate element by tab id
'
,
function
(
assert
)
{
var
pillsHTML
=
'
<ul class="pills">
'
+
'
<li><a href="#home">Home</a></li>
'
+
'
<li><a href="#profile">Profile</a></li>
'
...
...
@@ -59,7 +59,7 @@ $(function () {
assert
.
equal
(
$
(
'
#qunit-fixture
'
).
find
(
'
.active
'
).
attr
(
'
id
'
),
'
home
'
)
})
test
(
'
should not fire shown when show is prevented
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should not fire shown when show is prevented
'
,
function
(
assert
)
{
var
done
=
assert
.
async
()
$
(
'
<div class="tab"/>
'
)
...
...
@@ -74,7 +74,7 @@ $(function () {
.
bootstrapTab
(
'
show
'
)
})
test
(
'
show and shown events should reference correct relatedTarget
'
,
function
(
assert
)
{
QUnit
.
test
(
'
show and shown events should reference correct relatedTarget
'
,
function
(
assert
)
{
var
done
=
assert
.
async
()
var
dropHTML
=
'
<ul class="drop">
'
...
...
@@ -101,7 +101,7 @@ $(function () {
.
bootstrapTab
(
'
show
'
)
})
test
(
'
should fire hide and hidden events
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should fire hide and hidden events
'
,
function
(
assert
)
{
var
done
=
assert
.
async
()
var
tabsHTML
=
'
<ul class="tabs">
'
...
...
@@ -131,7 +131,7 @@ $(function () {
.
bootstrapTab
(
'
show
'
)
})
test
(
'
should not fire hidden when hide is prevented
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should not fire hidden when hide is prevented
'
,
function
(
assert
)
{
var
done
=
assert
.
async
()
var
tabsHTML
=
'
<ul class="tabs">
'
...
...
@@ -155,7 +155,7 @@ $(function () {
.
bootstrapTab
(
'
show
'
)
})
test
(
'
hide and hidden events contain correct relatedTarget
'
,
function
(
assert
)
{
QUnit
.
test
(
'
hide and hidden events contain correct relatedTarget
'
,
function
(
assert
)
{
var
done
=
assert
.
async
()
var
tabsHTML
=
'
<ul class="tabs">
'
...
...
@@ -178,7 +178,7 @@ $(function () {
.
bootstrapTab
(
'
show
'
)
})
test
(
'
selected tab should have aria-expanded
'
,
function
(
assert
)
{
QUnit
.
test
(
'
selected tab should have aria-expanded
'
,
function
(
assert
)
{
var
tabsHTML
=
'
<ul class="nav nav-tabs">
'
+
'
<li class="active"><a href="#home" toggle="tab" aria-expanded="true">Home</a></li>
'
+
'
<li><a href="#profile" toggle="tab" aria-expanded="false">Profile</a></li>
'
...
...
js/tests/unit/tooltip.js
View file @
118b8c26
This diff is collapsed.
Click to expand it.
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