Skip to content
Permalink
Browse files

Draggable: Use new has/lacksClasses assertions for all class checks

  • Loading branch information
arschmitz committed Jan 30, 2015
1 parent a9fa490 commit 2d5857ca9e4bfc8b275dedf1dede6f3e0b732632
@@ -105,7 +105,7 @@ test( "enable/disable disabled", function( assert ) {
var element = $( "<div></div>" ).dialog();
element.dialog( "disable" );
equal(element.dialog( "option", "disabled" ), false, "disable method doesn't do anything" );
assert.lacksClasses( element, "ui-dialog-disabled ui-state-disabled" );
assert.lacksClasses( element, "ui-dialog-disabled ui-state-disabled", "disable method doesn't add classes" );
ok( !element.dialog( "widget" ).attr( "aria-disabled" ), "disable method doesn't add aria-disabled" );
});

@@ -68,6 +68,7 @@
<script src="../../../external/qunit/qunit.js"></script>
<script src="../../../external/jquery-simulate/jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script src="../../../external/qunit-assert-classes/qunit-assert-classes.js"></script>
<script>
TestHelpers.loadResources({
css: [ "core" ],
@@ -318,35 +318,34 @@ asyncTest( "blur behavior", function() {
});
});

test( "ui-draggable-handle assigned to appropriate element", function() {
test( "ui-draggable-handle assigned to appropriate element", function( assert ) {
expect( 5 );

var p = $( "<p>" ).appendTo( "#qunit-fixture" ),
element = $( "<div><p></p></div>" ).appendTo( "#qunit-fixture" ).draggable();
ok( element.hasClass( "ui-draggable-handle" ), "handle is element by default" );
assert.hasClasses( element, "ui-draggable-handle" );

element.draggable( "option", "handle", "p" );
ok( !element.hasClass( "ui-draggable-handle" ), "removed from element" );
ok( element.find( "p" ).hasClass( "ui-draggable-handle" ), "added to handle" );

ok( !p.hasClass( "ui-draggable-handle" ),
assert.lacksClasses( element, "ui-draggable-handle" );
assert.hasClasses( element.find( "p" ), "ui-draggable-handle",
"ensure handle class name is constrained within the draggble (#10212)" );
assert.lacksClasses( p, "ui-draggable-handle" );

element.draggable( "destroy" );
ok( !element.find( "p" ).hasClass( "ui-draggable-handle" ), "removed in destroy()" );
assert.lacksClasses( element.find( "p" ), "ui-draggable-handle" );
});

test( "ui-draggable-handle managed correctly in nested draggables", function() {
test( "ui-draggable-handle managed correctly in nested draggables", function( assert ) {
expect( 4 );
var parent = $( "<div><div></div></div>" ).draggable().appendTo( "#qunit-fixture" ),
child = parent.find( "div" ).draggable();

ok( parent.hasClass( "ui-draggable-handle" ), "parent has class name on init" );
ok( child.hasClass( "ui-draggable-handle" ), "child has class name on init" );
assert.hasClasses( parent, "ui-draggable-handle", "parent has class name on init" );
assert.hasClasses( child, "ui-draggable-handle", "child has class name on init" );

parent.draggable( "destroy" );
ok( !parent.hasClass( "ui-draggable-handle" ), "parent loses class name on destroy" );
ok( child.hasClass( "ui-draggable-handle" ), "child retains class name on destroy" );
assert.lacksClasses( parent, "ui-draggable-handle", "parent loses class name on destroy" );
assert.hasClasses( child, "ui-draggable-handle", "child retains class name on destroy" );
});

// http://bugs.jqueryui.com/ticket/7772
@@ -73,7 +73,7 @@ test( "enable", function() {
equal( actual, expected, "enable is chainable" );
});

test( "disable", function() {
test( "disable", function( assert ) {
expect( 14 );

element = $( "#draggable2" ).draggable({ disabled: false });
@@ -91,9 +91,9 @@ test( "disable", function() {
equal( element.draggable( "option", "disabled" ), true, "disabled option setter" );
TestHelpers.draggable.shouldNotDrag( element, ".draggable('option', 'disabled', true)" );

ok( !element.draggable( "widget" ).hasClass( "ui-state-disabled" ), "element does not get ui-state-disabled" );
assert.lacksClasses( element.draggable( "widget" ), "ui-state-disabled" );
ok( !element.draggable( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" );
ok( element.draggable( "widget" ).hasClass( "ui-draggable-disabled" ), "element gets ui-draggable-disabled" );
assert.hasClasses( element.draggable( "widget" ), "ui-draggable-disabled" );

var expected = element.draggable(),
actual = expected.draggable( "disable" );

0 comments on commit 2d5857c

Please sign in to comment.
You can’t perform that action at this time.