aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAlexander Schmitz <arschmitz@gmail.com>2016-05-10 13:32:21 -0400
committerAlexander Schmitz <arschmitz@gmail.com>2016-05-26 09:15:48 -0400
commit04b670e6cc6b25ffe595c665ea86929f71f78b50 (patch)
tree25ad0a0b6ebc60a7725916193ec6118fe64a43b8 /tests
parent83ec5e8016dea46694e48027887c902ab9075b48 (diff)
downloadjquery-ui-04b670e6cc6b25ffe595c665ea86929f71f78b50.tar.gz
jquery-ui-04b670e6cc6b25ffe595c665ea86929f71f78b50.zip
Controlgroup: Don't remove existing classes classes
unless its a corner class Fixes #14960
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/controlgroup/controlgroup.html21
-rw-r--r--tests/unit/controlgroup/core.js25
-rw-r--r--tests/unit/controlgroup/methods.js23
3 files changed, 69 insertions, 0 deletions
diff --git a/tests/unit/controlgroup/controlgroup.html b/tests/unit/controlgroup/controlgroup.html
index 9767381ac..9983232ec 100644
--- a/tests/unit/controlgroup/controlgroup.html
+++ b/tests/unit/controlgroup/controlgroup.html
@@ -36,6 +36,27 @@
<option>Slow</option>
</select>
</div>
+ <select id="select-sanatize">
+ <option>Fast</option>
+ <option>Medium</option>
+ <option>Slow</option>
+ </select>
+ <div class="controlgroup-pre">
+ <select id="select-pre">
+ <option>Fast</option>
+ <option>Medium</option>
+ <option>Slow</option>
+ </select>
+ <button>Button with icon on the bottom</button>
+ </div>
+ <div class="controlgroup-refresh">
+ <select id="select-refresh">
+ <option>Fast</option>
+ <option>Medium</option>
+ <option>Slow</option>
+ </select>
+ <button>Button with icon on the bottom</button>
+ </div>
</div>
</body>
</html>
diff --git a/tests/unit/controlgroup/core.js b/tests/unit/controlgroup/core.js
index c1b1556aa..205633594 100644
--- a/tests/unit/controlgroup/core.js
+++ b/tests/unit/controlgroup/core.js
@@ -74,4 +74,29 @@ QUnit.test( "selectmenu: controlgroupLabel", function( assert ) {
assert.hasClasses( label.find( "span" ), "ui-controlgroup-label-contents" );
} );
+var assertSanatized = function( assert, initClasses, expectedClasses, message ) {
+ var selectmenu = $( "#select-sanatize" ).selectmenu({
+ classes: {
+ "ui-selectmenu-button-open": initClasses
+ }
+ }).selectmenu( "instance" );
+ var classes = {
+ "ui-selectmenu-button-open": "ui-corner-top"
+ };
+ var result = $.ui.controlgroup.prototype._resolveClassesValues( classes, selectmenu );
+ assert.deepEqual( result, {
+ "ui-selectmenu-button-open": expectedClasses + " ui-corner-top"
+ }, message );
+}
+
+QUnit.test( "_resolveClassesValues", function( assert ) {
+ assert.expect( 6 );
+ assertSanatized( assert, "bar ui-corner-bottom", "bar", "Single Corner Class Removed end" );
+ assertSanatized( assert, "ui-corner-bottom bar", "bar", "Single Corner Class Removed beginning" );
+ assertSanatized( assert, "bar ui-corner-bottom ui-corner-left", "bar", "Multiple Corner Class Removed end" );
+ assertSanatized( assert, "ui-corner-bottom ui-corner-left bar", "bar", "Multiple Corner Class Removed beginning" );
+ assertSanatized( assert, "bar ui-corner-bottom ui-corner-left foo", "bar foo", "Multiple Corner Class Removed Middle" );
+ assertSanatized( assert, "bar", "bar", "No corner Class" );
+} );
+
} );
diff --git a/tests/unit/controlgroup/methods.js b/tests/unit/controlgroup/methods.js
index 94f189747..9f1e4201e 100644
--- a/tests/unit/controlgroup/methods.js
+++ b/tests/unit/controlgroup/methods.js
@@ -148,4 +148,27 @@ $.each( tests, function( widget, html ) {
} );
} );
+QUnit.test( "Child Classes Option: init", function( assert ) {
+ assert.expect( 1 );
+ var selectmenu = $( "#select-pre" ).selectmenu( {
+ classes: {
+ "ui-selectmenu-button-closed": "test-class"
+ }
+ } );
+ var controlgroup = $( ".controlgroup-pre" ).controlgroup();
+ assert.hasClasses( selectmenu.selectmenu( "widget" ), "test-class" );
+} );
+
+QUnit.test( "Child Classes Option: refresh", function( assert ) {
+ assert.expect( 1 );
+ var controlgroup = $( ".controlgroup-refresh" ).controlgroup();
+ var selectmenu = $( "#select-refresh" ).selectmenu( {
+ classes: {
+ "ui-selectmenu-button-closed": "test-class"
+ }
+ } );
+ controlgroup.controlgroup( "refresh" );
+ assert.hasClasses( selectmenu.selectmenu( "widget" ), "test-class" );
+} );
+
} );