X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;ds=inline;f=src%2Fjquery%2FcoreTest.js;h=928f07e5cc1bea328e79a1f1cc74adc8998b0be5;hb=a5c319f922efcf34652d0632a945d20a0ab36ca6;hp=e9192849758e6562df3a477493f7ac00d8390b44;hpb=3ae74b523ec379a1753d116bb7f1aec8db2c52d4;p=jquery.git
diff --git a/src/jquery/coreTest.js b/src/jquery/coreTest.js
index e919284..928f07e 100644
--- a/src/jquery/coreTest.js
+++ b/src/jquery/coreTest.js
@@ -348,20 +348,50 @@ test("wrap(String|Element)", function() {
ok( result.text() == defaultText, 'Check for element wrapping' );
reset();
- //stop();
$('#check1').click(function() {
var checkbox = this;
ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );
$(checkbox).wrap( '
' );
ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );
- // use a fade in to check state after this event handler has finished
- /*setTimeout(function() {
- ok( !checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );
- start();
- }, 100);*/
}).click();
});
+test("wrapAll(String|Element)", function() {
+ expect(8);
+ var prev = $("#first")[0].previousSibling;
+ var p = $("#first")[0].parentNode;
+ var result = $('#first,#firstp').wrapAll('');
+ equals( result.parent().length, 1, 'Check for wrapping of on-the-fly html' );
+ ok( $('#first').parent().parent().is('.red'), 'Check if wrapper has class "red"' );
+ ok( $('#firstp').parent().parent().is('.red'), 'Check if wrapper has class "red"' );
+ equals( $("#first").parent().parent()[0].previousSibling, prev, "Correct Previous Sibling" );
+ equals( $("#first").parent().parent()[0].parentNode, p, "Correct Parent" );
+
+ reset();
+ var prev = $("#first")[0].previousSibling;
+ var p = $("#first")[0].parentNode;
+ var result = $('#first,#firstp').wrapAll(document.getElementById('empty'));
+ equals( $("#first").parent()[0], $("#firstp").parent()[0], "Same Parent" );
+ equals( $("#first").parent()[0].previousSibling, prev, "Correct Previous Sibling" );
+ equals( $("#first").parent()[0].parentNode, p, "Correct Parent" );
+});
+
+test("wrapInner(String|Element)", function() {
+ expect(6);
+ var num = $("#first").children().length;
+ var result = $('#first').wrapInner('');
+ equals( $("#first").children().length, 1, "Only one child" );
+ ok( $("#first").children().is(".red"), "Verify Right Element" );
+ equals( $("#first").children().children().children().length, num, "Verify Elements Intact" );
+
+ reset();
+ var num = $("#first").children().length;
+ var result = $('#first').wrapInner(document.getElementById('empty'));
+ equals( $("#first").children().length, 1, "Only one child" );
+ ok( $("#first").children().is("#empty"), "Verify Right Element" );
+ equals( $("#first").children().children().length, num, "Verify Elements Intact" );
+});
+
test("append(String|Element|Array<Element>|jQuery)", function() {
expect(18);
var defaultText = 'Try them out:'
@@ -976,3 +1006,30 @@ test("slice()", function() {
isSet( $("#ap a").slice(0,3), q("google", "groups", "anchor1"), "slice(0,3)" );
isSet( $("#ap a").slice(-1), q("mark"), "slice(-1)" );
});
+
+test("map()", function() {
+ expect(2);
+
+ isSet(
+ $("#ap").map(function(){
+ return $(this).find("a").get();
+ }),
+ q("google", "groups", "anchor1", "mark"),
+ "Array Map"
+ );
+
+ isSet(
+ $("#ap > a").map(function(){
+ return this.parentNode;
+ }),
+ q("ap","ap","ap"),
+ "Single Map"
+ );
+});
+
+test("contents()", function() {
+ expect(3);
+ equals( $("#ap").contents().length, 9, "Check element contents" );
+ ok( $("#iframe").contents()[0], "Check existance of IFrame document" );
+ ok( $("#iframe").contents()[0].body, "Check existance of IFrame body" );
+});