diff options
author | Gabriel Schulhof <gabriel.schulhof@intel.com> | 2016-06-14 17:47:09 +0300 |
---|---|---|
committer | Alexander Schmitz <arschmitz@gmail.com> | 2016-07-06 09:42:31 -0400 |
commit | 3a9a3c7c5bfa8d5695c74385e34d3f4cbb06472b (patch) | |
tree | 60cd8584b6bc37cd17d5a3f9df7ecbf266eb4f7d /tests | |
parent | 23d1db58458cd6e33aaf45cbd078328a8a1cf8bf (diff) | |
download | jquery-ui-3a9a3c7c5bfa8d5695c74385e34d3f4cbb06472b.tar.gz jquery-ui-3a9a3c7c5bfa8d5695c74385e34d3f4cbb06472b.zip |
Controlgroup: Correctly handle non-empty child class key
Fixes #14984
Closes gh-1713
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/controlgroup/controlgroup.html | 16 | ||||
-rw-r--r-- | tests/unit/controlgroup/core.js | 37 |
2 files changed, 53 insertions, 0 deletions
diff --git a/tests/unit/controlgroup/controlgroup.html b/tests/unit/controlgroup/controlgroup.html index d90bf607c..db1d47808 100644 --- a/tests/unit/controlgroup/controlgroup.html +++ b/tests/unit/controlgroup/controlgroup.html @@ -68,6 +68,22 @@ <div class="controlgroup-single-button"> <button class="single-button">button</button> </div> + <div class="controlgroup-class-key-init"> + <select id="class-key-init-child"> + <option>Option 1</option> + <option>Option 2</option> + </select> + </div> + <div class="controlgroup-class-key-dupe"> + <select id="class-key-dupe-first"> + <option>Option 1</option> + <option>Option 2</option> + </select> + <select id="class-key-dupe-second"> + <option>Option 1</option> + <option>Option 2</option> + </select> + </div> </div> </body> </html> diff --git a/tests/unit/controlgroup/core.js b/tests/unit/controlgroup/core.js index dff3b1b12..789eefc90 100644 --- a/tests/unit/controlgroup/core.js +++ b/tests/unit/controlgroup/core.js @@ -160,4 +160,41 @@ QUnit.test( "Single controlgroup button - vertical", function( assert ) { " ui-corner-tr ui-corner-tl ui-corner-bl ui corner-br" ); } ); +QUnit.module( "Controlgroup: Non-empty class key", { + setup: function() { + this.classKey = $.ui.selectmenu.prototype.options.classes[ "ui-selectmenu-button-closed" ]; + $.ui.selectmenu.prototype.options.classes[ "ui-selectmenu-button-closed" ] = + "something-custom"; + }, + teardown: function() { + $.ui.selectmenu.prototype.options.classes[ "ui-selectmenu-button-closed" ] = this.classKey; + } +} ); + +QUnit.test( "Controlgroup instantiates child widgets with correct options", function( assert ) { + assert.expect( 1 ); + + $( ".controlgroup-class-key-init" ).controlgroup(); + + assert.hasClasses( $( "#class-key-init-child" ).next(), "something-custom" ); +} ); + +QUnit.test( "Controlgroup correctly assigns child widget classes options key", function( assert ) { + assert.expect( 2 ); + + $( ".controlgroup-class-key-dupe" ).controlgroup(); + + assert.strictEqual( + ( $( "#class-key-dupe-first" ) + .selectmenu( "option", "classes.ui-selectmenu-button-closed" ) + .match( /something-custom/g ) || [] ).length, 1, + "Class 'something-custom' appears exactly once in the first widget's class key value" ); + + assert.strictEqual( + ( $( "#class-key-dupe-second" ) + .selectmenu( "option", "classes.ui-selectmenu-button-closed" ) + .match( /something-custom/g ) || [] ).length, 1, + "Class 'something-custom' appears exactly once in the second widget's class key value" ); +} ); + } ); |