@@ -3953,7 +3953,7 @@ describe('$compile', function() {
3953
3953
expect ( componentScope . ref ) . toBe ( 'hello world' ) ;
3954
3954
3955
3955
componentScope . ref = 'ignore me' ;
3956
- expect ( $rootScope . $apply ) .
3956
+ expect ( function ( ) { $rootScope . $apply ( ) ; } ) .
3957
3957
toThrowMinErr ( "$compile" , "nonassign" , "Expression ''hello ' + name' used with directive 'myComponent' is non-assignable!" ) ;
3958
3958
expect ( componentScope . ref ) . toBe ( 'hello world' ) ;
3959
3959
// reset since the exception was rethrown which prevented phase clearing
@@ -3964,6 +3964,21 @@ describe('$compile', function() {
3964
3964
expect ( componentScope . ref ) . toBe ( 'hello misko' ) ;
3965
3965
} ) ) ;
3966
3966
3967
+ it ( 'should complain if assigning to undefined' , inject ( function ( ) {
3968
+ compile ( '<div><span my-component>' ) ;
3969
+ $rootScope . $apply ( ) ;
3970
+ expect ( componentScope . ref ) . toBeUndefined ( ) ;
3971
+
3972
+ componentScope . ref = 'ignore me' ;
3973
+ expect ( function ( ) { $rootScope . $apply ( ) ; } ) .
3974
+ toThrowMinErr ( "$compile" , "nonassign" , "Expression 'undefined' used with directive 'myComponent' is non-assignable!" ) ;
3975
+ expect ( componentScope . ref ) . toBeUndefined ( ) ;
3976
+
3977
+ $rootScope . $$phase = null ; // reset since the exception was rethrown which prevented phase clearing
3978
+ $rootScope . $apply ( ) ;
3979
+ expect ( componentScope . ref ) . toBeUndefined ( ) ;
3980
+ } ) ) ;
3981
+
3967
3982
// regression
3968
3983
it ( 'should stabilize model' , inject ( function ( ) {
3969
3984
compile ( '<div><span my-component reference="name">' ) ;
0 commit comments