Skip to content

Commit f69df14

Browse files
authored
Add files via upload
1 parent d23bcbc commit f69df14

File tree

1 file changed

+16
-28
lines changed

1 file changed

+16
-28
lines changed

test/unit/manipulation.js

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3100,34 +3100,26 @@ testIframe(
31003100
}
31013101
);
31023102

3103-
// Custom event handler test case
3104-
3105-
QUnit.test( "should handle custom '_se-custom-destroy' event correctly", function( assert ) {
3106-
3107-
// Define the expected number of assertions
3103+
QUnit.test( "should handle custom 'removeondestroy' event correctly", function( assert ) {
31083104

31093105
assert.expect( 4 );
31103106

3111-
// Set up the HTML structure by appending to the existing fixture
3112-
3113-
var fixture = jQuery( "#qunit-fixture" );
3114-
3115-
fixture.append( `
3107+
jQuery( `
31163108
<div id="container">
3117-
<div class="guarded removeself" data-elt="one">
3118-
Guarded 1
3119-
</div>
3120-
<div class="guarded" data-elt="two">
3121-
Guarded 2
3122-
</div>
3123-
<div class="guarded" data-elt="three">
3124-
Guarded 3
3125-
</div>
3109+
<div class="guarded removeself" data-elt="one">
3110+
Guarded 1
3111+
</div>
3112+
<div class="guarded" data-elt="two">
3113+
Guarded 2
3114+
</div>
3115+
<div class="guarded" data-elt="three">
3116+
Guarded 3
3117+
</div>
31263118
</div>
3127-
` );
3119+
` ).appendTo( "#qunit-fixture" );
31283120

31293121
// Define the custom event handler
3130-
jQuery.event.special[ "_se-custom-destroy" ] = {
3122+
jQuery.event.special.removeondestroy = {
31313123
remove: function( _handleObj ) {
31323124
var $t = jQuery( this );
31333125
assert.step( $t.data( "elt" ) );
@@ -3139,15 +3131,11 @@ QUnit.test( "should handle custom '_se-custom-destroy' event correctly", functio
31393131

31403132
// Attach an empty handler to trigger the `remove`
31413133
// logic for the custom event when the element is removed.
3134+
jQuery( ".guarded" ).on( "removeondestroy", function( ) { } );
31423135

3143-
jQuery( ".guarded" ).on( "_se-custom-destroy", function( ) { } );
3144-
3145-
// Trigger the event by emptying the container
3146-
3136+
// Trigger the event's removal logic by emptying the container
31473137
jQuery( "#container" ).empty();
31483138

3149-
// Verify the steps to ensure the expected elements were processed
3150-
3151-
assert.verifySteps( [ "one", "two", "three" ], "Steps should match the data-elt attributes" );
3139+
assert.verifySteps( [ "one", "two", "three" ], "All elements were processed in order" );
31523140
} );
31533141

0 commit comments

Comments
 (0)