Skip to content

Commit a7ac081

Browse files
authored
Tests: Make tests not trigger Migrate 4.0.0-beta.1 warnings
Changes: * Checkboxradio: Change `.attr( "checked", true )` to `.attr( "checked", "checked" ) * Selectmenu: Disable the `boolean-attributes` patch for one assertion where it's impossible to avoid Closes gh-2364
1 parent 73d0636 commit a7ac081

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

tests/unit/checkboxradio/options.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ QUnit.test( "icon - default unchecked", function( assert ) {
9797
} );
9898

9999
QUnit.test( "icon - default checked", function( assert ) {
100-
var checkbox = $( "#checkbox-option-icon" ).attr( "checked", true );
100+
var checkbox = $( "#checkbox-option-icon" ).attr( "checked", "checked" );
101101

102102
assert.expect( 2 );
103103

tests/unit/selectmenu/methods.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,25 @@ QUnit.test( "enable / disable", function( assert ) {
4141

4242
element.selectmenu( "disable" );
4343
assert.ok( element.selectmenu( "option", "disabled" ), "disable: widget option" );
44-
assert.ok( [ "disabled", "" ].indexOf( element.attr( "disabled" ) ) !== -1,
45-
"disable: native select disabled" );
44+
45+
// Migrate 4.x warns about reading boolean attributes when their
46+
// value is not their lowercase name - but that's what happens
47+
// when setting the `disabled` property to `true` first; the attribute
48+
// is then set to an empty string. Avoid the warning by temporarily
49+
// disabling the patch.
50+
// In real apps it's discouraged to mix `.prop()` & `.attr()` usage
51+
// for reflected property-attribute pairs.
52+
if ( $.migrateDisablePatches ) {
53+
$.migrateDisablePatches( "boolean-attributes" );
54+
}
55+
assert.ok(
56+
[ "disabled", "" ].indexOf( element.attr( "disabled" ) ) !== -1,
57+
"disable: native select disabled"
58+
);
59+
if ( $.migrateEnablePatches ) {
60+
$.migrateEnablePatches( "boolean-attributes" );
61+
}
62+
4663
assert.equal( button.attr( "aria-disabled" ), "true", "disable: button ARIA" );
4764
assert.equal( button.attr( "tabindex" ), -1, "disable: button tabindex" );
4865
assert.equal( menu.attr( "aria-disabled" ), "true", "disable: menu ARIA" );

0 commit comments

Comments
 (0)