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
b5acda7a
Commit
b5acda7a
authored
Dec 02, 2012
by
Dave Methvin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Followup to #12989 fix, improve unit test resiliency.
parent
c2d6847d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
27 deletions
+16
-27
ajax.js
test/unit/ajax.js
+16
-27
No files found.
test/unit/ajax.js
View file @
b5acda7a
...
@@ -9,7 +9,7 @@ module( "ajax", {
...
@@ -9,7 +9,7 @@ module( "ajax", {
},
},
teardown
:
function
()
{
teardown
:
function
()
{
jQuery
(
document
).
off
(
"ajaxStart ajaxStop ajaxSend ajaxComplete ajaxError ajaxSuccess"
);
jQuery
(
document
).
off
(
"ajaxStart ajaxStop ajaxSend ajaxComplete ajaxError ajaxSuccess"
);
moduleTeardown
(
);
moduleTeardown
.
apply
(
this
,
arguments
);
}
}
});
});
...
@@ -19,16 +19,19 @@ module( "ajax", {
...
@@ -19,16 +19,19 @@ module( "ajax", {
return
;
return
;
}
}
function
addGlobalEvents
()
{
function
addGlobalEvents
(
expected
)
{
return
function
()
{
expected
=
expected
||
""
;
jQuery
(
document
).
on
(
"ajaxStart ajaxStop ajaxSend ajaxComplete ajaxError ajaxSuccess"
,
function
(
e
)
{
jQuery
(
document
).
on
(
"ajaxStart ajaxStop ajaxSend ajaxComplete ajaxError ajaxSuccess"
,
function
(
e
)
{
ok
(
true
,
e
.
type
);
ok
(
expected
.
indexOf
(
e
.
type
)
!==
-
1
,
e
.
type
);
});
});
};
}
}
//----------- jQuery.ajax()
//----------- jQuery.ajax()
ajaxTest
(
"jQuery.ajax() - success callbacks"
,
8
,
{
ajaxTest
(
"jQuery.ajax() - success callbacks"
,
8
,
{
setup
:
addGlobalEvents
,
setup
:
addGlobalEvents
(
"ajaxStart ajaxStop ajaxSend ajaxComplete ajaxSuccess"
)
,
url
:
url
(
"data/name.html"
),
url
:
url
(
"data/name.html"
),
beforeSend
:
function
()
{
beforeSend
:
function
()
{
ok
(
true
,
"beforeSend"
);
ok
(
true
,
"beforeSend"
);
...
@@ -42,7 +45,7 @@ module( "ajax", {
...
@@ -42,7 +45,7 @@ module( "ajax", {
});
});
ajaxTest
(
"jQuery.ajax() - success callbacks - (url, options) syntax"
,
8
,
{
ajaxTest
(
"jQuery.ajax() - success callbacks - (url, options) syntax"
,
8
,
{
setup
:
addGlobalEvents
,
setup
:
addGlobalEvents
(
"ajaxStart ajaxStop ajaxSend ajaxComplete ajaxSuccess"
)
,
create
:
function
(
options
)
{
create
:
function
(
options
)
{
return
jQuery
.
ajax
(
url
(
"data/name.html"
),
options
);
return
jQuery
.
ajax
(
url
(
"data/name.html"
),
options
);
},
},
...
@@ -58,7 +61,7 @@ module( "ajax", {
...
@@ -58,7 +61,7 @@ module( "ajax", {
});
});
ajaxTest
(
"jQuery.ajax() - success callbacks (late binding)"
,
8
,
{
ajaxTest
(
"jQuery.ajax() - success callbacks (late binding)"
,
8
,
{
setup
:
addGlobalEvents
,
setup
:
addGlobalEvents
(
"ajaxStart ajaxStop ajaxSend ajaxComplete ajaxSuccess"
)
,
url
:
url
(
"data/name.html"
),
url
:
url
(
"data/name.html"
),
beforeSend
:
function
()
{
beforeSend
:
function
()
{
ok
(
true
,
"beforeSend"
);
ok
(
true
,
"beforeSend"
);
...
@@ -76,7 +79,7 @@ module( "ajax", {
...
@@ -76,7 +79,7 @@ module( "ajax", {
});
});
ajaxTest
(
"jQuery.ajax() - success callbacks (oncomplete binding)"
,
8
,
{
ajaxTest
(
"jQuery.ajax() - success callbacks (oncomplete binding)"
,
8
,
{
setup
:
addGlobalEvents
,
setup
:
addGlobalEvents
(
"ajaxStart ajaxStop ajaxSend ajaxComplete ajaxSuccess"
)
,
url
:
url
(
"data/name.html"
),
url
:
url
(
"data/name.html"
),
beforeSend
:
function
()
{
beforeSend
:
function
()
{
ok
(
true
,
"beforeSend"
);
ok
(
true
,
"beforeSend"
);
...
@@ -94,7 +97,7 @@ module( "ajax", {
...
@@ -94,7 +97,7 @@ module( "ajax", {
});
});
ajaxTest
(
"jQuery.ajax() - error callbacks"
,
8
,
{
ajaxTest
(
"jQuery.ajax() - error callbacks"
,
8
,
{
setup
:
addGlobalEvents
,
setup
:
addGlobalEvents
(
"ajaxStart ajaxStop ajaxSend ajaxComplete ajaxError"
)
,
url
:
url
(
"data/name.php?wait=5"
),
url
:
url
(
"data/name.php?wait=5"
),
beforeSend
:
function
()
{
beforeSend
:
function
()
{
ok
(
true
,
"beforeSend"
);
ok
(
true
,
"beforeSend"
);
...
@@ -334,7 +337,7 @@ module( "ajax", {
...
@@ -334,7 +337,7 @@ module( "ajax", {
});
});
ajaxTest
(
"jQuery.ajax() - abort"
,
9
,
{
ajaxTest
(
"jQuery.ajax() - abort"
,
9
,
{
setup
:
addGlobalEvents
,
setup
:
addGlobalEvents
(
"ajaxStart ajaxStop ajaxSend ajaxError ajaxComplete"
)
,
url
:
url
(
"data/name.php?wait=5"
),
url
:
url
(
"data/name.php?wait=5"
),
beforeSend
:
function
()
{
beforeSend
:
function
()
{
ok
(
true
,
"beforeSend"
);
ok
(
true
,
"beforeSend"
);
...
@@ -439,21 +442,7 @@ module( "ajax", {
...
@@ -439,21 +442,7 @@ module( "ajax", {
});
});
ajaxTest
(
"jQuery.ajax() - disabled globals"
,
3
,
{
ajaxTest
(
"jQuery.ajax() - disabled globals"
,
3
,
{
setup
:
function
()
{
setup
:
addGlobalEvents
(
"ajaxStart ajaxStop ajaxSend ajaxComplete ajaxError ajaxSuccess"
),
jQuery
(
"#foo"
).
ajaxStart
(
function
()
{
ok
(
false
,
"ajaxStart"
);
}).
ajaxStop
(
function
()
{
ok
(
false
,
"ajaxStop"
);
}).
ajaxSend
(
function
()
{
ok
(
false
,
"ajaxSend"
);
}).
ajaxComplete
(
function
()
{
ok
(
false
,
"ajaxComplete"
);
}).
ajaxError
(
function
()
{
ok
(
false
,
"ajaxError"
);
}).
ajaxSuccess
(
function
()
{
ok
(
false
,
"ajaxSuccess"
);
});
},
global
:
false
,
global
:
false
,
url
:
url
(
"data/name.html"
),
url
:
url
(
"data/name.html"
),
beforeSend
:
function
()
{
beforeSend
:
function
()
{
...
@@ -1696,7 +1685,7 @@ module( "ajax", {
...
@@ -1696,7 +1685,7 @@ module( "ajax", {
});
});
asyncTest
(
"jQuery.fn.load() - 404 error callbacks"
,
6
,
function
()
{
asyncTest
(
"jQuery.fn.load() - 404 error callbacks"
,
6
,
function
()
{
addGlobalEvents
();
addGlobalEvents
(
"ajaxStart ajaxStop ajaxSend ajaxComplete ajaxError"
)(
);
jQuery
(
document
).
ajaxStop
(
start
);
jQuery
(
document
).
ajaxStop
(
start
);
jQuery
(
"<div/>"
).
load
(
"data/404.html"
,
function
()
{
jQuery
(
"<div/>"
).
load
(
"data/404.html"
,
function
()
{
ok
(
true
,
"complete"
);
ok
(
true
,
"complete"
);
...
...
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