aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJörn Zaefferer <joern.zaefferer@gmail.com>2013-09-11 22:00:27 +0200
committerJörn Zaefferer <joern.zaefferer@gmail.com>2013-09-13 00:16:31 +0200
commit1552fc8a05ad351650b2a56c5c31905c671f1cdf (patch)
tree23f11b203b629b98456037a62ef1737dbf19309f /tests
parent6e799c39d33be8eee02224d2f754dc42228a4cbb (diff)
downloadjquery-ui-1552fc8a05ad351650b2a56c5c31905c671f1cdf.tar.gz
jquery-ui-1552fc8a05ad351650b2a56c5c31905c671f1cdf.zip
Spinner: Add isValid method. Fixes #9542 - Spinner: Add isValid() method
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/spinner/spinner_methods.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/unit/spinner/spinner_methods.js b/tests/unit/spinner/spinner_methods.js
index 4f44a73ae..41c991be3 100644
--- a/tests/unit/spinner/spinner_methods.js
+++ b/tests/unit/spinner/spinner_methods.js
@@ -73,6 +73,38 @@ test( "enable", function() {
equal( 2, element.val(), "keyboard - value changes on key UP" );
});
+test( "isValid", function() {
+ expect( 8 );
+ var element = $( "#spin" ).spinner({
+ min: 0,
+ max: 10,
+ step: 2
+ }),
+ spinner = element.spinner( "instance" );
+ ok( !spinner.isValid(), "initial state is invalid" );
+
+ element.val( "this is not a number" );
+ ok( !spinner.isValid(), "text string is not valid" );
+
+ element.val( "0" );
+ ok( spinner.isValid(), "min value is valid" );
+
+ element.val( "10" );
+ ok( spinner.isValid(), "max value is valid" );
+
+ element.val( "4" );
+ ok( spinner.isValid(), "inbetween step is valid" );
+
+ element.val( "-1" );
+ ok( !spinner.isValid(), "below min is invalid" );
+
+ element.val( "11" );
+ ok( !spinner.isValid(), "above max is invalid" );
+
+ element.val( "1" );
+ ok( !spinner.isValid(), "step mismatch is invalid" );
+});
+
test( "pageDown", function() {
expect( 4 );
var element = $( "#spin" ).val( -12 ).spinner({