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
d31cef38
Commit
d31cef38
authored
Nov 26, 2012
by
jaubourg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Total revamping of the ajax unit tests
parent
53a06660
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
1523 additions
and
2314 deletions
+1523
-2314
.jshintrc
test/.jshintrc
+2
-0
testinit.js
test/data/testinit.js
+71
-0
testrunner.js
test/data/testrunner.js
+29
-1
ajax.js
test/unit/ajax.js
+1421
-2313
No files found.
test/.jshintrc
View file @
d31cef38
...
@@ -38,6 +38,7 @@
...
@@ -38,6 +38,7 @@
"stop": true,
"stop": true,
"expect": true,
"expect": true,
"raises": true,
"raises": true,
"ajaxTest": true,
"testIframe": true,
"testIframe": true,
"testIframeWithCallback": true,
"testIframeWithCallback": true,
"createDashboardXML": true,
"createDashboardXML": true,
...
@@ -50,6 +51,7 @@
...
@@ -50,6 +51,7 @@
"q": true,
"q": true,
"amdDefined": true,
"amdDefined": true,
"fireNative": true,
"fireNative": true,
"Globals": true,
"hasPHP": true,
"hasPHP": true,
"isLocal": true,
"isLocal": true,
"originaljQuery": true,
"originaljQuery": true,
...
...
test/data/testinit.js
View file @
d31cef38
...
@@ -143,6 +143,77 @@ function url( value ) {
...
@@ -143,6 +143,77 @@ function url( value ) {
return
value
+
(
/
\?
/
.
test
(
value
)
?
"&"
:
"?"
)
+
new
Date
().
getTime
()
+
""
+
parseInt
(
Math
.
random
()
*
100000
,
10
);
return
value
+
(
/
\?
/
.
test
(
value
)
?
"&"
:
"?"
)
+
new
Date
().
getTime
()
+
""
+
parseInt
(
Math
.
random
()
*
100000
,
10
);
}
}
// Ajax testing helper
var
ajaxTest
=
(
function
()
{
var
resolved
=
$
.
Deferred
().
resolve
();
function
getRequests
(
options
)
{
var
requests
=
options
.
requests
||
options
.
request
||
options
||
[];
if
(
!
jQuery
.
isArray
(
requests
)
)
{
requests
=
[
requests
];
}
return
requests
;
}
return
function
(
title
,
expect
,
options
)
{
if
(
jQuery
.
isFunction
(
options
)
)
{
options
=
options
();
}
options
=
options
||
[];
asyncTest
(
title
,
expect
,
function
()
{
setTimeout
(
function
()
{
if
(
options
.
setup
)
{
options
.
setup
();
}
var
ajaxSettings
=
jQuery
.
ajaxSetup
(
{},
{}
);
aborted
=
false
,
abort
=
function
(
reason
)
{
if
(
!
aborted
)
{
aborted
=
true
;
ok
(
false
,
"unexpected "
+
reason
);
jQuery
.
each
(
requests
,
function
(
_
,
request
)
{
request
.
abort
();
});
}
},
requestOptions
=
getRequests
(
options
),
requests
=
jQuery
.
map
(
requestOptions
,
function
(
options
)
{
var
request
=
(
options
.
create
||
jQuery
.
ajax
)(
options
);
if
(
options
.
afterSend
)
{
options
.
afterSend
(
request
);
}
return
request
;
});
requests
=
jQuery
.
map
(
requests
,
function
(
request
,
index
)
{
function
callIfDefined
(
type
,
type2
)
{
var
handler
=
requestOptions
[
index
][
type
]
||
!!
requestOptions
[
index
][
type2
];
return
handler
?
function
()
{
if
(
!
aborted
&&
jQuery
.
isFunction
(
handler
)
)
{
handler
.
apply
(
this
,
arguments
);
}
return
resolved
;
}
:
function
()
{
abort
(
type
);
return
resolved
;
}
}
var
promise
=
request
.
then
(
callIfDefined
(
"done"
,
"success"
),
callIfDefined
(
"fail"
,
"error"
)
);
promise
.
abort
=
request
.
abort
;
return
promise
;
});
jQuery
.
when
.
apply
(
jQuery
,
requests
).
done
(
options
.
teardown
,
function
()
{
jQuery
.
ajaxSetup
(
ajaxSettings
);
setTimeout
(
start
,
0
);
}
);
},
0
);
});
};
})();
(
function
()
{
(
function
()
{
this
.
testIframe
=
function
(
fileName
,
name
,
fn
)
{
this
.
testIframe
=
function
(
fileName
,
name
,
fn
)
{
...
...
test/data/testrunner.js
View file @
d31cef38
...
@@ -134,6 +134,31 @@ function testSubproject( label, url, risTests ) {
...
@@ -134,6 +134,31 @@ function testSubproject( label, url, risTests ) {
}
}
}
}
// Register globals for cleanup and the cleanup code itself
// Explanation at http://perfectionkills.com/understanding-delete/#ie_bugs
var
Globals
=
(
function
()
{
var
globals
=
{};
return
QUnit
.
config
.
noglobals
?
{
register
:
function
(
name
)
{
globals
[
name
]
=
true
;
jQuery
.
globalEval
(
"var "
+
name
);
},
cleanup
:
function
()
{
var
name
,
current
=
globals
;
globals
=
{};
for
(
name
in
current
)
{
jQuery
.
globalEval
(
"try { "
+
"delete "
+
(
jQuery
.
support
.
deleteExpando
?
"window['"
+
name
+
"']"
:
name
)
+
"; } catch( x ) {}"
);
}
}
}
:
{
register
:
jQuery
.
noop
,
cleanup
:
jQuery
.
noop
};
})();
/**
/**
* QUnit hooks
* QUnit hooks
*/
*/
...
@@ -292,10 +317,13 @@ function testSubproject( label, url, risTests ) {
...
@@ -292,10 +317,13 @@ function testSubproject( label, url, risTests ) {
// Reset internal jQuery state
// Reset internal jQuery state
jQuery
.
event
.
global
=
{};
jQuery
.
event
.
global
=
{};
if
(
ajaxSettings
)
{
if
(
ajaxSettings
)
{
jQuery
.
ajaxSettings
=
jQuery
.
extend
(
{},
ajaxSettings
);
jQuery
.
ajaxSettings
=
jQuery
.
extend
(
true
,
{},
ajaxSettings
);
}
else
{
}
else
{
delete
jQuery
.
ajaxSettings
;
delete
jQuery
.
ajaxSettings
;
}
}
// Cleanup globals
Globals
.
cleanup
();
// Let QUnit reset the fixture
// Let QUnit reset the fixture
reset
.
apply
(
this
,
arguments
);
reset
.
apply
(
this
,
arguments
);
...
...
test/unit/ajax.js
View file @
d31cef38
This source diff could not be displayed because it is too large. You can
view the blob
instead.
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