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