MCPcopy Create free account
hub / github.com/jquery/jquery / testAppendForObject

Function testAppendForObject

test/unit/manipulation.js:123–195  ·  view source on GitHub ↗
( valueObj, isFragment, assert )

Source from the content-addressed store, hash-verified

121} );
122
123function testAppendForObject( valueObj, isFragment, assert ) {
124 var $base,
125 type = isFragment ? " (DocumentFragment)" : " (Element)",
126 text = "This link has class=\"blog\": Timmy Willison's Weblog",
127 el = document.getElementById( "sap" ).cloneNode( true ),
128 first = document.getElementById( "first" ),
129 yahoo = document.getElementById( "yahoo" );
130
131 if ( isFragment ) {
132 $base = document.createDocumentFragment();
133 jQuery( el ).contents().each( function() {
134 $base.appendChild( this );
135 } );
136 $base = jQuery( $base );
137 } else {
138 $base = jQuery( el );
139 }
140
141 assert.equal( $base.clone().append( valueObj( first.cloneNode( true ) ) ).text(),
142 text + "Try them out:",
143 "Check for appending of element" + type
144 );
145
146 assert.equal( $base.clone().append( valueObj( [ first.cloneNode( true ), yahoo.cloneNode( true ) ] ) ).text(),
147 text + "Try them out:Yahoo",
148 "Check for appending of array of elements" + type
149 );
150
151 assert.equal( $base.clone().append( valueObj( jQuery( "#yahoo, #first" ).clone() ) ).text(),
152 text + "YahooTry them out:",
153 "Check for appending of jQuery object" + type
154 );
155
156 assert.equal( $base.clone().append( valueObj( 5 ) ).text(),
157 text + "5",
158 "Check for appending a number" + type
159 );
160
161 assert.equal( $base.clone().append( valueObj( [ jQuery( "#first" ).clone(), jQuery( "#yahoo, #google" ).clone() ] ) ).text(),
162 text + "Try them out:GoogleYahoo",
163 "Check for appending of array of jQuery objects"
164 );
165
166 assert.equal( $base.clone().append( valueObj( " text with spaces " ) ).text(),
167 text + " text with spaces ",
168 "Check for appending text with spaces" + type
169 );
170
171 assert.equal( $base.clone().append( valueObj( [] ) ).text(),
172 text,
173 "Check for appending an empty array" + type
174 );
175
176 assert.equal( $base.clone().append( valueObj( "" ) ).text(),
177 text,
178 "Check for appending an empty string" + type
179 );
180

Callers 1

testAppendFunction · 0.85

Calls 1

jQueryFunction · 0.50

Tested by

no test coverage detected