Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jquery
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
夏彬
jquery
Commits
305eefe6
Commit
305eefe6
authored
Dec 24, 2013
by
cjqed
Committed by
Oleg
Jan 03, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tests: Avoid use of QUnit.reset() in tests by splitting them
Closes gh-1470 Ref #1457
parent
3140d3bd
Changes
7
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
563 additions
and
225 deletions
+563
-225
testrunner.js
test/data/testrunner.js
+8
-9
attributes.js
test/unit/attributes.js
+14
-9
core.js
test/unit/core.js
+0
-2
css.js
test/unit/css.js
+8
-4
effects.js
test/unit/effects.js
+3
-3
manipulation.js
test/unit/manipulation.js
+468
-172
wrap.js
test/unit/wrap.js
+62
-26
No files found.
test/data/testrunner.js
View file @
305eefe6
...
@@ -13,7 +13,7 @@ var oldStart = window.start,
...
@@ -13,7 +13,7 @@ var oldStart = window.start,
expectedDataKeys
=
{},
expectedDataKeys
=
{},
splice
=
[].
splice
,
splice
=
[].
splice
,
reset
=
QUnit
.
reset
,
reset
,
ajaxSettings
=
jQuery
.
ajaxSettings
;
ajaxSettings
=
jQuery
.
ajaxSettings
;
...
@@ -157,8 +157,7 @@ window.moduleTeardown = function() {
...
@@ -157,8 +157,7 @@ window.moduleTeardown = function() {
oldActive
=
jQuery
.
active
;
oldActive
=
jQuery
.
active
;
}
}
// Allow QUnit.reset to clean up any attached elements before checking for leaks
reset
();
QUnit
.
reset
();
for
(
i
in
jQuery
.
cache
)
{
for
(
i
in
jQuery
.
cache
)
{
++
cacheLength
;
++
cacheLength
;
...
@@ -187,8 +186,8 @@ QUnit.done(function() {
...
@@ -187,8 +186,8 @@ QUnit.done(function() {
supportjQuery
(
"#qunit ~ *"
).
remove
();
supportjQuery
(
"#qunit ~ *"
).
remove
();
});
});
// jQuery-specific
QUnit.reset
// jQuery-specific
post-test cleanup
QUnit
.
reset
=
function
()
{
reset
=
function
()
{
// Ensure jQuery events and data on the fixture are properly removed
// Ensure jQuery events and data on the fixture are properly removed
jQuery
(
"#qunit-fixture"
).
empty
();
jQuery
(
"#qunit-fixture"
).
empty
();
...
@@ -206,10 +205,11 @@ QUnit.reset = function() {
...
@@ -206,10 +205,11 @@ QUnit.reset = function() {
// Cleanup globals
// Cleanup globals
Globals
.
cleanup
();
Globals
.
cleanup
();
// Let QUnit reset the fixture
jQuery
(
"#qunit-fixture"
)[
0
].
innerHTML
=
QUnit
.
config
.
fixture
;
reset
.
apply
(
this
,
arguments
);
};
};
QUnit
.
testDone
(
reset
);
// Register globals for cleanup and the cleanup code itself
// Register globals for cleanup and the cleanup code itself
// Explanation at http://perfectionkills.com/understanding-delete/#ie_bugs
// Explanation at http://perfectionkills.com/understanding-delete/#ie_bugs
window
.
Globals
=
(
function
()
{
window
.
Globals
=
(
function
()
{
...
@@ -351,7 +351,7 @@ function testSubproject( label, subProjectURL, risTests, complete ) {
...
@@ -351,7 +351,7 @@ function testSubproject( label, subProjectURL, risTests, complete ) {
// WARNING: UNDOCUMENTED INTERFACE
// WARNING: UNDOCUMENTED INTERFACE
QUnit
.
config
.
fixture
=
fixtureHTML
;
QUnit
.
config
.
fixture
=
fixtureHTML
;
QUnit
.
reset
();
reset
();
if
(
supportjQuery
(
"#qunit-fixture"
).
html
()
!==
fixtureHTML
)
{
if
(
supportjQuery
(
"#qunit-fixture"
).
html
()
!==
fixtureHTML
)
{
ok
(
false
,
"Copied subproject fixture"
);
ok
(
false
,
"Copied subproject fixture"
);
return
;
return
;
...
@@ -359,7 +359,6 @@ function testSubproject( label, subProjectURL, risTests, complete ) {
...
@@ -359,7 +359,6 @@ function testSubproject( label, subProjectURL, risTests, complete ) {
fixtureReplaced
=
true
;
fixtureReplaced
=
true
;
}
}
fn
.
apply
(
this
,
arguments
);
fn
.
apply
(
this
,
arguments
);
};
};
}
}
...
...
test/unit/attributes.js
View file @
305eefe6
...
@@ -639,7 +639,7 @@ test( "removeAttr(Multi String, variable space width)", function() {
...
@@ -639,7 +639,7 @@ test( "removeAttr(Multi String, variable space width)", function() {
});
});
test
(
"prop(String, Object)"
,
function
()
{
test
(
"prop(String, Object)"
,
function
()
{
expect
(
31
);
expect
(
17
);
equal
(
jQuery
(
"#text1"
).
prop
(
"value"
),
"Test"
,
"Check for value attribute"
);
equal
(
jQuery
(
"#text1"
).
prop
(
"value"
),
"Test"
,
"Check for value attribute"
);
equal
(
jQuery
(
"#text1"
).
prop
(
"value"
,
"Test2"
).
prop
(
"defaultValue"
),
"Test"
,
"Check for defaultValue attribute"
);
equal
(
jQuery
(
"#text1"
).
prop
(
"value"
,
"Test2"
).
prop
(
"defaultValue"
),
"Test"
,
"Check for defaultValue attribute"
);
...
@@ -667,7 +667,11 @@ test( "prop(String, Object)", function() {
...
@@ -667,7 +667,11 @@ test( "prop(String, Object)", function() {
equal
(
jQuery
(
"#table"
).
prop
(
"useMap"
),
1
,
"Check setting and retrieving useMap"
);
equal
(
jQuery
(
"#table"
).
prop
(
"useMap"
),
1
,
"Check setting and retrieving useMap"
);
jQuery
(
"#table"
).
prop
(
"frameborder"
,
1
);
jQuery
(
"#table"
).
prop
(
"frameborder"
,
1
);
equal
(
jQuery
(
"#table"
).
prop
(
"frameBorder"
),
1
,
"Check setting and retrieving frameBorder"
);
equal
(
jQuery
(
"#table"
).
prop
(
"frameBorder"
),
1
,
"Check setting and retrieving frameBorder"
);
QUnit
.
reset
();
});
test
(
"prop(String, Object) on null/undefined"
,
function
()
{
expect
(
14
);
var
select
,
optgroup
,
option
,
attributeNode
,
commentNode
,
textNode
,
obj
,
$form
,
var
select
,
optgroup
,
option
,
attributeNode
,
commentNode
,
textNode
,
obj
,
$form
,
body
=
document
.
body
,
body
=
document
.
body
,
...
@@ -799,16 +803,19 @@ test( "removeProp(String)", function() {
...
@@ -799,16 +803,19 @@ test( "removeProp(String)", function() {
});
});
});
});
test
(
"val()"
,
function
()
{
test
(
"val() after modification"
,
function
()
{
expect
(
21
+
(
jQuery
.
fn
.
serialize
?
6
:
0
)
);
expect
(
1
);
var
checks
,
$button
;
document
.
getElementById
(
"text1"
).
value
=
"bla"
;
document
.
getElementById
(
"text1"
).
value
=
"bla"
;
equal
(
jQuery
(
"#text1"
).
val
(),
"bla"
,
"Check for modified value of input element"
);
equal
(
jQuery
(
"#text1"
).
val
(),
"bla"
,
"Check for modified value of input element"
);
QUnit
.
reset
(
);
}
);
test
(
"val()"
,
function
()
{
expect
(
20
+
(
jQuery
.
fn
.
serialize
?
6
:
0
)
);
var
checks
,
$button
;
equal
(
jQuery
(
"#text1"
).
val
(),
"Test"
,
"Check for value of input element"
);
equal
(
jQuery
(
"#text1"
).
val
(),
"Test"
,
"Check for value of input element"
);
// ticket #1714 this caused a JS error in IE
// ticket #1714 this caused a JS error in IE
equal
(
jQuery
(
"#first"
).
val
(),
""
,
"Check a paragraph element to see if it has a value"
);
equal
(
jQuery
(
"#first"
).
val
(),
""
,
"Check a paragraph element to see if it has a value"
);
...
@@ -923,7 +930,6 @@ if ( "value" in document.createElement("meter") &&
...
@@ -923,7 +930,6 @@ if ( "value" in document.createElement("meter") &&
var
testVal
=
function
(
valueObj
)
{
var
testVal
=
function
(
valueObj
)
{
expect
(
8
);
expect
(
8
);
QUnit
.
reset
();
jQuery
(
"#text1"
).
val
(
valueObj
(
"test"
)
);
jQuery
(
"#text1"
).
val
(
valueObj
(
"test"
)
);
equal
(
document
.
getElementById
(
"text1"
).
value
,
"test"
,
"Check for modified (via val(String)) value of input element"
);
equal
(
document
.
getElementById
(
"text1"
).
value
,
"test"
,
"Check for modified (via val(String)) value of input element"
);
...
@@ -978,7 +984,6 @@ test( "val(Array of Numbers) (Bug #7123)", function() {
...
@@ -978,7 +984,6 @@ test( "val(Array of Numbers) (Bug #7123)", function() {
test
(
"val(Function) with incoming value"
,
function
()
{
test
(
"val(Function) with incoming value"
,
function
()
{
expect
(
10
);
expect
(
10
);
QUnit
.
reset
();
var
oldVal
=
jQuery
(
"#text1"
).
val
();
var
oldVal
=
jQuery
(
"#text1"
).
val
();
jQuery
(
"#text1"
).
val
(
function
(
i
,
val
)
{
jQuery
(
"#text1"
).
val
(
function
(
i
,
val
)
{
...
...
test/unit/core.js
View file @
305eefe6
...
@@ -592,7 +592,6 @@ test("jQuery('html')", function() {
...
@@ -592,7 +592,6 @@ test("jQuery('html')", function() {
var
s
,
div
,
j
;
var
s
,
div
,
j
;
QUnit
.
reset
();
jQuery
[
"foo"
]
=
false
;
jQuery
[
"foo"
]
=
false
;
s
=
jQuery
(
"<script>jQuery.foo='test';</script>"
)[
0
];
s
=
jQuery
(
"<script>jQuery.foo='test';</script>"
)[
0
];
ok
(
s
,
"Creating a script"
);
ok
(
s
,
"Creating a script"
);
...
@@ -608,7 +607,6 @@ test("jQuery('html')", function() {
...
@@ -608,7 +607,6 @@ test("jQuery('html')", function() {
equal
(
div
.
childNodes
[
1
].
nodeType
,
1
,
"Paragraph."
);
equal
(
div
.
childNodes
[
1
].
nodeType
,
1
,
"Paragraph."
);
equal
(
div
.
childNodes
[
1
].
firstChild
.
nodeType
,
3
,
"Paragraph text."
);
equal
(
div
.
childNodes
[
1
].
firstChild
.
nodeType
,
3
,
"Paragraph text."
);
QUnit
.
reset
();
ok
(
jQuery
(
"<link rel='stylesheet'/>"
)[
0
],
"Creating a link"
);
ok
(
jQuery
(
"<link rel='stylesheet'/>"
)[
0
],
"Creating a link"
);
ok
(
!
jQuery
(
"<script/>"
)[
0
].
parentNode
,
"Create a script"
);
ok
(
!
jQuery
(
"<script/>"
)[
0
].
parentNode
,
"Create a script"
);
...
...
test/unit/css.js
View file @
305eefe6
...
@@ -431,9 +431,9 @@ test("css(Object) where values are Functions with incoming values", function() {
...
@@ -431,9 +431,9 @@ test("css(Object) where values are Functions with incoming values", function() {
});
});
test
(
"show(); hide()"
,
function
()
{
test
(
"show(); hide()"
,
function
()
{
expect
(
22
);
expect
(
4
);
var
hiddendiv
,
div
,
pass
,
old
,
test
;
var
hiddendiv
,
div
;
hiddendiv
=
jQuery
(
"div.hidden"
);
hiddendiv
=
jQuery
(
"div.hidden"
);
hiddendiv
.
hide
();
hiddendiv
.
hide
();
...
@@ -446,8 +446,13 @@ test("show(); hide()", function() {
...
@@ -446,8 +446,13 @@ test("show(); hide()", function() {
div
.
appendTo
(
"#qunit-fixture"
).
show
();
div
.
appendTo
(
"#qunit-fixture"
).
show
();
equal
(
div
.
css
(
"display"
),
"block"
,
"Pre-hidden div shown"
);
equal
(
div
.
css
(
"display"
),
"block"
,
"Pre-hidden div shown"
);
QUnit
.
reset
();
});
test
(
"show();"
,
function
()
{
expect
(
18
);
var
hiddendiv
,
div
,
pass
,
old
,
test
;
hiddendiv
=
jQuery
(
"div.hidden"
);
hiddendiv
=
jQuery
(
"div.hidden"
);
equal
(
jQuery
.
css
(
hiddendiv
[
0
],
"display"
),
"none"
,
"hiddendiv is display: none"
);
equal
(
jQuery
.
css
(
hiddendiv
[
0
],
"display"
),
"none"
,
"hiddendiv is display: none"
);
...
@@ -666,7 +671,6 @@ test("toggle()", function() {
...
@@ -666,7 +671,6 @@ test("toggle()", function() {
test
(
"hide hidden elements (bug #7141)"
,
function
()
{
test
(
"hide hidden elements (bug #7141)"
,
function
()
{
expect
(
3
);
expect
(
3
);
QUnit
.
reset
();
var
div
=
jQuery
(
"<div style='display:none'></div>"
).
appendTo
(
"#qunit-fixture"
);
var
div
=
jQuery
(
"<div style='display:none'></div>"
).
appendTo
(
"#qunit-fixture"
);
equal
(
div
.
css
(
"display"
),
"none"
,
"Element is hidden by default"
);
equal
(
div
.
css
(
"display"
),
"none"
,
"Element is hidden by default"
);
...
...
test/unit/effects.js
View file @
305eefe6
...
@@ -124,7 +124,7 @@ test("show()", 27, function () {
...
@@ -124,7 +124,7 @@ test("show()", 27, function () {
test
(
"show(Number) - other displays"
,
function
()
{
test
(
"show(Number) - other displays"
,
function
()
{
expect
(
15
);
expect
(
15
);
QUnit
.
reset
();
stop
();
stop
();
// #show-tests * is set display: none in CSS
// #show-tests * is set display: none in CSS
...
@@ -171,7 +171,7 @@ test("show(Number) - other displays", function() {
...
@@ -171,7 +171,7 @@ test("show(Number) - other displays", function() {
// Supports #7397
// Supports #7397
test
(
"Persist correct display value"
,
function
()
{
test
(
"Persist correct display value"
,
function
()
{
expect
(
3
);
expect
(
3
);
QUnit
.
reset
();
stop
();
stop
();
// #show-tests * is set display: none in CSS
// #show-tests * is set display: none in CSS
...
@@ -1310,7 +1310,7 @@ test("animate with CSS shorthand properties", function(){
...
@@ -1310,7 +1310,7 @@ test("animate with CSS shorthand properties", function(){
test
(
"hide hidden elements, with animation (bug #7141)"
,
function
()
{
test
(
"hide hidden elements, with animation (bug #7141)"
,
function
()
{
expect
(
3
);
expect
(
3
);
QUnit
.
reset
();
stop
();
stop
();
var
div
=
jQuery
(
"<div style='display:none'></div>"
).
appendTo
(
"#qunit-fixture"
);
var
div
=
jQuery
(
"<div style='display:none'></div>"
).
appendTo
(
"#qunit-fixture"
);
...
...
test/unit/manipulation.js
View file @
305eefe6
This diff is collapsed.
Click to expand it.
test/unit/wrap.js
View file @
305eefe6
...
@@ -31,12 +31,10 @@ function testWrap( val ) {
...
@@ -31,12 +31,10 @@ function testWrap( val ) {
equal
(
defaultText
,
result
,
"Check for wrapping of on-the-fly html"
);
equal
(
defaultText
,
result
,
"Check for wrapping of on-the-fly html"
);
ok
(
jQuery
(
"#first"
).
parent
().
parent
().
is
(
".red"
),
"Check if wrapper has class 'red'"
);
ok
(
jQuery
(
"#first"
).
parent
().
parent
().
is
(
".red"
),
"Check if wrapper has class 'red'"
);
QUnit
.
reset
();
result
=
jQuery
(
"#first"
).
wrap
(
val
(
document
.
getElementById
(
"empty"
))
).
parent
();
result
=
jQuery
(
"#first"
).
wrap
(
val
(
document
.
getElementById
(
"empty"
))
).
parent
();
ok
(
result
.
is
(
"ol"
),
"Check for element wrapping"
);
ok
(
result
.
is
(
"ol"
),
"Check for element wrapping"
);
equal
(
result
.
text
(),
defaultText
,
"Check for element wrapping"
);
equal
(
result
.
text
(),
defaultText
,
"Check for element wrapping"
);
QUnit
.
reset
();
jQuery
(
"#check1"
).
on
(
"click"
,
function
()
{
jQuery
(
"#check1"
).
on
(
"click"
,
function
()
{
var
checkbox
=
this
;
var
checkbox
=
this
;
...
@@ -97,8 +95,6 @@ function testWrap( val ) {
...
@@ -97,8 +95,6 @@ function testWrap( val ) {
j
.
parent
().
trigger
(
"click"
);
j
.
parent
().
trigger
(
"click"
);
// clean up attached elements
QUnit
.
reset
();
}
}
test
(
"wrap(String|Element)"
,
function
()
{
test
(
"wrap(String|Element)"
,
function
()
{
...
@@ -136,15 +132,15 @@ test( "wrap(String) consecutive elements (#10177)", function() {
...
@@ -136,15 +132,15 @@ test( "wrap(String) consecutive elements (#10177)", function() {
});
});
});
});
function
testWrapAll
(
val
)
{
test
(
"wrapAll(String)"
,
function
(
)
{
expect
(
8
);
expect
(
5
);
var
prev
,
p
,
result
;
var
prev
,
p
,
result
;
prev
=
jQuery
(
"#firstp"
)[
0
].
previousSibling
;
prev
=
jQuery
(
"#firstp"
)[
0
].
previousSibling
;
p
=
jQuery
(
"#firstp,#first"
)[
0
].
parentNode
;
p
=
jQuery
(
"#firstp,#first"
)[
0
].
parentNode
;
result
=
jQuery
(
"#firstp,#first"
).
wrapAll
(
val
(
"<div class='red'><div class='tmp'></div></div>"
)
);
result
=
jQuery
(
"#firstp,#first"
).
wrapAll
(
"<div class='red'><div class='tmp'></div></div>"
);
equal
(
result
.
parent
().
length
,
1
,
"Check for wrapping of on-the-fly html"
);
equal
(
result
.
parent
().
length
,
1
,
"Check for wrapping of on-the-fly html"
);
ok
(
jQuery
(
"#first"
).
parent
().
parent
().
is
(
".red"
),
"Check if wrapper has class 'red'"
);
ok
(
jQuery
(
"#first"
).
parent
().
parent
().
is
(
".red"
),
"Check if wrapper has class 'red'"
);
...
@@ -152,25 +148,67 @@ function testWrapAll( val ) {
...
@@ -152,25 +148,67 @@ function testWrapAll( val ) {
equal
(
jQuery
(
"#first"
).
parent
().
parent
()[
0
].
previousSibling
,
prev
,
"Correct Previous Sibling"
);
equal
(
jQuery
(
"#first"
).
parent
().
parent
()[
0
].
previousSibling
,
prev
,
"Correct Previous Sibling"
);
equal
(
jQuery
(
"#first"
).
parent
().
parent
()[
0
].
parentNode
,
p
,
"Correct Parent"
);
equal
(
jQuery
(
"#first"
).
parent
().
parent
()[
0
].
parentNode
,
p
,
"Correct Parent"
);
QUnit
.
reset
();
});
test
(
"wrapAll(Element)"
,
function
()
{
expect
(
3
);
var
prev
,
p
;
prev
=
jQuery
(
"#firstp"
)[
0
].
previousSibling
;
prev
=
jQuery
(
"#firstp"
)[
0
].
previousSibling
;
p
=
jQuery
(
"#first"
)[
0
].
parentNode
;
p
=
jQuery
(
"#first"
)[
0
].
parentNode
;
jQuery
(
"#firstp,#first"
).
wrapAll
(
val
(
document
.
getElementById
(
"empty"
)
)
);
jQuery
(
"#firstp,#first"
).
wrapAll
(
document
.
getElementById
(
"empty"
)
);
equal
(
jQuery
(
"#first"
).
parent
()[
0
],
jQuery
(
"#firstp"
).
parent
()[
0
],
"Same Parent"
);
equal
(
jQuery
(
"#first"
).
parent
()[
0
],
jQuery
(
"#firstp"
).
parent
()[
0
],
"Same Parent"
);
equal
(
jQuery
(
"#first"
).
parent
()[
0
].
previousSibling
,
prev
,
"Correct Previous Sibling"
);
equal
(
jQuery
(
"#first"
).
parent
()[
0
].
previousSibling
,
prev
,
"Correct Previous Sibling"
);
equal
(
jQuery
(
"#first"
).
parent
()[
0
].
parentNode
,
p
,
"Correct Parent"
);
equal
(
jQuery
(
"#first"
).
parent
()[
0
].
parentNode
,
p
,
"Correct Parent"
);
}
});
test
(
"wrapInner(String)"
,
function
()
{
expect
(
6
);
var
num
;
num
=
jQuery
(
"#first"
).
children
().
length
;
jQuery
(
"#first"
).
wrapInner
(
"<div class='red'><div id='tmp'></div></div>"
);
equal
(
jQuery
(
"#first"
).
children
().
length
,
1
,
"Only one child"
);
ok
(
jQuery
(
"#first"
).
children
().
is
(
".red"
),
"Verify Right Element"
);
equal
(
jQuery
(
"#first"
).
children
().
children
().
children
().
length
,
num
,
"Verify Elements Intact"
);
test
(
"wrapAll(String|Element)"
,
function
()
{
num
=
jQuery
(
"#first"
).
html
(
"foo<div>test</div><div>test2</div>"
).
children
().
length
;
testWrapAll
(
manipulationBareObj
);
jQuery
(
"#first"
).
wrapInner
(
"<div class='red'><div id='tmp'></div></div>"
);
equal
(
jQuery
(
"#first"
).
children
().
length
,
1
,
"Only one child"
);
ok
(
jQuery
(
"#first"
).
children
().
is
(
".red"
),
"Verify Right Element"
);
equal
(
jQuery
(
"#first"
).
children
().
children
().
children
().
length
,
num
,
"Verify Elements Intact"
);
});
});
function
testWrapInner
(
val
)
{
test
(
"wrapInner(Element)"
,
function
(
)
{
expect
(
11
);
expect
(
5
);
var
num
,
div
;
var
num
,
div
=
jQuery
(
"<div/>"
);
num
=
jQuery
(
"#first"
).
children
().
length
;
jQuery
(
"#first"
).
wrapInner
(
document
.
getElementById
(
"empty"
)
);
equal
(
jQuery
(
"#first"
).
children
().
length
,
1
,
"Only one child"
);
ok
(
jQuery
(
"#first"
).
children
().
is
(
"#empty"
),
"Verify Right Element"
);
equal
(
jQuery
(
"#first"
).
children
().
children
().
length
,
num
,
"Verify Elements Intact"
);
div
.
wrapInner
(
"<span></span>"
);
equal
(
div
.
children
().
length
,
1
,
"The contents were wrapped."
);
equal
(
div
.
children
()[
0
].
nodeName
.
toLowerCase
(),
"span"
,
"A span was inserted."
);
});
test
(
"wrapInner(Function) returns String"
,
function
()
{
expect
(
6
);
var
num
,
val
=
manipulationFunctionReturningObj
;
num
=
jQuery
(
"#first"
).
children
().
length
;
num
=
jQuery
(
"#first"
).
children
().
length
;
jQuery
(
"#first"
).
wrapInner
(
val
(
"<div class='red'><div id='tmp'></div></div>"
)
);
jQuery
(
"#first"
).
wrapInner
(
val
(
"<div class='red'><div id='tmp'></div></div>"
)
);
...
@@ -179,32 +217,30 @@ function testWrapInner( val ) {
...
@@ -179,32 +217,30 @@ function testWrapInner( val ) {
ok
(
jQuery
(
"#first"
).
children
().
is
(
".red"
),
"Verify Right Element"
);
ok
(
jQuery
(
"#first"
).
children
().
is
(
".red"
),
"Verify Right Element"
);
equal
(
jQuery
(
"#first"
).
children
().
children
().
children
().
length
,
num
,
"Verify Elements Intact"
);
equal
(
jQuery
(
"#first"
).
children
().
children
().
children
().
length
,
num
,
"Verify Elements Intact"
);
QUnit
.
reset
();
num
=
jQuery
(
"#first"
).
html
(
"foo<div>test</div><div>test2</div>"
).
children
().
length
;
num
=
jQuery
(
"#first"
).
html
(
"foo<div>test</div><div>test2</div>"
).
children
().
length
;
jQuery
(
"#first"
).
wrapInner
(
val
(
"<div class='red'><div id='tmp'></div></div>"
)
);
jQuery
(
"#first"
).
wrapInner
(
val
(
"<div class='red'><div id='tmp'></div></div>"
)
);
equal
(
jQuery
(
"#first"
).
children
().
length
,
1
,
"Only one child"
);
equal
(
jQuery
(
"#first"
).
children
().
length
,
1
,
"Only one child"
);
ok
(
jQuery
(
"#first"
).
children
().
is
(
".red"
),
"Verify Right Element"
);
ok
(
jQuery
(
"#first"
).
children
().
is
(
".red"
),
"Verify Right Element"
);
equal
(
jQuery
(
"#first"
).
children
().
children
().
children
().
length
,
num
,
"Verify Elements Intact"
);
equal
(
jQuery
(
"#first"
).
children
().
children
().
children
().
length
,
num
,
"Verify Elements Intact"
);
});
test
(
"wrapInner(Function) returns Element"
,
function
()
{
expect
(
5
);
var
num
,
val
=
manipulationFunctionReturningObj
,
div
=
jQuery
(
"<div/>"
);
QUnit
.
reset
();
num
=
jQuery
(
"#first"
).
children
().
length
;
num
=
jQuery
(
"#first"
).
children
().
length
;
jQuery
(
"#first"
).
wrapInner
(
val
(
document
.
getElementById
(
"empty"
))
);
jQuery
(
"#first"
).
wrapInner
(
val
(
document
.
getElementById
(
"empty"
))
);
equal
(
jQuery
(
"#first"
).
children
().
length
,
1
,
"Only one child"
);
equal
(
jQuery
(
"#first"
).
children
().
length
,
1
,
"Only one child"
);
ok
(
jQuery
(
"#first"
).
children
().
is
(
"#empty"
),
"Verify Right Element"
);
ok
(
jQuery
(
"#first"
).
children
().
is
(
"#empty"
),
"Verify Right Element"
);
equal
(
jQuery
(
"#first"
).
children
().
children
().
length
,
num
,
"Verify Elements Intact"
);
equal
(
jQuery
(
"#first"
).
children
().
children
().
length
,
num
,
"Verify Elements Intact"
);
div
=
jQuery
(
"<div/>"
);
div
.
wrapInner
(
val
(
"<span></span>"
)
);
div
.
wrapInner
(
val
(
"<span></span>"
)
);
equal
(
div
.
children
().
length
,
1
,
"The contents were wrapped."
);
equal
(
div
.
children
().
length
,
1
,
"The contents were wrapped."
);
equal
(
div
.
children
()[
0
].
nodeName
.
toLowerCase
(),
"span"
,
"A span was inserted."
);
equal
(
div
.
children
()[
0
].
nodeName
.
toLowerCase
(),
"span"
,
"A span was inserted."
);
}
test
(
"wrapInner(String|Element)"
,
function
()
{
testWrapInner
(
manipulationBareObj
);
});
test
(
"wrapInner(Function)"
,
function
()
{
testWrapInner
(
manipulationFunctionReturningObj
);
});
});
test
(
"unwrap()"
,
function
()
{
test
(
"unwrap()"
,
function
()
{
...
...
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