@@ -3974,7 +3974,7 @@ describe('input', function() {
3974
3974
3975
3975
describe ( 'radio' , function ( ) {
3976
3976
3977
- it ( 'should update the model' , function ( ) {
3977
+ they ( 'should update the model on $prop event ' , [ 'click' , 'change' ] , function ( event ) {
3978
3978
var inputElm = helper . compileInput (
3979
3979
'<input type="radio" ng-model="color" value="white" />' +
3980
3980
'<input type="radio" ng-model="color" value="red" />' +
@@ -3990,7 +3990,8 @@ describe('input', function() {
3990
3990
expect ( inputElm [ 1 ] . checked ) . toBe ( true ) ;
3991
3991
expect ( inputElm [ 2 ] . checked ) . toBe ( false ) ;
3992
3992
3993
- browserTrigger ( inputElm [ 2 ] , 'click' ) ;
3993
+ if ( event === 'change' ) inputElm [ 2 ] . checked = true ;
3994
+ browserTrigger ( inputElm [ 2 ] , event ) ;
3994
3995
expect ( $rootScope . color ) . toBe ( 'blue' ) ;
3995
3996
} ) ;
3996
3997
@@ -4092,6 +4093,23 @@ describe('input', function() {
4092
4093
} ) ;
4093
4094
4094
4095
4096
+ they ( 'should update the model on $prop event' , [ 'click' , 'change' ] , function ( event ) {
4097
+ var inputElm = helper . compileInput ( '<input type="checkbox" ng-model="checkbox" />' ) ;
4098
+
4099
+ expect ( inputElm [ 0 ] . checked ) . toBe ( false ) ;
4100
+
4101
+ $rootScope . $apply ( 'checkbox = true' ) ;
4102
+ expect ( inputElm [ 0 ] . checked ) . toBe ( true ) ;
4103
+
4104
+ $rootScope . $apply ( 'checkbox = false' ) ;
4105
+ expect ( inputElm [ 0 ] . checked ) . toBe ( false ) ;
4106
+
4107
+ if ( event === 'change' ) inputElm [ 0 ] . checked = true ;
4108
+ browserTrigger ( inputElm [ 0 ] , event ) ;
4109
+ expect ( $rootScope . checkbox ) . toBe ( true ) ;
4110
+ } ) ;
4111
+
4112
+
4095
4113
it ( 'should format booleans' , function ( ) {
4096
4114
var inputElm = helper . compileInput ( '<input type="checkbox" ng-model="name" />' ) ;
4097
4115
0 commit comments