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
517846aa
Commit
517846aa
authored
Nov 08, 2012
by
Richard Gibson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
No ticket: speedup test suite. Close gh-1020.
parent
87730673
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
223 additions
and
264 deletions
+223
-264
ajax.js
test/unit/ajax.js
+3
-6
effects.js
test/unit/effects.js
+72
-75
manipulation.js
test/unit/manipulation.js
+138
-174
queue.js
test/unit/queue.js
+10
-9
No files found.
test/unit/ajax.js
View file @
517846aa
...
@@ -1481,9 +1481,7 @@
...
@@ -1481,9 +1481,7 @@
jQuery
.
getScript
(
url
(
"data/test.js"
),
function
(
data
,
_
,
jqXHR
)
{
jQuery
.
getScript
(
url
(
"data/test.js"
),
function
(
data
,
_
,
jqXHR
)
{
equal
(
foobar
,
"bar"
,
"Check if script was evaluated"
);
equal
(
foobar
,
"bar"
,
"Check if script was evaluated"
);
strictEqual
(
data
,
jqXHR
.
responseText
,
"Same-domain script requests returns the source of the script (#8082)"
);
strictEqual
(
data
,
jqXHR
.
responseText
,
"Same-domain script requests returns the source of the script (#8082)"
);
setTimeout
(
function
()
{
start
();
start
();
},
1000
);
});
});
});
});
...
@@ -2221,7 +2219,7 @@
...
@@ -2221,7 +2219,7 @@
test
(
"jQuery.ajaxSetup({timeout: Number}) - with global timeout"
,
function
()
{
test
(
"jQuery.ajaxSetup({timeout: Number}) - with global timeout"
,
function
()
{
var
passed
=
0
;
var
passed
=
0
;
expect
(
1
);
expect
(
2
);
stop
();
stop
();
...
@@ -2230,9 +2228,8 @@
...
@@ -2230,9 +2228,8 @@
});
});
var
pass
=
function
()
{
var
pass
=
function
()
{
passed
++
;
ok
(
passed
++
<
2
,
"Error callback executed"
)
;
if
(
passed
==
2
)
{
if
(
passed
==
2
)
{
ok
(
true
,
"Check local and global callbacks after timeout"
);
jQuery
(
"#qunit-fixture"
).
unbind
(
"ajaxError"
);
jQuery
(
"#qunit-fixture"
).
unbind
(
"ajaxError"
);
start
();
start
();
}
}
...
...
test/unit/effects.js
View file @
517846aa
...
@@ -695,14 +695,13 @@ test("stop(clearQueue, gotoEnd)", function() {
...
@@ -695,14 +695,13 @@ test("stop(clearQueue, gotoEnd)", function() {
asyncTest
(
"stop( queue, ..., ... ) - Stop single queues"
,
function
()
{
asyncTest
(
"stop( queue, ..., ... ) - Stop single queues"
,
function
()
{
expect
(
3
);
expect
(
3
);
var
foo
=
jQuery
(
"#foo"
)
,
var
saved
,
saved
;
foo
=
jQuery
(
"#foo"
).
css
({
width
:
200
,
height
:
200
})
;
foo
.
css
(
"width"
,
200
).
css
(
"height"
,
200
);
foo
.
animate
({
foo
.
animate
({
width
:
400
width
:
400
},{
},{
duration
:
10
00
,
duration
:
5
00
,
complete
:
function
()
{
complete
:
function
()
{
equal
(
parseFloat
(
foo
.
css
(
"width"
)
),
400
,
"Animation completed for standard queue"
);
equal
(
parseFloat
(
foo
.
css
(
"width"
)
),
400
,
"Animation completed for standard queue"
);
equal
(
parseFloat
(
foo
.
css
(
"height"
)
),
saved
,
"Height was not changed after the second stop"
);
equal
(
parseFloat
(
foo
.
css
(
"height"
)
),
saved
,
"Height was not changed after the second stop"
);
...
@@ -715,7 +714,7 @@ asyncTest( "stop( queue, ..., ... ) - Stop single queues", function() {
...
@@ -715,7 +714,7 @@ asyncTest( "stop( queue, ..., ... ) - Stop single queues", function() {
},{
},{
duration
:
1000
,
duration
:
1000
,
queue
:
"height"
queue
:
"height"
}).
dequeue
(
"height"
).
stop
(
"height"
,
false
,
true
);
}).
dequeue
(
"height"
).
stop
(
"height"
,
false
,
true
);
equal
(
parseFloat
(
foo
.
css
(
"height"
)
),
400
,
"Height was stopped with gotoEnd"
);
equal
(
parseFloat
(
foo
.
css
(
"height"
)
),
400
,
"Height was stopped with gotoEnd"
);
...
@@ -745,16 +744,6 @@ test("toggle()", function() {
...
@@ -745,16 +744,6 @@ test("toggle()", function() {
ok
(
x
.
is
(
":visible"
),
"is visible again"
);
ok
(
x
.
is
(
":visible"
),
"is visible again"
);
});
});
jQuery
.
checkOverflowDisplay
=
function
(){
var
o
=
jQuery
.
css
(
this
,
"overflow"
);
equal
(
o
,
"visible"
,
"Overflow should be visible: "
+
o
);
equal
(
jQuery
.
css
(
this
,
"display"
),
"inline"
,
"Display shouldn't be tampered with."
);
jQuery
(
this
).
remove
();
start
();
};
test
(
"jQuery.fx.prototype.cur() - <1.8 Back Compat"
,
7
,
function
()
{
test
(
"jQuery.fx.prototype.cur() - <1.8 Back Compat"
,
7
,
function
()
{
var
div
=
jQuery
(
"<div></div>"
).
appendTo
(
"#qunit-fixture"
).
css
({
var
div
=
jQuery
(
"<div></div>"
).
appendTo
(
"#qunit-fixture"
).
css
({
color
:
"#ABC"
,
color
:
"#ABC"
,
...
@@ -809,29 +798,31 @@ test( "jQuery.fx.prototype.cur() - <1.8 Back Compat", 7, function() {
...
@@ -809,29 +798,31 @@ test( "jQuery.fx.prototype.cur() - <1.8 Back Compat", 7, function() {
jQuery
(
div
).
remove
();
jQuery
(
div
).
remove
();
});
});
test
(
"
JS
Overflow and Display"
,
function
()
{
test
(
"Overflow and Display"
,
function
()
{
expect
(
2
);
expect
(
4
);
stop
();
stop
();
jQuery
.
makeTest
(
"JS Overflow and Display"
)
.
addClass
(
"widewidth"
)
.
css
({
overflow
:
"visible"
,
display
:
"inline"
})
.
addClass
(
"widewidth"
)
.
text
(
"Some sample text."
)
.
before
(
"text before"
)
.
after
(
"text after"
)
.
animate
({
opacity
:
0.5
},
"slow"
,
jQuery
.
checkOverflowDisplay
);
});
test
(
"CSS Overflow and Display"
,
function
()
{
var
expect
(
2
);
testClass
=
jQuery
.
makeTest
(
"Overflow and Display"
)
stop
();
.
addClass
(
"overflow inline"
),
jQuery
.
makeTest
(
"CSS Overflow and Display"
)
testStyle
=
jQuery
.
makeTest
(
"Overflow and Display (inline style)"
)
.
addClass
(
"overflow inline"
)
.
css
({
overflow
:
"visible"
,
display
:
"inline"
}),
remaining
=
2
,
done
=
function
()
{
equal
(
jQuery
.
css
(
this
,
"overflow"
),
"visible"
,
"Overflow should be 'visible'"
);
equal
(
jQuery
.
css
(
this
,
"display"
),
"inline"
,
"Display should be 'inline'"
);
if
(
--
remaining
===
0
)
{
start
();
}
};
testClass
.
add
(
testStyle
)
.
addClass
(
"widewidth"
)
.
addClass
(
"widewidth"
)
.
text
(
"Some sample text."
)
.
text
(
"Some sample text."
)
.
before
(
"text before"
)
.
before
(
"text before"
)
.
after
(
"text after"
)
.
after
(
"text after"
)
.
animate
({
opacity
:
0.5
},
"slow"
,
jQuery
.
checkOverflowDisplay
);
.
animate
({
opacity
:
0.5
},
"slow"
,
done
);
});
});
jQuery
.
each
({
jQuery
.
each
({
...
@@ -1126,57 +1117,63 @@ test("jQuery.show('fast') doesn't clear radio buttons (bug #1095)", function ()
...
@@ -1126,57 +1117,63 @@ test("jQuery.show('fast') doesn't clear radio buttons (bug #1095)", function ()
});
});
});
});
jQuery
.
expandedEach
=
jQuery
.
each
;
test
(
"interrupt toggle"
,
function
()
{
jQuery
.
expandedEach
({
expect
(
24
);
"slideToggle"
:
function
(
$elem
)
{
stop
();
return
parseFloat
(
$elem
.
css
(
"height"
)
);
},
"fadeToggle"
:
function
(
$elem
)
{
return
$elem
.
css
(
"opacity"
);
},
"toggle"
:
function
(
$elem
)
{
return
parseFloat
(
$elem
.
css
(
"width"
)
);
}
},
function
(
method
,
defProp
)
{
test
(
method
+
"().stop()."
+
method
+
"()"
,
function
()
{
expect
(
8
);
var
animTime
=
2000
;
var
longDuration
=
2000
,
shortDuration
=
500
,
remaining
=
0
,
$elems
=
jQuery
(
".chain-test"
),
finish
=
function
()
{
if
(
!
(
--
remaining
)
)
{
start
();
}
};
jQuery
.
each
([
"in"
,
"out"
],
function
(
i
,
type
)
{
jQuery
.
each
(
{
slideToggle
:
"height"
,
fadeToggle
:
"opacity"
,
toggle
:
"width"
},
function
(
method
,
prop
)
{
var
$elem
=
jQuery
(
"#"
+
method
.
toLowerCase
()
+
type
),
var
$methodElems
=
$elems
.
filter
(
"[id^='"
+
method
.
toLowerCase
()
+
"']"
).
each
(
function
()
{
startVal
=
defProp
(
$elem
);
// Don't end test until we're done with this element
remaining
++
;
$elem
[
method
](
animTime
);
// Save original property value for comparison
stop
(
);
jQuery
.
data
(
this
,
"startVal"
,
jQuery
(
this
).
css
(
prop
)
);
setTimeout
(
function
()
{
// Expect olddisplay data from our .hide() call below
$elem
.
stop
();
QUnit
.
expectJqData
(
this
,
"olddisplay"
);
});
notEqual
(
defProp
(
$elem
),
startVal
,
".stop() is called about halfway through animation."
);
// Interrupt a hiding toggle
$methodElems
[
method
](
longDuration
);
setTimeout
(
function
()
{
$methodElems
.
stop
().
each
(
function
()
{
notEqual
(
jQuery
(
this
).
css
(
prop
),
jQuery
.
data
(
this
,
"startVal"
),
".stop() before completion of hiding ."
+
method
+
"() - #"
+
this
.
id
);
});
$elem
[
method
](
animTime
,
function
()
{
// Restore
equal
(
defProp
(
$elem
),
startVal
,
"After doing .stop() halfway through hide, check that state has been saved for returning to original property value."
);
$methodElems
[
method
](
shortDuration
,
function
()
{
var
id
=
this
.
id
,
$elem
=
jQuery
(
this
),
startVal
=
$elem
.
data
(
"startVal"
);
// Start from hidden position to show this time
$elem
.
removeData
(
"startVal"
);
$elem
.
hide
()[
method
](
animTime
);
setTimeout
(
function
()
{
$elem
.
stop
();
notEqual
(
defProp
(
$elem
),
startVal
,
".stop() is called about halfway through animation."
);
equal
(
$elem
.
css
(
prop
),
startVal
,
"original value restored by ."
+
method
+
"() - #"
+
id
);
$elem
[
method
](
animTime
,
function
()
{
// Interrupt a showing toggle
equal
(
defProp
(
$elem
),
startVal
,
"After doing .stop() halfway through show, check that state has been saved for returning to original property value."
);
$elem
.
hide
()[
method
](
longDuration
);
setTimeout
(
function
()
{
$elem
.
stop
();
notEqual
(
$elem
.
css
(
prop
),
startVal
,
".stop() before completion of showing ."
+
method
+
"() - #"
+
id
);
// Tolerate olddisplay data from .hide() call
// Restore
QUnit
.
expectJqData
(
this
,
"olddisplay"
);
$elem
[
method
](
shortDuration
,
function
()
{
start
(
);
equal
(
$elem
.
css
(
prop
),
startVal
,
"original value restored by ."
+
method
+
"() - #"
+
id
);
}
);
finish
(
);
}
,
animTime
/
2
);
});
});
}
,
shortDuration
);
}
,
animTime
/
2
);
});
});
}
,
shortDuration
);
});
});
});
});
...
@@ -1319,7 +1316,7 @@ test( "animate properties missing px w/ opacity as last (#9074)", 2, function()
...
@@ -1319,7 +1316,7 @@ test( "animate properties missing px w/ opacity as last (#9074)", 2, function()
notEqual
(
l
,
200
,
"Left is not 200 after partial animate"
);
notEqual
(
l
,
200
,
"Left is not 200 after partial animate"
);
div
.
stop
().
remove
();
div
.
stop
().
remove
();
start
();
start
();
},
10
00
);
},
5
00
);
});
});
test
(
"callbacks should fire in correct order (#9100)"
,
function
()
{
test
(
"callbacks should fire in correct order (#9100)"
,
function
()
{
...
@@ -1663,7 +1660,7 @@ asyncTest( "multiple unqueued and promise", 4, function() {
...
@@ -1663,7 +1660,7 @@ asyncTest( "multiple unqueued and promise", 4, function() {
}).
animate
({
}).
animate
({
top
:
100
top
:
100
},
{
},
{
duration
:
1
5
00
,
duration
:
1
0
00
,
queue
:
false
,
queue
:
false
,
complete
:
function
()
{
complete
:
function
()
{
strictEqual
(
step
++
,
3
,
"Step 3"
);
strictEqual
(
step
++
,
3
,
"Step 3"
);
...
...
test/unit/manipulation.js
View file @
517846aa
This diff is collapsed.
Click to expand it.
test/unit/queue.js
View file @
517846aa
...
@@ -259,17 +259,16 @@ if ( jQuery.fn.stop ) {
...
@@ -259,17 +259,16 @@ if ( jQuery.fn.stop ) {
expect
(
3
);
expect
(
3
);
stop
();
stop
();
var
foo
=
jQuery
({}),
run
=
0
;
var
done
=
{};
jQuery
({})
foo
.
queue
(
"alternate"
,
function
(
next
)
{
.
queue
(
"alternate"
,
function
(
next
)
{
run
++
;
done
.
alt1
=
true
;
ok
(
true
,
"This first function was dequeued"
);
ok
(
true
,
"This first function was dequeued"
);
next
();
next
();
})
})
.
delay
(
1000
,
"alternate"
)
.
delay
(
1000
,
"alternate"
)
.
queue
(
"alternate"
,
function
()
{
.
queue
(
"alternate"
,
function
()
{
run
++
;
done
.
alt2
=
true
;
ok
(
true
,
"The function was dequeued immediately, the delay was stopped"
);
ok
(
true
,
"The function was dequeued immediately, the delay was stopped"
);
})
})
.
dequeue
(
"alternate"
)
.
dequeue
(
"alternate"
)
...
@@ -278,18 +277,20 @@ if ( jQuery.fn.stop ) {
...
@@ -278,18 +277,20 @@ if ( jQuery.fn.stop ) {
.
stop
(
"alternate"
,
false
,
false
)
.
stop
(
"alternate"
,
false
,
false
)
// this test
// this test
.
delay
(
1
000
)
.
delay
(
1
)
.
queue
(
function
()
{
.
queue
(
function
()
{
run
++
;
done
.
default1
=
true
;
ok
(
false
,
"This queue should never run"
);
ok
(
false
,
"This queue should never run"
);
})
})
// stop( clearQueue ) should clear the queue
// stop( clearQueue ) should clear the queue
.
stop
(
true
,
false
);
.
stop
(
true
,
false
);
equal
(
run
,
2
,
"Queue ran the proper functions"
);
deepEqual
(
done
,
{
alt1
:
true
,
alt2
:
true
}
,
"Queue ran the proper functions"
);
setTimeout
(
start
,
2000
);
setTimeout
(
function
()
{
start
();
},
1500
);
});
});
asyncTest
(
"queue stop hooks"
,
2
,
function
()
{
asyncTest
(
"queue stop hooks"
,
2
,
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