@@ -495,16 +495,16 @@ asyncTest("remote radio correct value sent", function() {
495
495
v . element ( e ) ;
496
496
} ) ;
497
497
498
- asyncTest ( "remote correct number of invalids" , function ( ) {
499
- expect ( 4 ) ;
498
+ asyncTest ( "remote reset clear old value" , function ( ) {
499
+ expect ( 1 ) ;
500
+
500
501
var e = $ ( "#username" ) ;
501
502
var v = $ ( "#userForm" ) . validate ( {
502
503
rules : {
503
504
username : {
504
505
required : true ,
505
506
remote : {
506
507
url : "echo.php" ,
507
- dataType : 'json' ,
508
508
dataFilter : function ( data ) {
509
509
var json = JSON . parse ( data ) ;
510
510
if ( json . username == 'asdf' ) {
@@ -514,33 +514,31 @@ asyncTest("remote correct number of invalids", function() {
514
514
}
515
515
}
516
516
}
517
- } ,
518
- messages : {
519
- username : {
520
- required : "Please"
521
- }
522
- } ,
523
- submitHandler : function ( ) {
524
- ok ( false , "submitHandler may never be called when validating only elements" ) ;
525
517
}
526
518
} ) ;
527
519
$ ( document ) . ajaxStop ( function ( ) {
520
+ var waitTimeout ;
521
+
528
522
$ ( document ) . unbind ( "ajaxStop" ) ;
529
- equal ( 1 , v . numberOfInvalids ( ) , "There must be one error" ) ;
530
523
531
- e . val ( "max" ) ;
532
524
533
525
$ ( document ) . ajaxStop ( function ( ) {
534
- equal ( 0 , v . numberOfInvalids ( ) , "There must not be any errors" ) ;
526
+ clearTimeout ( waitTimeout ) ;
527
+ ok ( true , "Remote request sent to server" ) ;
535
528
start ( ) ;
536
529
} ) ;
537
530
531
+
532
+ v . resetForm ( ) ;
533
+ e . val ( "asdf" ) ;
534
+ waitTimeout = setTimeout ( function ( ) {
535
+ ok ( false , "Remote server did not get request" ) ;
536
+ start ( ) ;
537
+ } , 200 ) ;
538
538
v . element ( e ) ;
539
539
} ) ;
540
- strictEqual ( v . element ( e ) , false , "invalid element, nothing entered yet" ) ;
541
540
e . val ( "asdf" ) ;
542
- strictEqual ( v . numberOfInvalids ( ) , 1 , "still invalid, because remote validation must block until it returns; dependency-mismatch considered as valid though" ) ;
543
- v . element ( e ) ;
541
+ v . element ( e ) ;
544
542
} ) ;
545
543
546
544
module ( "additional methods" ) ;
0 commit comments