]> source.dussan.org Git - jquery-ui.git/commitdiff
Tests: Properly check `$.uiBackCompat` in common widget tests
authorMichał Gołębiowski-Owczarek <m.goleb@gmail.com>
Mon, 9 Sep 2024 15:52:53 +0000 (17:52 +0200)
committerGitHub <noreply@github.com>
Mon, 9 Sep 2024 15:52:53 +0000 (17:52 +0200)
The "common widget" tests, checking if a widget doesn't overwrite some
core widget APIs wasn't running as it was incorrectly checking for
`$.uiBackCompat === false` instead of `$.uiBackCompat !== true` after the
default changed in gh-2250.

Fixing the check uncovered that the draggable & sortable modules do
overwrite the `_trigger` method. Add an exception in the test for that;
at this stage of the project we don't plan to change the implementation.

Closes gh-2286
Ref gh-2250

tests/lib/common.js

index 56b7a3ff389b6398bf3d70e9621073abba719b48..ba78fb6f630bec375c7cf17417a412aba1e5d7d9 100644 (file)
@@ -34,7 +34,7 @@ function testWidgetDefaults( widget, defaults ) {
 }
 
 function testWidgetOverrides( widget ) {
-       if ( $.uiBackCompat === false ) {
+       if ( $.uiBackCompat !== true ) {
                QUnit.test( "$.widget overrides", function( assert ) {
                        assert.expect( 4 );
                        $.each( [
@@ -43,8 +43,19 @@ function testWidgetOverrides( widget ) {
                                "option",
                                "_trigger"
                        ], function( i, method ) {
-                               assert.strictEqual( $.ui[ widget ].prototype[ method ],
-                                       $.Widget.prototype[ method ], "should not override " + method );
+
+                               if ( method === "_trigger" &&
+                                       /^(?:draggable|sortable): common widget$/
+                                               .test( assert.test.module.name ) ) {
+
+                                       // Draggable & sortable modules overwrite _trigger. They
+                                       // should not, but we don't plan to change the API at this
+                                       // stage of the project.
+                                       assert.ok( true, "draggable & sortable modules overwrite _trigger" );
+                               } else {
+                                       assert.strictEqual( $.ui[ widget ].prototype[ method ],
+                                               $.Widget.prototype[ method ], "should not override " + method );
+                               }
                        } );
                } );
        }