( valueObj, assert )
| 195 | } |
| 196 | |
| 197 | function testAppend( valueObj, assert ) { |
| 198 | |
| 199 | assert.expect( 82 ); |
| 200 | |
| 201 | testAppendForObject( valueObj, false, assert ); |
| 202 | testAppendForObject( valueObj, true, assert ); |
| 203 | |
| 204 | var defaultText, result, message, iframe, iframeDoc, j, d, |
| 205 | $input, $radioChecked, $radioUnchecked, $radioParent, $map, $table; |
| 206 | |
| 207 | defaultText = "Try them out:"; |
| 208 | result = jQuery( "#first" ).append( valueObj( "<b>buga</b>" ) ); |
| 209 | |
| 210 | assert.equal( result.text(), defaultText + "buga", "Check if text appending works" ); |
| 211 | assert.equal( jQuery( "#select3" ).append( valueObj( "<option value='appendTest'>Append Test</option>" ) ).find( "option:last-child" ).attr( "value" ), "appendTest", "Appending html options to select element" ); |
| 212 | |
| 213 | jQuery( "#qunit-fixture form" ).append( valueObj( "<input name='radiotest' type='radio' checked='checked' />" ) ); |
| 214 | jQuery( "#qunit-fixture form input[name=radiotest]" ).each( function() { |
| 215 | assert.ok( jQuery( this ).is( ":checked" ), "Append checked radio" ); |
| 216 | } ).remove(); |
| 217 | |
| 218 | jQuery( "#qunit-fixture form" ).append( valueObj( "<input name='radiotest2' type='radio' checked = 'checked' />" ) ); |
| 219 | jQuery( "#qunit-fixture form input[name=radiotest2]" ).each( function() { |
| 220 | assert.ok( jQuery( this ).is( ":checked" ), "Append alternately formatted checked radio" ); |
| 221 | } ).remove(); |
| 222 | |
| 223 | jQuery( "#qunit-fixture form" ).append( valueObj( "<input name='radiotest3' type='radio' checked />" ) ); |
| 224 | jQuery( "#qunit-fixture form input[name=radiotest3]" ).each( function() { |
| 225 | assert.ok( jQuery( this ).is( ":checked" ), "Append HTML5-formatted checked radio" ); |
| 226 | } ).remove(); |
| 227 | |
| 228 | jQuery( "#qunit-fixture form" ).append( valueObj( "<input type='radio' checked='checked' name='radiotest4' />" ) ); |
| 229 | jQuery( "#qunit-fixture form input[name=radiotest4]" ).each( function() { |
| 230 | assert.ok( jQuery( this ).is( ":checked" ), "Append with name attribute after checked attribute" ); |
| 231 | } ).remove(); |
| 232 | |
| 233 | message = "Test for appending a DOM node to the contents of an iframe"; |
| 234 | iframe = jQuery( "#iframe" )[ 0 ]; |
| 235 | iframeDoc = iframe.contentDocument || iframe.contentWindow && iframe.contentWindow.document; |
| 236 | |
| 237 | try { |
| 238 | if ( iframeDoc && iframeDoc.body ) { |
| 239 | assert.equal( jQuery( iframeDoc.body ).append( valueObj( "<div id='success'>test</div>" ) )[ 0 ].lastChild.id, "success", message ); |
| 240 | } else { |
| 241 | assert.ok( true, message + " - can't test" ); |
| 242 | } |
| 243 | } catch ( e ) { |
| 244 | assert.strictEqual( e.message || e, undefined, message ); |
| 245 | } |
| 246 | |
| 247 | jQuery( "<fieldset></fieldset>" ).appendTo( "#form" ).append( valueObj( "<legend id='legend'>test</legend>" ) ); |
| 248 | assert.t( "Append legend", "#legend", [ "legend" ] ); |
| 249 | |
| 250 | $map = jQuery( "<map></map>" ).append( valueObj( "<area id='map01' shape='rect' coords='50,50,150,150' href='https://www.jquery.com/' alt='jQuery'>" ) ); |
| 251 | |
| 252 | assert.equal( $map[ 0 ].childNodes.length, 1, "The area was inserted." ); |
| 253 | assert.equal( $map[ 0 ].firstChild.nodeName.toLowerCase(), "area", "The area was inserted." ); |
| 254 |
no test coverage detected