diff options
author | Scott González <scott.gonzalez@gmail.com> | 2012-05-25 16:51:51 -0400 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2012-05-25 16:51:51 -0400 |
commit | 3b7c33fd496d8db82a71158f3663d52e3dc3c4ac (patch) | |
tree | b3c28a9556bd8f73621431897bdc3a7200870981 /tests/unit/testsuite.js | |
parent | be784b2f79e6f70a8b02d4ae7834d5081d8993c6 (diff) | |
download | jquery-ui-3b7c33fd496d8db82a71158f3663d52e3dc3c4ac.tar.gz jquery-ui-3b7c33fd496d8db82a71158f3663d52e3dc3c4ac.zip |
Tests: Added several more property checks to domEqual().
Diffstat (limited to 'tests/unit/testsuite.js')
-rw-r--r-- | tests/unit/testsuite.js | 54 |
1 files changed, 39 insertions, 15 deletions
diff --git a/tests/unit/testsuite.js b/tests/unit/testsuite.js index 33a9a2c99..bf17627f9 100644 --- a/tests/unit/testsuite.js +++ b/tests/unit/testsuite.js @@ -138,32 +138,56 @@ TestHelpers.commonWidgetTests = function( widget, settings ) { /* * Experimental assertion for comparing DOM objects. * - * Serializes an element and some attributes and it's children if any, otherwise the text. + * Serializes an element and some properties and it's children if any, otherwise the text. * Then compares the result using deepEqual. */ window.domEqual = function( selector, modifier, message ) { var expected, actual, - attributes = ["class", "role", "id", "tabIndex", "aria-activedescendant"]; - - function extract(value) { - if (!value || !value.length) { - QUnit.push( false, actual, expected, "domEqual failed, can't extract " + selector + ", message was: " + message ); + properties = [ + "autocomplete", + "aria-activedescendant", + "aria-controls", + "aria-describedby", + "aria-disabled", + "aria-expanded", + "aria-haspopup", + "aria-hidden", + "aria-labelledby", + "aria-pressed", + "aria-selected", + "aria-valuemax", + "aria-valuemin", + "aria-valuenow", + "class", + "disabled", + "href", + "id", + "nodeName", + "readOnly", + "role", + "tabIndex", + "title" + ]; + + function extract( elem ) { + if ( !elem || !elem.length ) { + QUnit.push( false, actual, expected, + "domEqual failed, can't extract " + selector + ", message was: " + message ); return; } + var children, result = {}; - result.nodeName = value[0].nodeName; - $.each(attributes, function(index, attr) { - result[attr] = value.prop(attr); + $.each( properties, function( index, attr ) { + result[ attr ] = elem.prop( attr ); }); - result.children = []; - children = value.children(); - if (children.length) { - children.each(function() { - result.children.push(extract($(this))); + children = elem.children(); + if ( children.length ) { + result.children = elem.children().map(function( ind ) { + return extract( $( this ) ); }); } else { - result.text = value.text(); + result.text = elem.text(); } return result; } |