@@ -876,7 +876,7 @@ describe('input', function() {
876
876
} ) ;
877
877
878
878
879
- it ( 'should allow custom enumeration' , function ( ) {
879
+ it ( 'should allow custom string enumeration' , function ( ) {
880
880
compileInput ( '<input type="checkbox" ng-model="name" ng-true-value="y" ' +
881
881
'ng-false-value="n">' ) ;
882
882
@@ -902,6 +902,31 @@ describe('input', function() {
902
902
expect ( scope . name ) . toEqual ( 'n' ) ;
903
903
} ) ;
904
904
905
+ it ( 'should allow custom numerical enumeration' , function ( ) {
906
+ compileInput ( '<input type="checkbox" ng-model="name" ng-true-value="1" ' +
907
+ 'ng-false-value="0">' ) ;
908
+
909
+ scope . $apply ( function ( ) {
910
+ scope . name = 1 ;
911
+ } ) ;
912
+ expect ( inputElm [ 0 ] . checked ) . toBe ( true ) ;
913
+
914
+ scope . $apply ( function ( ) {
915
+ scope . name = 0 ;
916
+ } ) ;
917
+ expect ( inputElm [ 0 ] . checked ) . toBe ( false ) ;
918
+
919
+ scope . $apply ( function ( ) {
920
+ scope . name = 'something else' ;
921
+ } ) ;
922
+ expect ( inputElm [ 0 ] . checked ) . toBe ( false ) ;
923
+
924
+ browserTrigger ( inputElm , 'click' ) ;
925
+ expect ( scope . name ) . toEqual ( 1 ) ;
926
+
927
+ browserTrigger ( inputElm , 'click' ) ;
928
+ expect ( scope . name ) . toEqual ( 0 ) ;
929
+ } ) ;
905
930
906
931
it ( 'should be required if false' , function ( ) {
907
932
compileInput ( '<input type="checkbox" ng:model="value" required />' ) ;
0 commit comments