diff options
author | Alexander Schmitz <arschmitz@gmail.com> | 2015-08-24 08:57:40 -0400 |
---|---|---|
committer | Alexander Schmitz <arschmitz@gmail.com> | 2015-09-11 08:29:07 -0400 |
commit | 23d0884e662b099095688db2c3d05a2d94688ceb (patch) | |
tree | 2e47a26fb3faaff8e69d2697237f017a2246d4bb /tests/unit/spinner/options.js | |
parent | 6c0bb249184e3ad6f8ce48509b5f9011313a57a3 (diff) | |
download | jquery-ui-23d0884e662b099095688db2c3d05a2d94688ceb.tar.gz jquery-ui-23d0884e662b099095688db2c3d05a2d94688ceb.zip |
Spinner: Style updates
Ref #14246
Diffstat (limited to 'tests/unit/spinner/options.js')
-rw-r--r-- | tests/unit/spinner/options.js | 98 |
1 files changed, 49 insertions, 49 deletions
diff --git a/tests/unit/spinner/options.js b/tests/unit/spinner/options.js index c3a9f74a2..8ad5caeaa 100644 --- a/tests/unit/spinner/options.js +++ b/tests/unit/spinner/options.js @@ -20,43 +20,43 @@ test( "icons: default ", function( assert ) { element.spinner( "option", "icons", { up: "ui-icon-caret-1-n", down: "ui-icon-caret-1-s" - }); + } ); assert.hasClasses( element.spinner( "widget" ).find( ".ui-icon:first" ), "ui-icon ui-icon-caret-1-n" ); assert.hasClasses( element.spinner( "widget" ).find( ".ui-icon:last" ), "ui-icon ui-icon-caret-1-s" ); -}); +} ); test( "icons: custom ", function( assert ) { expect( 2 ); - var element = $( "#spin" ).val( 0 ).spinner({ + var element = $( "#spin" ).val( 0 ).spinner( { icons: { down: "custom-down", up: "custom-up" } - }).spinner( "widget" ); + } ).spinner( "widget" ); assert.hasClasses( element.find( ".ui-icon:first" ), "ui-icon custom-up" ); assert.hasClasses( element.find( ".ui-icon:last" ), "ui-icon custom-down" ); -}); +} ); test( "incremental, false", function() { expect( 100 ); var i, prev = 0, - element = $( "#spin" ).val( prev ).spinner({ + element = $( "#spin" ).val( prev ).spinner( { incremental: false, spin: function( event, ui ) { equal( ui.value - prev, 1 ); prev = ui.value; } - }); + } ); for ( i = 0; i < 100; i++ ) { element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } ); } element.simulate( "keyup", { keyCode: $.ui.keyCode.UP } ); -}); +} ); test( "incremental, true", function() { expect( 100 ); @@ -64,7 +64,7 @@ test( "incremental, true", function() { function fill( num, val ) { return $.map( new Array( num ), function() { return val; - }); + } ); } var i, @@ -72,26 +72,26 @@ test( "incremental, true", function() { expected = [].concat( fill( 18, 1 ), fill( 37, 2 ), fill( 14, 3 ), fill( 9, 4 ), fill( 6, 5 ), fill( 5, 6 ), fill ( 5, 7 ), fill( 4, 8 ), fill( 2, 9 ) ), - element = $( "#spin" ).val( prev ).spinner({ + element = $( "#spin" ).val( prev ).spinner( { incremental: true, spin: function( event, ui ) { equal( ui.value - prev, expected[ i ] ); prev = ui.value; } - }); + } ); for ( i = 0; i < 100; i++ ) { element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } ); } element.simulate( "keyup", { keyCode: $.ui.keyCode.UP } ); -}); +} ); test( "incremental, function", function() { expect( 100 ); var i, prev = 0, - element = $( "#spin" ).val( prev ).spinner({ + element = $( "#spin" ).val( prev ).spinner( { incremental: function( i ) { return i; }, @@ -99,83 +99,83 @@ test( "incremental, function", function() { equal( ui.value - prev, i + 1 ); prev = ui.value; } - }); + } ); for ( i = 0; i < 100; i++ ) { element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } ); } element.simulate( "keyup", { keyCode: $.ui.keyCode.UP } ); -}); +} ); test( "numberFormat, number", function() { expect( 2 ); - var element = $( "#spin" ).val( 0 ).spinner({ numberFormat: "n" }); + var element = $( "#spin" ).val( 0 ).spinner( { numberFormat: "n" } ); equal( element.val(), "0.00", "formatted on init" ); element.spinner( "stepUp" ); equal( element.val(), "1.00", "formatted after step" ); -}); +} ); test( "numberFormat, number, simple", function() { expect( 2 ); - var element = $( "#spin" ).val( 0 ).spinner({ numberFormat: "n0" }); + var element = $( "#spin" ).val( 0 ).spinner( { numberFormat: "n0" } ); equal( element.val(), "0", "formatted on init" ); element.spinner( "stepUp" ); equal( element.val(), "1", "formatted after step" ); -}); +} ); test( "numberFormat, currency", function() { expect( 2 ); - var element = $( "#spin" ).val( 0 ).spinner({ numberFormat: "C" }); + var element = $( "#spin" ).val( 0 ).spinner( { numberFormat: "C" } ); equal( element.val(), "$0.00", "formatted on init" ); element.spinner( "stepUp" ); equal( element.val(), "$1.00", "formatted after step" ); -}); +} ); test( "numberFormat, change", function() { expect( 2 ); - var element = $( "#spin" ).val( 5 ).spinner({ numberFormat: "n1" }); + var element = $( "#spin" ).val( 5 ).spinner( { numberFormat: "n1" } ); equal( element.val(), "5.0", "formatted on init" ); element.spinner( "option", "numberFormat", "c" ); equal( element.val(), "$5.00", "formatted after change" ); -}); +} ); test( "culture, null", function() { expect( 2 ); Globalize.culture( "ja-JP" ); - var element = $( "#spin" ).val( 0 ).spinner({ numberFormat: "C" }); + var element = $( "#spin" ).val( 0 ).spinner( { numberFormat: "C" } ); equal( element.val(), "¥0", "formatted on init" ); element.spinner( "stepUp" ); equal( element.val(), "¥1", "formatted after step" ); // Reset culture Globalize.culture( "default" ); -}); +} ); test( "currency, ja-JP", function() { expect( 2 ); - var element = $( "#spin" ).val( 0 ).spinner({ + var element = $( "#spin" ).val( 0 ).spinner( { numberFormat: "C", culture: "ja-JP" - }); + } ); equal( element.val(), "¥0", "formatted on init" ); element.spinner( "stepUp" ); equal( element.val(), "¥1", "formatted after step" ); -}); +} ); test( "currency, change", function() { expect( 2 ); - var element = $( "#spin" ).val( 5 ).spinner({ + var element = $( "#spin" ).val( 5 ).spinner( { numberFormat: "C", culture: "ja-JP" - }); + } ); equal( element.val(), "¥5", "formatted on init" ); element.spinner( "option", "culture", "en" ); equal( element.val(), "$5.00", "formatted after change" ); -}); +} ); test( "max", function() { expect( 3 ); - var element = $( "#spin" ).val( 1000 ).spinner({ max: 100 }); + var element = $( "#spin" ).val( 1000 ).spinner( { max: 100 } ); equal( element.val(), 1000, "value not constrained on init" ); element.spinner( "value", 1000 ); @@ -183,27 +183,27 @@ test( "max", function() { element.val( 1000 ).trigger( "blur" ); equal( element.val(), 1000, "max not constrained if manual entry" ); -}); +} ); test( "max, string", function() { expect( 3 ); var element = $( "#spin" ) .val( 1000 ) - .spinner({ + .spinner( { max: "$100.00", numberFormat: "C", culture: "en" - }); + } ); equal( element.val(), "$1,000.00", "value not constrained on init" ); equal( element.spinner( "option", "max" ), 100, "option converted to number" ); element.spinner( "value", 1000 ); equal( element.val(), "$100.00", "max constrained in value method" ); -}); +} ); test( "min", function() { expect( 3 ); - var element = $( "#spin" ).val( -1000 ).spinner({ min: -100 }); + var element = $( "#spin" ).val( -1000 ).spinner( { min: -100 } ); equal( element.val(), -1000, "value not constrained on init" ); element.spinner( "value", -1000 ); @@ -211,27 +211,27 @@ test( "min", function() { element.val( -1000 ).trigger( "blur" ); equal( element.val(), -1000, "min not constrained if manual entry" ); -}); +} ); test( "min, string", function() { expect( 3 ); var element = $( "#spin" ) .val( -1000 ) - .spinner({ + .spinner( { min: "-$100.00", numberFormat: "C", culture: "en" - }); + } ); equal( element.val(), "($1,000.00)", "value not constrained on init" ); equal( element.spinner( "option", "min" ), -100, "option converted to number" ); element.spinner( "value", -1000 ); equal( element.val(), "($100.00)", "min constrained in value method" ); -}); +} ); test( "step, 2", function() { expect( 3 ); - var element = $( "#spin" ).val( 0 ).spinner({ step: 2 }); + var element = $( "#spin" ).val( 0 ).spinner( { step: 2 } ); element.spinner( "stepUp" ); equal( element.val(), "2", "stepUp" ); @@ -242,30 +242,30 @@ test( "step, 2", function() { element.val( "4.5" ); element.spinner( "stepUp" ); equal( element.val(), "6", "stepUp" ); -}); +} ); test( "step, 0.7", function() { expect( 1 ); - var element = $("#spin").val( 0 ).spinner({ + var element = $( "#spin" ).val( 0 ).spinner( { step: 0.7 - }); + } ); element.spinner( "stepUp" ); equal( element.val(), "0.7", "stepUp" ); -}); +} ); test( "step, string", function() { expect( 2 ); - var element = $("#spin").val( 0 ).spinner({ + var element = $( "#spin" ).val( 0 ).spinner( { step: "$0.70", numberFormat: "C", culture: "en" - }); + } ); equal( element.spinner( "option", "step" ), 0.7, "option converted to number" ); element.spinner( "stepUp" ); equal( element.val(), "$0.70", "stepUp" ); -}); +} ); } ); |