diff options
Diffstat (limited to 'tests/unit/spinner')
-rw-r--r-- | tests/unit/spinner/all.html | 2 | ||||
-rw-r--r-- | tests/unit/spinner/spinner.html | 19 | ||||
-rw-r--r-- | tests/unit/spinner/spinner_defaults.js | 1 | ||||
-rw-r--r-- | tests/unit/spinner/spinner_options.js | 47 |
4 files changed, 62 insertions, 7 deletions
diff --git a/tests/unit/spinner/all.html b/tests/unit/spinner/all.html index 17ae4d164..e6e329fad 100644 --- a/tests/unit/spinner/all.html +++ b/tests/unit/spinner/all.html @@ -4,7 +4,7 @@ <meta charset="utf-8"> <title>jQuery UI Spinner Test Suite</title> - <script src="../../../jquery-1.6.2.js"></script> + <script src="../../../jquery-1.7.js"></script> <link rel="stylesheet" href="../../../external/qunit.css"> <link rel="stylesheet" href="../subsuiteRunner.css"> diff --git a/tests/unit/spinner/spinner.html b/tests/unit/spinner/spinner.html index ddfb03d91..0c01a5f48 100644 --- a/tests/unit/spinner/spinner.html +++ b/tests/unit/spinner/spinner.html @@ -4,15 +4,22 @@ <meta charset="utf-8"> <title>jQuery UI Spinner Test Suite</title> - <link rel="stylesheet" href="../../../themes/base/jquery.ui.spinner.css"> - <script src="../../jquery.js"></script> <script src="../../../external/jquery.mousewheel-3.0.4.js"></script> <script src="../../../external/globalize.js"></script> - <script src="../../../ui/jquery.ui.core.js"></script> - <script src="../../../ui/jquery.ui.widget.js"></script> - <script src="../../../ui/jquery.ui.button.js"></script> - <script src="../../../ui/jquery.ui.spinner.js"></script> + <script src="../../../external/globalize.culture.ja-JP.js"></script> + <script src="../../resource_loader.js"></script> + <script> + loadResources({ + css: [ "ui.core", "ui.button", "ui.spinner" ], + js: [ + "ui/jquery.ui.core.js", + "ui/jquery.ui.widget.js", + "ui/jquery.ui.button.js", + "ui/jquery.ui.spinner.js" + ] + }); + </script> <link rel="stylesheet" href="../../../external/qunit.css"> <script src="../../../external/qunit.js"></script> diff --git a/tests/unit/spinner/spinner_defaults.js b/tests/unit/spinner/spinner_defaults.js index 3321f8733..0a4e7c236 100644 --- a/tests/unit/spinner/spinner_defaults.js +++ b/tests/unit/spinner/spinner_defaults.js @@ -1,5 +1,6 @@ commonWidgetTests( "spinner", { defaults: { + culture: null, disabled: false, incremental: true, max: null, diff --git a/tests/unit/spinner/spinner_options.js b/tests/unit/spinner/spinner_options.js index 2b557cb69..81f434fc6 100644 --- a/tests/unit/spinner/spinner_options.js +++ b/tests/unit/spinner/spinner_options.js @@ -2,6 +2,8 @@ module( "spinner: options" ); +// culture is tested after numberFormat, since it depends on numberFormat + test( "incremental, false", function() { expect( 100 ); @@ -18,6 +20,7 @@ test( "incremental, false", function() { for ( i = 0; i < 100; i++ ) { element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } ); } + element.simulate( "keyup", { keyCode: $.ui.keyCode.UP } ); }); test( "incremental, true", function() { @@ -45,6 +48,7 @@ test( "incremental, true", function() { for ( i = 0; i < 100; i++ ) { element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } ); } + element.simulate( "keyup", { keyCode: $.ui.keyCode.UP } ); }); test( "incremental, function", function() { @@ -65,6 +69,7 @@ test( "incremental, function", function() { for ( i = 0; i < 100; i++ ) { element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } ); } + element.simulate( "keyup", { keyCode: $.ui.keyCode.UP } ); }); test( "numberFormat, number", function() { @@ -91,6 +96,48 @@ test( "numberFormat, currency", function() { equal( element.val(), "$1.00", "formatted after step" ); }); +test( "numberFormat, change", function() { + expect( 2 ); + 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" }); + 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({ + 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({ + 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 }); |