@@ -44,15 +44,16 @@ describe('event directives', function() {
44
44
45
45
it ( 'should call the listener asynchronously during $apply' ,
46
46
inject ( function ( $rootScope , $compile ) {
47
- element = $compile ( '<input type="text" ng-focus="focus()">' ) ( $rootScope ) ;
48
- $rootScope . focus = jasmine . createSpy ( 'focus' ) ;
47
+ var scope = $rootScope . $new ( true ) ;
48
+ element = $compile ( '<input type="text" ng-focus="focus()">' ) ( scope ) ;
49
+ scope . focus = jasmine . createSpy ( 'focus' ) ;
49
50
50
- $rootScope . $apply ( function ( ) {
51
+ scope . $apply ( function ( ) {
51
52
element . triggerHandler ( 'focus' ) ;
52
- expect ( $rootScope . focus ) . not . toHaveBeenCalled ( ) ;
53
+ expect ( scope . focus ) . not . toHaveBeenCalled ( ) ;
53
54
} ) ;
54
55
55
- expect ( $rootScope . focus ) . toHaveBeenCalledOnce ( ) ;
56
+ expect ( scope . focus ) . toHaveBeenCalledOnce ( ) ;
56
57
} ) ) ;
57
58
58
59
it ( 'should call the listener synchronously inside of $apply if outside of $apply' ,
@@ -74,15 +75,16 @@ describe('event directives', function() {
74
75
75
76
it ( 'should call the listener asynchronously during $apply' ,
76
77
inject ( function ( $rootScope , $compile ) {
77
- element = $compile ( '<input type="text" ng-blur="blur()">' ) ( $rootScope ) ;
78
- $rootScope . blur = jasmine . createSpy ( 'blur' ) ;
78
+ var scope = $rootScope . $new ( true ) ;
79
+ element = $compile ( '<input type="text" ng-blur="blur()">' ) ( scope ) ;
80
+ scope . blur = jasmine . createSpy ( 'blur' ) ;
79
81
80
- $rootScope . $apply ( function ( ) {
82
+ scope . $apply ( function ( ) {
81
83
element . triggerHandler ( 'blur' ) ;
82
- expect ( $rootScope . blur ) . not . toHaveBeenCalled ( ) ;
84
+ expect ( scope . blur ) . not . toHaveBeenCalled ( ) ;
83
85
} ) ;
84
86
85
- expect ( $rootScope . blur ) . toHaveBeenCalledOnce ( ) ;
87
+ expect ( scope . blur ) . toHaveBeenCalledOnce ( ) ;
86
88
} ) ) ;
87
89
88
90
it ( 'should call the listener synchronously inside of $apply if outside of $apply' ,
0 commit comments