diff options
author | Scott González <scott.gonzalez@gmail.com> | 2011-08-07 08:10:11 -0400 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2011-08-07 08:10:11 -0400 |
commit | 380c2e6fbdba524c56855e9c9018b6bf89225c50 (patch) | |
tree | 9bdcf068a4b0c3fe0d043c8ff6188c343be51a23 /tests/unit/spinner/spinner_options.js | |
parent | e9cdd576f4327f947b00032b6d1aaa60c305c844 (diff) | |
download | jquery-ui-380c2e6fbdba524c56855e9c9018b6bf89225c50.tar.gz jquery-ui-380c2e6fbdba524c56855e9c9018b6bf89225c50.zip |
Spinner tests: Cleanup.
Diffstat (limited to 'tests/unit/spinner/spinner_options.js')
-rw-r--r-- | tests/unit/spinner/spinner_options.js | 134 |
1 files changed, 51 insertions, 83 deletions
diff --git a/tests/unit/spinner/spinner_options.js b/tests/unit/spinner/spinner_options.js index 2cb90ef5d..33a7c1978 100644 --- a/tests/unit/spinner/spinner_options.js +++ b/tests/unit/spinner/spinner_options.js @@ -1,32 +1,32 @@ -/*
- * spinner_options.js
- */
-(function($) {
+(function( $ ) {
-module("spinner: options");
+module( "spinner: options" );
-test("numberFormat, number", function() {
- var el = $("#spin").spinner({
+test( "numberFormat, number", function() {
+ expect( 1 );
+ var element = $( "#spin" ).spinner({
value: "1",
numberFormat: "n"
});
- equal(el.val(), "1.00");
+ equal( element.val(), "1.00", "n" );
});
-test("numberFormat, number, simple", function() {
- var el = $("#spin").spinner({
+test( "numberFormat, number, simple", function() {
+ expect( 1 );
+ var element = $( "#spin" ).spinner({
value: "1",
numberFormat: "n0"
});
- equal(el.val(), "1");
+ equal( element.val(), "1", "n0" );
});
-test("numberFormat, currency", function() {
- var el = $("#spin").spinner({
+test( "numberFormat, currency", function() {
+ expect( 1 );
+ var element = $( "#spin" ).spinner({
value: "1",
numberFormat: "C"
});
- equal(el.val(), "$1.00");
+ equal( element.val(), "$1.00", "C" );
});
/* TODO figure out how to test this properly
@@ -67,88 +67,56 @@ test("incremental - true (default)", function() { });
*/
-test("max", function() {
- var el = $("#spin").spinner({ max: 100, value: 1000 });
- equals(el.val(), 100, "max constrained if value option is greater");
-
- el.spinner('value', 1000);
- equals(el.val(), 100, "max constrained if value method is greater");
-
- el.val(1000).blur();
- equals(el.val(), 100, "max constrained if manual entry");
-});
+test( "max", function() {
+ expect( 3 );
+ var element = $( "#spin" ).spinner({ max: 100, value: 1000 });
+ equals( element.val(), 100, "max constrained if value option is greater" );
+
+ element.spinner( "value", 1000 );
+ equals( element.val(), 100, "max constrained if value method is greater" );
-test("min", function() {
- var el = $("#spin").spinner({ min: -100, value: -1000 });
- equals(el.val(), -100, "min constrained if value option is greater");
-
- el.spinner('value', -1000);
- equals(el.val(), -100, "min constrained if value method is greater");
-
- el.val(-1000).blur();
- equals(el.val(), -100, "min constrained if manual entry");
+ element.val( 1000 ).blur();
+ equals( element.val(), 100, "max constrained if manual entry" );
});
-test("step, 2", function() {
- var el = $("#spin").spinner({ step: 2 });
- equals(el.val(), "0", "value initialized to");
-
- for ( var i = 0 ; i < 5 ; i++ ) {
- spinner_simulateKeyDownUp(el, $.ui.keyCode.UP);
- }
- equals(el.val(), "10", "UP 5 times with step: 2");
+test( "min", function() {
+ expect( 3 );
+ var element = $( "#spin" ).spinner({ min: -100, value: -1000 });
+ equals( element.val(), -100, "min constrained if value option is greater" );
- el.spinner('value', '10.5');
- equals(el.val(), "10.5", "value reset to");
+ element.spinner( "value", -1000 );
+ equals( element.val(), -100, "min constrained if value method is greater" );
- el.spinner('option', 'step', 2);
- for ( var i = 0 ; i < 5 ; i++ ) {
- spinner_simulateKeyDownUp(el, $.ui.keyCode.UP);
- }
- equals(el.val(), "20.5", "UP 5 times with step: 2");
+ element.val( -1000 ).blur();
+ equals( element.val(), -100, "min constrained if manual entry" );
});
-test("step, 0.7", function() {
- var el = $("#spin").spinner({
- step: 0.7,
- numberFormat: "n1"
- });
- equals(el.val(), "0.0", "value initialized to");
-
- spinner_simulateKeyDownUp(el, $.ui.keyCode.DOWN);
- equals(el.val(), "-0.7", "DOWN 1 time with step: 0.7");
+test( "step, 2", function() {
+ expect( 4 );
+ var element = $( "#spin" ).spinner({ step: 2 });
+ equals( element.val(), "0", "value initialized to 0" );
- for ( var i = 0 ; i < 11 ; i++ ) {
- spinner_simulateKeyDownUp(el, $.ui.keyCode.UP);
- }
- equals(el.val(), "7.0", "UP 11 times with step: 0.7");
-});
+ element.spinner( "stepUp" );
+ equals( element.val(), "2", "stepUp" );
-test("value, default, specified in markup", function() {
- var el = $('#spin2').spinner();
- equals(el.val(), 2, "starting value");
-});
+ element.spinner( "value", "10.5" );
+ equals( element.val(), "10.5", "value reset to 10.5" );
-test("value, default, nothing specified", function() {
- var el = $('#spin').spinner();
- equals(el.val(), 0, "starting value");
+ element.spinner( "stepUp" );
+ equals( element.val(), "12.5", "stepUp" );
});
-test("value, override", function() {
- var el = $('#spin').spinner({ value: 100 });
- equals(el.val(), 100, "starting value");
-});
+test( "step, 0.7", function() {
+ expect( 2 );
+ var element = $("#spin").spinner({
+ step: 0.7
+ });
+ equals( element.val(), "0", "value initialized to 0" );
-test("value, override markup", function() {
- var el = $('#spin2').spinner({ value: 100 });
- equals(el.val(), 100, "starting value");
+ element.spinner( "stepUp" );
+ equals( element.val(), "0.7", "stepUp" );
});
-test("value, override later", function() {
- var el = $('#spin').spinner();
- equals(el.val(), 0, "starting value");
- el.spinner('option', 'value', 1000);
- equals(el.val(), 1000, "value option changed and set as current value");
-});
+// TODO: test value
-})(jQuery);
+})( jQuery );
|