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 @@
jQuery
.
getScript
(
url
(
"data/test.js"
),
function
(
data
,
_
,
jqXHR
)
{
equal
(
foobar
,
"bar"
,
"Check if script was evaluated"
);
strictEqual
(
data
,
jqXHR
.
responseText
,
"Same-domain script requests returns the source of the script (#8082)"
);
setTimeout
(
function
()
{
start
();
},
1000
);
start
();
});
});
...
...
@@ -2221,7 +2219,7 @@
test
(
"jQuery.ajaxSetup({timeout: Number}) - with global timeout"
,
function
()
{
var
passed
=
0
;
expect
(
1
);
expect
(
2
);
stop
();
...
...
@@ -2230,9 +2228,8 @@
});
var
pass
=
function
()
{
passed
++
;
ok
(
passed
++
<
2
,
"Error callback executed"
)
;
if
(
passed
==
2
)
{
ok
(
true
,
"Check local and global callbacks after timeout"
);
jQuery
(
"#qunit-fixture"
).
unbind
(
"ajaxError"
);
start
();
}
...
...
test/unit/effects.js
View file @
517846aa
...
...
@@ -695,14 +695,13 @@ test("stop(clearQueue, gotoEnd)", function() {
asyncTest
(
"stop( queue, ..., ... ) - Stop single queues"
,
function
()
{
expect
(
3
);
var
foo
=
jQuery
(
"#foo"
)
,
saved
;
var
saved
,
foo
=
jQuery
(
"#foo"
).
css
({
width
:
200
,
height
:
200
})
;
foo
.
css
(
"width"
,
200
).
css
(
"height"
,
200
);
foo
.
animate
({
width
:
400
},{
duration
:
10
00
,
duration
:
5
00
,
complete
:
function
()
{
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"
);
...
...
@@ -715,7 +714,7 @@ asyncTest( "stop( queue, ..., ... ) - Stop single queues", function() {
},{
duration
:
1000
,
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"
);
...
...
@@ -745,16 +744,6 @@ test("toggle()", function() {
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
()
{
var
div
=
jQuery
(
"<div></div>"
).
appendTo
(
"#qunit-fixture"
).
css
({
color
:
"#ABC"
,
...
...
@@ -809,29 +798,31 @@ test( "jQuery.fx.prototype.cur() - <1.8 Back Compat", 7, function() {
jQuery
(
div
).
remove
();
});
test
(
"
JS
Overflow and Display"
,
function
()
{
expect
(
2
);
test
(
"Overflow and Display"
,
function
()
{
expect
(
4
);
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
()
{
expect
(
2
);
stop
();
jQuery
.
makeTest
(
"CSS Overflow and Display"
)
.
addClass
(
"overflow inline"
)
var
testClass
=
jQuery
.
makeTest
(
"Overflow and Display"
)
.
addClass
(
"overflow inline"
),
testStyle
=
jQuery
.
makeTest
(
"Overflow and Display (inline style)"
)
.
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"
)
.
text
(
"Some sample text."
)
.
before
(
"text before"
)
.
after
(
"text after"
)
.
animate
({
opacity
:
0.5
},
"slow"
,
jQuery
.
checkOverflowDisplay
);
.
animate
({
opacity
:
0.5
},
"slow"
,
done
);
});
jQuery
.
each
({
...
...
@@ -1126,57 +1117,63 @@ test("jQuery.show('fast') doesn't clear radio buttons (bug #1095)", function ()
});
});
jQuery
.
expandedEach
=
jQuery
.
each
;
jQuery
.
expandedEach
({
"slideToggle"
:
function
(
$elem
)
{
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
);
test
(
"interrupt toggle"
,
function
()
{
expect
(
24
);
stop
();
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
)
{
var
$elem
=
jQuery
(
"#"
+
method
.
toLowerCase
()
+
type
),
startVal
=
defProp
(
$elem
);
jQuery
.
each
(
{
slideToggle
:
"height"
,
fadeToggle
:
"opacity"
,
toggle
:
"width"
},
function
(
method
,
prop
)
{
var
$methodElems
=
$elems
.
filter
(
"[id^='"
+
method
.
toLowerCase
()
+
"']"
).
each
(
function
()
{
// Don't end test until we're done with this element
remaining
++
;
$elem
[
method
](
animTime
);
stop
(
);
// Save original property value for comparison
jQuery
.
data
(
this
,
"startVal"
,
jQuery
(
this
).
css
(
prop
)
);
setTimeout
(
function
()
{
$elem
.
stop
();
// Expect olddisplay data from our .hide() call below
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
()
{
equal
(
defProp
(
$elem
),
startVal
,
"After doing .stop() halfway through hide, check that state has been saved for returning to original property value."
);
// Restore
$methodElems
[
method
](
shortDuration
,
function
()
{
var
id
=
this
.
id
,
$elem
=
jQuery
(
this
),
startVal
=
$elem
.
data
(
"startVal"
);
// Start from hidden position to show this time
$elem
.
hide
()[
method
](
animTime
);
setTimeout
(
function
()
{
$elem
.
stop
();
$elem
.
removeData
(
"startVal"
);
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
()
{
equal
(
defProp
(
$elem
),
startVal
,
"After doing .stop() halfway through show, check that state has been saved for returning to original property value."
);
// Interrupt a showing toggle
$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
QUnit
.
expectJqData
(
this
,
"olddisplay"
);
start
(
);
}
);
}
,
animTime
/
2
);
});
}
,
animTime
/
2
);
});
// Restore
$elem
[
method
](
shortDuration
,
function
()
{
equal
(
$elem
.
css
(
prop
),
startVal
,
"original value restored by ."
+
method
+
"() - #"
+
id
);
finish
(
);
});
}
,
shortDuration
);
});
}
,
shortDuration
);
});
});
...
...
@@ -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"
);
div
.
stop
().
remove
();
start
();
},
10
00
);
},
5
00
);
});
test
(
"callbacks should fire in correct order (#9100)"
,
function
()
{
...
...
@@ -1663,7 +1660,7 @@ asyncTest( "multiple unqueued and promise", 4, function() {
}).
animate
({
top
:
100
},
{
duration
:
1
5
00
,
duration
:
1
0
00
,
queue
:
false
,
complete
:
function
()
{
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 ) {
expect
(
3
);
stop
();
var
foo
=
jQuery
({}),
run
=
0
;
foo
var
done
=
{};
jQuery
({})
.
queue
(
"alternate"
,
function
(
next
)
{
run
++
;
done
.
alt1
=
true
;
ok
(
true
,
"This first function was dequeued"
);
next
();
})
.
delay
(
1000
,
"alternate"
)
.
queue
(
"alternate"
,
function
()
{
run
++
;
done
.
alt2
=
true
;
ok
(
true
,
"The function was dequeued immediately, the delay was stopped"
);
})
.
dequeue
(
"alternate"
)
...
...
@@ -278,18 +277,20 @@ if ( jQuery.fn.stop ) {
.
stop
(
"alternate"
,
false
,
false
)
// this test
.
delay
(
1
000
)
.
delay
(
1
)
.
queue
(
function
()
{
run
++
;
done
.
default1
=
true
;
ok
(
false
,
"This queue should never run"
);
})
// stop( clearQueue ) should clear the queue
.
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
()
{
...
...
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