testrunner: Putting back the global variables used for ajax tests. I added many calls to delete though. The global namespace must be cleaned up before calling start() again.
This commit is contained in:
parent
d62875fb01
commit
afb05081c0
6 changed files with 54 additions and 30 deletions
|
@ -1,6 +1,6 @@
|
||||||
html text<br/>
|
html text<br/>
|
||||||
<script type="text/javascript">/* <![CDATA[ */
|
<script type="text/javascript">/* <![CDATA[ */
|
||||||
jQuery.testFoo = "foo"; jQuery('#foo').html('foo');
|
testFoo = "foo"; jQuery('#foo').html('foo');
|
||||||
ok( true, "test.html executed" );
|
ok( true, "test.html executed" );
|
||||||
/* ]]> */</script>
|
/* ]]> */</script>
|
||||||
<script src="data/test.js"></script>
|
<script src="data/test.js"></script>
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
jQuery.foobar = "bar";
|
foobar = "bar";
|
||||||
jQuery('#ap').html('bar');
|
jQuery('#ap').html('bar');
|
||||||
ok( true, "test.js executed");
|
ok( true, "test.js executed");
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
html text<br/>
|
html text<br/>
|
||||||
<script type="text/javascript">/* <![CDATA[ */
|
<script type="text/javascript">/* <![CDATA[ */
|
||||||
jQuery.testFoo = "foo"; jQuery('#foo').html('foo');
|
testFoo = "foo"; jQuery('#foo').html('foo');
|
||||||
ok( true, "test.php executed" );
|
ok( true, "test.php executed" );
|
||||||
/* ]]> */</script>
|
/* ]]> */</script>
|
||||||
<script src="data/test.js?<?php srand(); echo time() . '' . rand(); ?>"></script>
|
<script src="data/test.js?<?php srand(); echo time() . '' . rand(); ?>"></script>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
jQuery.testFoo = "foo";
|
testFoo = "foo";
|
||||||
jQuery('#foo').html('foo');
|
jQuery('#foo').html('foo');
|
||||||
ok( true, "test2.html executed" );
|
ok( true, "test2.html executed" );
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -161,12 +161,17 @@ test("jQuery.ajax - dataType html", function() {
|
||||||
expect(5);
|
expect(5);
|
||||||
stop();
|
stop();
|
||||||
|
|
||||||
jQuery.foobar = null;
|
window.foobar = null;
|
||||||
jQuery.testFoo = undefined;
|
window.testFoo = undefined;
|
||||||
|
|
||||||
var verifyEvaluation = function() {
|
var verifyEvaluation = function() {
|
||||||
equals( jQuery.testFoo, "foo", 'Check if script was evaluated for datatype html' );
|
equals( testFoo, "foo", 'Check if script was evaluated for datatype html' );
|
||||||
equals( jQuery.foobar, "bar", 'Check if script src was evaluated for datatype html' );
|
equals( foobar, "bar", 'Check if script src was evaluated for datatype html' );
|
||||||
|
|
||||||
|
// Cleanup the global namespace
|
||||||
|
delete window.foobar;
|
||||||
|
delete window.testFoo;
|
||||||
|
|
||||||
start();
|
start();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -255,6 +260,8 @@ test("pass-through request object", function() {
|
||||||
equals(successCount, 5, "Check all ajax calls successful");
|
equals(successCount, 5, "Check all ajax calls successful");
|
||||||
equals(errorCount, 0, "Check no ajax errors (status" + errorEx + ")");
|
equals(errorCount, 0, "Check no ajax errors (status" + errorEx + ")");
|
||||||
jQuery("#foo").unbind('ajaxError');
|
jQuery("#foo").unbind('ajaxError');
|
||||||
|
|
||||||
|
delete window.foobar;
|
||||||
start();
|
start();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -357,17 +364,24 @@ test("load(String, Function) - simple: inject text into DOM", function() {
|
||||||
test("load(String, Function) - check scripts", function() {
|
test("load(String, Function) - check scripts", function() {
|
||||||
expect(7);
|
expect(7);
|
||||||
stop();
|
stop();
|
||||||
jQuery.testFoo = undefined;
|
|
||||||
jQuery.foobar = null;
|
window.testFoo = undefined;
|
||||||
|
window.foobar = null;
|
||||||
|
|
||||||
var verifyEvaluation = function() {
|
var verifyEvaluation = function() {
|
||||||
equals( jQuery.foobar, "bar", 'Check if script src was evaluated after load' );
|
equals( foobar, "bar", 'Check if script src was evaluated after load' );
|
||||||
equals( jQuery('#ap').html(), 'bar', 'Check if script evaluation has modified DOM');
|
equals( jQuery('#ap').html(), 'bar', 'Check if script evaluation has modified DOM');
|
||||||
|
|
||||||
|
// Cleanup the global namespace
|
||||||
|
delete window.foobar;
|
||||||
|
delete window.testFoo;
|
||||||
|
|
||||||
start();
|
start();
|
||||||
};
|
};
|
||||||
jQuery('#first').load(url('data/test.html'), function() {
|
jQuery('#first').load(url('data/test.html'), function() {
|
||||||
ok( jQuery('#first').html().match(/^html text/), 'Check content after loading html' );
|
ok( jQuery('#first').html().match(/^html text/), 'Check content after loading html' );
|
||||||
equals( jQuery('#foo').html(), 'foo', 'Check if script evaluation has modified DOM');
|
equals( jQuery('#foo').html(), 'foo', 'Check if script evaluation has modified DOM');
|
||||||
equals( jQuery.testFoo, "foo", 'Check if script was evaluated after load' );
|
equals( testFoo, "foo", 'Check if script was evaluated after load' );
|
||||||
setTimeout(verifyEvaluation, 600);
|
setTimeout(verifyEvaluation, 600);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -375,10 +389,13 @@ test("load(String, Function) - check scripts", function() {
|
||||||
test("load(String, Function) - check file with only a script tag", function() {
|
test("load(String, Function) - check file with only a script tag", function() {
|
||||||
expect(3);
|
expect(3);
|
||||||
stop();
|
stop();
|
||||||
jQuery.testFoo = undefined;
|
window.testFoo = undefined;
|
||||||
jQuery('#first').load(url('data/test2.html'), function() {
|
jQuery('#first').load(url('data/test2.html'), function() {
|
||||||
equals( jQuery('#foo').html(), 'foo', 'Check if script evaluation has modified DOM');
|
equals( jQuery('#foo').html(), 'foo', 'Check if script evaluation has modified DOM');
|
||||||
equals( jQuery.testFoo, "foo", 'Check if script was evaluated after load' );
|
equals( testFoo, "foo", 'Check if script was evaluated after load' );
|
||||||
|
|
||||||
|
// Cleanup the global namespace
|
||||||
|
delete window.testFoo;
|
||||||
start();
|
start();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -424,9 +441,10 @@ test("jQuery.get(String, Hash, Function) - parse xml and use text() on nodes", f
|
||||||
test("jQuery.getScript(String, Function) - with callback", function() {
|
test("jQuery.getScript(String, Function) - with callback", function() {
|
||||||
expect(2);
|
expect(2);
|
||||||
stop();
|
stop();
|
||||||
jQuery.foobar = null;
|
window.foobar = null;
|
||||||
jQuery.getScript(url("data/test.js"), function() {
|
jQuery.getScript(url("data/test.js"), function() {
|
||||||
equals( jQuery.foobar, "bar", 'Check if script was evaluated' );
|
equals( foobar, "bar", 'Check if script was evaluated' );
|
||||||
|
delete window.foobar;
|
||||||
setTimeout(start, 100);
|
setTimeout(start, 100);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -434,7 +452,10 @@ test("jQuery.getScript(String, Function) - with callback", function() {
|
||||||
test("jQuery.getScript(String, Function) - no callback", function() {
|
test("jQuery.getScript(String, Function) - no callback", function() {
|
||||||
expect(1);
|
expect(1);
|
||||||
stop();
|
stop();
|
||||||
jQuery.getScript(url("data/test.js"), start);
|
jQuery.getScript(url("data/test.js"), function(){
|
||||||
|
delete window.foobar;
|
||||||
|
start();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test("jQuery.ajax() - JSONP, Local", function() {
|
test("jQuery.ajax() - JSONP, Local", function() {
|
||||||
|
@ -616,12 +637,13 @@ test("jQuery.ajax() - script, Remote", function() {
|
||||||
|
|
||||||
stop();
|
stop();
|
||||||
|
|
||||||
jQuery.foobar = null;
|
window.foobar = null;
|
||||||
jQuery.ajax({
|
jQuery.ajax({
|
||||||
url: base + "data/test.js",
|
url: base + "data/test.js",
|
||||||
dataType: "script",
|
dataType: "script",
|
||||||
success: function(data){
|
success: function(data){
|
||||||
ok( jQuery.foobar, "Script results returned (GET, no callback)" );
|
ok( foobar, "Script results returned (GET, no callback)" );
|
||||||
|
delete window.foobar;
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -634,14 +656,15 @@ test("jQuery.ajax() - script, Remote with POST", function() {
|
||||||
|
|
||||||
stop();
|
stop();
|
||||||
|
|
||||||
jQuery.foobar = null;
|
window.foobar = null;
|
||||||
jQuery.ajax({
|
jQuery.ajax({
|
||||||
url: base + "data/test.js",
|
url: base + "data/test.js",
|
||||||
type: "POST",
|
type: "POST",
|
||||||
dataType: "script",
|
dataType: "script",
|
||||||
success: function(data, status){
|
success: function(data, status){
|
||||||
ok( jQuery.foobar, "Script results returned (GET, no callback)" );
|
ok( foobar, "Script results returned (GET, no callback)" );
|
||||||
equals( status, "success", "Script results returned (GET, no callback)" );
|
equals( status, "success", "Script results returned (GET, no callback)" );
|
||||||
|
delete window.foobar;
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -655,12 +678,13 @@ test("jQuery.ajax() - script, Remote with scheme-less URL", function() {
|
||||||
|
|
||||||
stop();
|
stop();
|
||||||
|
|
||||||
jQuery.foobar = null;
|
window.foobar = null;
|
||||||
jQuery.ajax({
|
jQuery.ajax({
|
||||||
url: base + "data/test.js",
|
url: base + "data/test.js",
|
||||||
dataType: "script",
|
dataType: "script",
|
||||||
success: function(data){
|
success: function(data){
|
||||||
ok( jQuery.foobar, "Script results returned (GET, no callback)" );
|
ok( foobar, "Script results returned (GET, no callback)" );
|
||||||
|
delete window.foobar;
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -337,15 +337,15 @@ jQuery.each( {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
jQuery.check = ['opacity','height','width','display','overflow'];
|
|
||||||
|
|
||||||
jQuery.fn.saveState = function(){
|
jQuery.fn.saveState = function(){
|
||||||
expect(jQuery.check.length);
|
var check = ['opacity','height','width','display','overflow'];
|
||||||
|
expect(check.length);
|
||||||
|
|
||||||
stop();
|
stop();
|
||||||
return this.each(function(){
|
return this.each(function(){
|
||||||
var self = this;
|
var self = this;
|
||||||
self.save = {};
|
self.save = {};
|
||||||
jQuery.each(jQuery.check, function(i,c){
|
jQuery.each(check, function(i,c){
|
||||||
self.save[c] = jQuery.css(self,c);
|
self.save[c] = jQuery.css(self,c);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue