aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjeresig <jeresig@gmail.com>2010-10-09 11:41:58 -0400
committerjeresig <jeresig@gmail.com>2010-10-09 11:41:58 -0400
commit51283d9643726721acc415dba891004a30cf1ae6 (patch)
tree102a63f95ca9c30c3e7d40173c46a6d6416c3a72
parent2ae872c594790c4b935a1d7eabdf8b8212fd3c3f (diff)
downloadjquery-51283d9643726721acc415dba891004a30cf1ae6.tar.gz
jquery-51283d9643726721acc415dba891004a30cf1ae6.zip
Added some more tests to make sure that replaceWith is working correctly. Follow-up to the comment on 2a6de9ab66653e5e424d9cc79d195b555158d04f.
-rw-r--r--test/unit/manipulation.js15
1 files changed, 13 insertions, 2 deletions
diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js
index 7b4f4d159..d4c434871 100644
--- a/test/unit/manipulation.js
+++ b/test/unit/manipulation.js
@@ -680,7 +680,7 @@ test("insertAfter(String|Element|Array&lt;Element&gt;|jQuery)", function() {
});
var testReplaceWith = function(val) {
- expect(17);
+ expect(20);
jQuery('#yahoo').replaceWith(val( '<b id="replace">buga</b>' ));
ok( jQuery("#replace")[0], 'Replace element with string' );
ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after string' );
@@ -748,6 +748,17 @@ var testReplaceWith = function(val) {
//"</script>");
equals(jQuery('.replacewith').length, 1, 'Check number of elements in page.');
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() {
@@ -757,7 +768,7 @@ test("replaceWith(String|Element|Array&lt;Element&gt;|jQuery)", function() {
test("replaceWith(Function)", function() {
testReplaceWith(functionReturningObj);
- expect(18);
+ expect(21);
var y = jQuery("#yahoo")[0];