Commit 51283d96 authored by jeresig's avatar jeresig

Added some more tests to make sure that replaceWith is working correctly....

Added some more tests to make sure that replaceWith is working correctly. Follow-up to the comment on 2a6de9ab.
parent 2ae872c5
...@@ -680,7 +680,7 @@ test("insertAfter(String|Element|Array<Element>|jQuery)", function() { ...@@ -680,7 +680,7 @@ test("insertAfter(String|Element|Array<Element>|jQuery)", function() {
}); });
var testReplaceWith = function(val) { var testReplaceWith = function(val) {
expect(17); expect(20);
jQuery('#yahoo').replaceWith(val( '<b id="replace">buga</b>' )); jQuery('#yahoo').replaceWith(val( '<b id="replace">buga</b>' ));
ok( jQuery("#replace")[0], 'Replace element with string' ); ok( jQuery("#replace")[0], 'Replace element with string' );
ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after string' ); ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after string' );
...@@ -748,6 +748,17 @@ var testReplaceWith = function(val) { ...@@ -748,6 +748,17 @@ var testReplaceWith = function(val) {
//"</script>"); //"</script>");
equals(jQuery('.replacewith').length, 1, 'Check number of elements in page.'); equals(jQuery('.replacewith').length, 1, 'Check number of elements in page.');
jQuery('.replacewith').remove(); jQuery('.replacewith').remove();
QUnit.reset();
jQuery("#main").append("<div id='replaceWith'></div>");
equals( jQuery("#main").find("div[id=replaceWith]").length, 1, "Make sure only one div exists." );
jQuery("#replaceWith").replaceWith( val("<div id='replaceWith'></div>") );
equals( jQuery("#main").find("div[id=replaceWith]").length, 1, "Make sure only one div exists." );
jQuery("#replaceWith").replaceWith( val("<div id='replaceWith'></div>") );
equals( jQuery("#main").find("div[id=replaceWith]").length, 1, "Make sure only one div exists." );
} }
test("replaceWith(String|Element|Array&lt;Element&gt;|jQuery)", function() { test("replaceWith(String|Element|Array&lt;Element&gt;|jQuery)", function() {
...@@ -757,7 +768,7 @@ test("replaceWith(String|Element|Array&lt;Element&gt;|jQuery)", function() { ...@@ -757,7 +768,7 @@ test("replaceWith(String|Element|Array&lt;Element&gt;|jQuery)", function() {
test("replaceWith(Function)", function() { test("replaceWith(Function)", function() {
testReplaceWith(functionReturningObj); testReplaceWith(functionReturningObj);
expect(18); expect(21);
var y = jQuery("#yahoo")[0]; var y = jQuery("#yahoo")[0];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment