aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorRichard Gibson <richard.gibson@gmail.com>2012-12-02 23:32:16 -0500
committerRichard Gibson <richard.gibson@gmail.com>2012-12-02 23:32:16 -0500
commit5b9bf134390d56d6b6916225d86c1328e70e9970 (patch)
treea5310c5395cb903caf353ecf9389189cfc438eb7 /test/unit
parent27c9360a1b3c099850f4da8ba26a387f88b1897e (diff)
downloadjquery-5b9bf134390d56d6b6916225d86c1328e70e9970.tar.gz
jquery-5b9bf134390d56d6b6916225d86c1328e70e9970.zip
No ticket: improve global variable/ajax request tracking
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/ajax.js33
-rw-r--r--test/unit/core.js3
-rw-r--r--test/unit/manipulation.js12
3 files changed, 28 insertions, 20 deletions
diff --git a/test/unit/ajax.js b/test/unit/ajax.js
index a65f90536..f88b5d7cc 100644
--- a/test/unit/ajax.js
+++ b/test/unit/ajax.js
@@ -533,7 +533,7 @@ module( "ajax", {
ajaxTest( "jQuery.ajax() - dataType html", 5, {
setup: function() {
Globals.register("testFoo");
- Globals.register("foobar");
+ Globals.register("testBar");
},
dataType: "html",
url: url("data/test.html"),
@@ -541,7 +541,7 @@ module( "ajax", {
ok( data.match( /^html text/ ), "Check content for datatype html" );
jQuery("#ap").html( data );
strictEqual( window["testFoo"], "foo", "Check if script was evaluated for datatype html" );
- strictEqual( window["foobar"], "bar", "Check if script src was evaluated for datatype html" );
+ strictEqual( window["testBar"], "bar", "Check if script src was evaluated for datatype html" );
}
});
@@ -588,6 +588,7 @@ module( "ajax", {
jQuery( document ).off("ajaxError.passthru");
start();
});
+ Globals.register("testBar");
ok( jQuery.get( url(target), success ), "get" );
ok( jQuery.post( url(target), success ), "post" );
@@ -836,28 +837,37 @@ module( "ajax", {
});
ajaxTest( "jQuery.ajax() - script, Remote", 2, {
+ setup: function() {
+ Globals.register("testBar");
+ },
url: window.location.href.replace( /[^\/]*$/, "" ) + "data/test.js",
dataType: "script",
success: function( data ) {
- ok( window[ "foobar" ], "Script results returned (GET, no callback)" );
+ strictEqual( window["testBar"], "bar", "Script results returned (GET, no callback)" );
}
});
ajaxTest( "jQuery.ajax() - script, Remote with POST", 3, {
+ setup: function() {
+ Globals.register("testBar");
+ },
url: window.location.href.replace( /[^\/]*$/, "" ) + "data/test.js",
type: "POST",
dataType: "script",
success: function( data, status ) {
- ok( window[ "foobar" ], "Script results returned (POST, no callback)" );
+ strictEqual( window["testBar"], "bar", "Script results returned (POST, no callback)" );
strictEqual( status, "success", "Script results returned (POST, no callback)" );
}
});
ajaxTest( "jQuery.ajax() - script, Remote with scheme-less URL", 2, {
+ setup: function() {
+ Globals.register("testBar");
+ },
url: window.location.href.replace( /[^\/]*$/, "" ).replace( /^.*?\/\//, "//" ) + "data/test.js",
dataType: "script",
success: function( data ) {
- ok( window[ "foobar" ], "Script results returned (GET, no callback)" );
+ strictEqual( window["testBar"], "bar", "Script results returned (GET, no callback)" );
}
});
@@ -1655,17 +1665,20 @@ module( "ajax", {
//----------- jQuery.getScript()
asyncTest( "jQuery.getScript( String, Function ) - with callback", 2, function() {
+ Globals.register("testBar");
jQuery.getScript( url("data/test.js"), function( data, _, jqXHR ) {
- strictEqual( foobar, "bar", "Check if script was evaluated" );
+ strictEqual( window["testBar"], "bar", "Check if script was evaluated" );
start();
});
});
asyncTest( "jQuery.getScript( String, Function ) - no callback", 1, function() {
+ Globals.register("testBar");
jQuery.getScript( url("data/test.js") ).done( start );
});
asyncTest( "#8082 - jQuery.getScript( String, Function ) - source as responseText", 2, function() {
+ Globals.register("testBar");
jQuery.getScript( url("data/test.js"), function( data, _, jqXHR ) {
strictEqual( data, jqXHR.responseText, "Same-domain script requests returns the source of the script" );
start();
@@ -1729,10 +1742,14 @@ module( "ajax", {
asyncTest( "jQuery.fn.load( String, Function ) - check scripts", 7, function() {
var verifyEvaluation = function() {
- strictEqual( window["foobar"], "bar", "Check if script src was evaluated after load" );
+ strictEqual( window["testBar"], "bar", "Check if script src was evaluated after load" );
strictEqual( jQuery("#ap").html(), "bar", "Check if script evaluation has modified DOM");
start();
};
+
+ Globals.register("testFoo");
+ Globals.register("testBar");
+
jQuery("#first").load( url("data/test.html"), function() {
ok( jQuery("#first").html().match( /^html text/ ), "Check content after loading html" );
strictEqual( jQuery("#foo").html(), "foo", "Check if script evaluation has modified DOM" );
@@ -1742,6 +1759,8 @@ module( "ajax", {
});
asyncTest( "jQuery.fn.load( String, Function ) - check file with only a script tag", 3, function() {
+ Globals.register("testFoo");
+
jQuery("#first").load( url("data/test2.html"), function() {
strictEqual( jQuery("#foo").html(), "foo", "Check if script evaluation has modified DOM");
strictEqual( window["testFoo"], "foo", "Check if script was evaluated after load" );
diff --git a/test/unit/core.js b/test/unit/core.js
index 603368b9e..6ecfe5a4f 100644
--- a/test/unit/core.js
+++ b/test/unit/core.js
@@ -195,6 +195,7 @@ test( "selector state", function() {
test( "globalEval", function() {
expect( 3 );
+ Globals.register("globalEvalTest");
jQuery.globalEval("globalEvalTest = 1;");
equal( window.globalEvalTest, 1, "Test variable assignments are global" );
@@ -204,8 +205,6 @@ test( "globalEval", function() {
jQuery.globalEval("this.globalEvalTest = 3;");
equal( window.globalEvalTest, 3, "Test context (this) is the window object" );
-
- jQuery.globalEval("delete globalEvalTest;");
});
test("noConflict", function() {
diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js
index 4a980b249..530224354 100644
--- a/test/unit/manipulation.js
+++ b/test/unit/manipulation.js
@@ -704,7 +704,7 @@ test("append(xml)", function() {
});
test("appendTo(String|Element|Array<Element>|jQuery)", function() {
- expect( 16 + ( jQuery.getScript ? 1 : 0 ) );
+ expect( 16 );
var defaultText = "Try them out:";
@@ -775,16 +775,6 @@ test("appendTo(String|Element|Array<Element>|jQuery)", function() {
div.remove().appendTo("#qunit-fixture");
equal( jQuery("#qunit-fixture div").length, num, "Make sure all the removed divs were inserted." );
-
- QUnit.reset();
-
- if ( jQuery.getScript ) {
- stop();
- jQuery.getScript("data/test.js", function() {
- jQuery("script[src*='data\\/test\\.js']").remove();
- start();
- });
- }
});
var testPrepend = function(val) {