aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/manipulation.js
diff options
context:
space:
mode:
authorabnud1 <ahmad13932013@hotmail.com>2019-02-18 19:02:38 +0100
committerMichał Gołębiowski-Owczarek <m.goleb@gmail.com>2019-02-18 19:03:26 +0100
commitc3498187421d0a50ee0369163428481137a04b99 (patch)
tree9f56f408a22f610089474d2f1784f1a680b4d483 /test/unit/manipulation.js
parentda44ff39c2c3433e32b757b05b5643edb72fe786 (diff)
downloadjquery-c3498187421d0a50ee0369163428481137a04b99.tar.gz
jquery-c3498187421d0a50ee0369163428481137a04b99.zip
Build: Update test code for compatibility with QUnit 2.x (#4297)
Also, run `grunt npmcopy` to sync the "external" directory with dependencies from package.json. For example, the Sinon library version didn't match. Ref gh-4234 Closes gh-4297
Diffstat (limited to 'test/unit/manipulation.js')
-rw-r--r--test/unit/manipulation.js77
1 files changed, 41 insertions, 36 deletions
diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js
index 0acb45f3e..d72f1374f 100644
--- a/test/unit/manipulation.js
+++ b/test/unit/manipulation.js
@@ -1,5 +1,5 @@
QUnit.module( "manipulation", {
- teardown: moduleTeardown
+ afterEach: moduleTeardown
} );
// Ensure that an extended Array prototype doesn't break jQuery
@@ -1300,7 +1300,7 @@ function testReplaceWith( val, assert ) {
$div = jQuery( "<div class='replacewith'></div>" ).appendTo( "#qunit-fixture" );
$div.replaceWith( val( "<div class='replacewith'></div><script>" +
- "equal( jQuery('.replacewith').length, 1, 'Check number of elements in page.' );" +
+ "QUnit.assert.equal( jQuery('.replacewith').length, 1, 'Check number of elements in page.' );" +
"</script>" ) );
jQuery( "#qunit-fixture" ).append( "<div id='replaceWith'></div>" );
@@ -1754,15 +1754,15 @@ function testHtml( valueObj, assert ) {
tmp = fixture.html(
valueObj( [
- "<script type='something/else'>ok( false, 'evaluated: non-script' );</script>",
- "<script type='text/javascript'>ok( true, 'evaluated: text/javascript' );</script>",
- "<script type='text/ecmascript'>ok( true, 'evaluated: text/ecmascript' );</script>",
- "<script>ok( true, 'evaluated: no type' );</script>",
+ "<script type='something/else'>QUnit.assert.ok( false, 'evaluated: non-script' );</script>",
+ "<script type='text/javascript'>QUnit.assert.ok( true, 'evaluated: text/javascript' );</script>",
+ "<script type='text/ecmascript'>QUnit.assert.ok( true, 'evaluated: text/ecmascript' );</script>",
+ "<script>QUnit.assert.ok( true, 'evaluated: no type' );</script>",
"<div>",
- "<script type='something/else'>ok( false, 'evaluated: inner non-script' );</script>",
- "<script type='text/javascript'>ok( true, 'evaluated: inner text/javascript' );</script>",
- "<script type='text/ecmascript'>ok( true, 'evaluated: inner text/ecmascript' );</script>",
- "<script>ok( true, 'evaluated: inner no type' );</script>",
+ "<script type='something/else'>QUnit.assert.ok( false, 'evaluated: inner non-script' );</script>",
+ "<script type='text/javascript'>QUnit.assert.ok( true, 'evaluated: inner text/javascript' );</script>",
+ "<script type='text/ecmascript'>QUnit.assert.ok( true, 'evaluated: inner text/ecmascript' );</script>",
+ "<script>QUnit.assert.ok( true, 'evaluated: inner no type' );</script>",
"</div>"
].join( "" ) )
).find( "script" );
@@ -1770,19 +1770,19 @@ function testHtml( valueObj, assert ) {
assert.equal( tmp[ 0 ].type, "something/else", "Non-evaluated type." );
assert.equal( tmp[ 1 ].type, "text/javascript", "Evaluated type." );
- fixture.html( valueObj( "<script type='text/javascript'>ok( true, 'Injection of identical script' );</script>" ) );
- fixture.html( valueObj( "<script type='text/javascript'>ok( true, 'Injection of identical script' );</script>" ) );
- fixture.html( valueObj( "<script type='text/javascript'>ok( true, 'Injection of identical script' );</script>" ) );
- fixture.html( valueObj( "foo <form><script type='text/javascript'>ok( true, 'Injection of identical script (#975)' );</script></form>" ) );
+ fixture.html( valueObj( "<script type='text/javascript'>QUnit.assert.ok( true, 'Injection of identical script' );</script>" ) );
+ fixture.html( valueObj( "<script type='text/javascript'>QUnit.assert.ok( true, 'Injection of identical script' );</script>" ) );
+ fixture.html( valueObj( "<script type='text/javascript'>QUnit.assert.ok( true, 'Injection of identical script' );</script>" ) );
+ fixture.html( valueObj( "foo <form><script type='text/javascript'>QUnit.assert.ok( true, 'Injection of identical script (#975)' );</script></form>" ) );
jQuery.scriptorder = 0;
fixture.html( valueObj( [
"<script>",
- "equal( jQuery('#scriptorder').length, 1,'Execute after html' );",
- "equal( jQuery.scriptorder++, 0, 'Script is executed in order' );",
+ "QUnit.assert.equal( jQuery('#scriptorder').length, 1,'Execute after html' );",
+ "QUnit.assert.equal( jQuery.scriptorder++, 0, 'Script is executed in order' );",
"</script>",
- "<span id='scriptorder'><script>equal( jQuery.scriptorder++, 1, 'Script (nested) is executed in order');</script></span>",
- "<script>equal( jQuery.scriptorder++, 2, 'Script (unnested) is executed in order' );</script>"
+ "<span id='scriptorder'><script>QUnit.assert.equal( jQuery.scriptorder++, 1, 'Script (nested) is executed in order');</script></span>",
+ "<script>QUnit.assert.equal( jQuery.scriptorder++, 2, 'Script (unnested) is executed in order' );</script>"
].join( "" ) ) );
fixture.html( valueObj( fixture.text() ) );
@@ -1810,10 +1810,10 @@ QUnit[
$fixture.html(
[
- "<script type='module'>ok( true, 'evaluated: module' );</script>",
+ "<script type='module'>QUnit.assert.ok( true, 'evaluated: module' );</script>",
"<script type='module' src='" + url( "module.js" ) + "'></script>",
"<div>",
- "<script type='module'>ok( true, 'evaluated: inner module' );</script>",
+ "<script type='module'>QUnit.assert.ok( true, 'evaluated: inner module' );</script>",
"<script type='module' src='" + url( "inner_module.js" ) + "'></script>",
"</div>"
].join( "" )
@@ -2273,7 +2273,7 @@ QUnit.test( "domManip executes scripts containing html comments or CDATA (trac-9
jQuery( [
"<script type='text/javascript'>",
"<!--",
- "ok( true, '<!-- handled' );",
+ "QUnit.assert.ok( true, '<!-- handled' );",
"//-->",
"</script>"
].join( "\n" ) ).appendTo( "#qunit-fixture" );
@@ -2281,7 +2281,7 @@ QUnit.test( "domManip executes scripts containing html comments or CDATA (trac-9
jQuery( [
"<script type='text/javascript'>",
"<![CDATA[",
- "ok( true, '<![CDATA[ handled' );",
+ "QUnit.assert.ok( true, '<![CDATA[ handled' );",
"//]]>",
"</script>"
].join( "\n" ) ).appendTo( "#qunit-fixture" );
@@ -2289,7 +2289,7 @@ QUnit.test( "domManip executes scripts containing html comments or CDATA (trac-9
jQuery( [
"<script type='text/javascript'>",
"<!--//--><![CDATA[//><!--",
- "ok( true, '<!--//--><![CDATA[//><!-- (Drupal case) handled' );",
+ "QUnit.assert.ok( true, '<!--//--><![CDATA[//><!-- (Drupal case) handled' );",
"//--><!]]>",
"</script>"
].join( "\n" ) ).appendTo( "#qunit-fixture" );
@@ -2418,13 +2418,15 @@ QUnit.test( "Ensure oldIE creates a new set on appendTo (#8894)", function( asse
assert.strictEqual( jQuery( "<p/>" ).appendTo( "<div/>" ).end().length, jQuery( "<p>test</p>" ).appendTo( "<div/>" ).end().length, "Elements created with createElement and with createDocumentFragment should be treated alike" );
} );
-QUnit.asyncTest( "html() - script exceptions bubble (#11743)", 2, function( assert ) {
- var onerror = window.onerror;
+QUnit.test( "html() - script exceptions bubble (#11743)", function( assert ) {
+ assert.expect( 2 );
+ var done = assert.async(),
+ onerror = window.onerror;
setTimeout( function() {
window.onerror = onerror;
- QUnit.start();
+ done();
}, 1000 );
window.onerror = function() {
@@ -2493,15 +2495,15 @@ QUnit.test( "script evaluation (#11795)", function( assert ) {
objGlobal.ok = notOk;
scriptsIn = jQuery( [
- "<script type='something/else'>ok( false, 'evaluated: non-script' );</script>",
- "<script type='text/javascript'>ok( true, 'evaluated: text/javascript' );</script>",
- "<script type='text/ecmascript'>ok( true, 'evaluated: text/ecmascript' );</script>",
- "<script>ok( true, 'evaluated: no type' );</script>",
+ "<script type='something/else'>QUnit.assert.ok( false, 'evaluated: non-script' );</script>",
+ "<script type='text/javascript'>QUnit.assert.ok( true, 'evaluated: text/javascript' );</script>",
+ "<script type='text/ecmascript'>QUnit.assert.ok( true, 'evaluated: text/ecmascript' );</script>",
+ "<script>QUnit.assert.ok( true, 'evaluated: no type' );</script>",
"<div>",
- "<script type='something/else'>ok( false, 'evaluated: inner non-script' );</script>",
- "<script type='text/javascript'>ok( true, 'evaluated: inner text/javascript' );</script>",
- "<script type='text/ecmascript'>ok( true, 'evaluated: inner text/ecmascript' );</script>",
- "<script>ok( true, 'evaluated: inner no type' );</script>",
+ "<script type='something/else'>QUnit.assert.ok( false, 'evaluated: inner non-script' );</script>",
+ "<script type='text/javascript'>QUnit.assert.ok( true, 'evaluated: inner text/javascript' );</script>",
+ "<script type='text/ecmascript'>QUnit.assert.ok( true, 'evaluated: inner text/ecmascript' );</script>",
+ "<script>QUnit.assert.ok( true, 'evaluated: inner no type' );</script>",
"</div>"
].join( "" ) );
scriptsIn.appendTo( jQuery( "<div class='detached'/>" ) );
@@ -2823,7 +2825,8 @@ QUnit.test( "Make sure tags with single-character names are found (gh-4124)", fu
assert.strictEqual( htmlOut, htmlIn );
} );
-QUnit.test( "Insert script with data-URI (gh-1887)", 1, function( assert ) {
+QUnit.test( "Insert script with data-URI (gh-1887)", function( assert ) {
+ assert.expect( 1 );
Globals.register( "testFoo" );
Globals.register( "testSrcFoo" );
@@ -2849,7 +2852,9 @@ QUnit.test( "Insert script with data-URI (gh-1887)", 1, function( assert ) {
}, 100 );
} );
-QUnit.test( "Ignore content from unsuccessful responses (gh-4126)", 1, function( assert ) {
+QUnit.test( "Ignore content from unsuccessful responses (gh-4126)", function( assert ) {
+ assert.expect( 1 );
+
var globalEval = jQuery.globalEval;
jQuery.globalEval = function( code ) {
assert.ok( false, "no attempt to evaluate code from an unsuccessful response" );