@@ -3964,7 +3964,7 @@ describe('$compile', function() {
39643964 expect ( componentScope . ref ) . toBe ( 'hello world' ) ;
39653965
39663966 componentScope . ref = 'ignore me' ;
3967- expect ( $rootScope . $apply ) .
3967+ expect ( function ( ) { $rootScope . $apply ( ) ; } ) .
39683968 toThrowMinErr ( "$compile" , "nonassign" , "Expression ''hello ' + name' used with directive 'myComponent' is non-assignable!" ) ;
39693969 expect ( componentScope . ref ) . toBe ( 'hello world' ) ;
39703970 // reset since the exception was rethrown which prevented phase clearing
@@ -3975,6 +3975,21 @@ describe('$compile', function() {
39753975 expect ( componentScope . ref ) . toBe ( 'hello misko' ) ;
39763976 } ) ) ;
39773977
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+
39783993 // regression
39793994 it ( 'should stabilize model' , inject ( function ( ) {
39803995 compile ( '<div><span my-component reference="name">' ) ;
0 commit comments