@@ -42,18 +42,30 @@ describe('event directives', function() {
42
42
43
43
describe ( 'focus' , function ( ) {
44
44
45
- it ( 'should call the listener asynchronously during $apply' ,
46
- inject ( function ( $rootScope , $compile ) {
47
- element = $compile ( '<input type="text" ng-focus="focus()">' ) ( $rootScope ) ;
48
- $rootScope . focus = jasmine . createSpy ( 'focus' ) ;
45
+ describe ( 'call the listener asynchronously during $apply' , function ( ) {
46
+ function run ( scope ) {
47
+ inject ( function ( $compile ) {
48
+ element = $compile ( '<input type="text" ng-focus="focus()">' ) ( scope ) ;
49
+ scope . focus = jasmine . createSpy ( 'focus' ) ;
49
50
50
- $rootScope . $apply ( function ( ) {
51
- element . triggerHandler ( 'focus' ) ;
52
- expect ( $rootScope . focus ) . not . toHaveBeenCalled ( ) ;
53
- } ) ;
51
+ scope . $apply ( function ( ) {
52
+ element . triggerHandler ( 'focus' ) ;
53
+ expect ( scope . focus ) . not . toHaveBeenCalled ( ) ;
54
+ } ) ;
54
55
55
- expect ( $rootScope . focus ) . toHaveBeenCalledOnce ( ) ;
56
- } ) ) ;
56
+ expect ( scope . focus ) . toHaveBeenCalledOnce ( ) ;
57
+ } ) ;
58
+ }
59
+
60
+ it ( 'should call the listener with non isolate scopes' , inject ( function ( $rootScope ) {
61
+ run ( $rootScope . $new ( ) ) ;
62
+ } ) ) ;
63
+
64
+ it ( 'should call the listener with isolate scopes' , inject ( function ( $rootScope ) {
65
+ run ( $rootScope . $new ( true ) ) ;
66
+ } ) ) ;
67
+
68
+ } ) ;
57
69
58
70
it ( 'should call the listener synchronously inside of $apply if outside of $apply' ,
59
71
inject ( function ( $rootScope , $compile ) {
@@ -72,18 +84,30 @@ describe('event directives', function() {
72
84
73
85
describe ( 'blur' , function ( ) {
74
86
75
- it ( 'should call the listener asynchronously during $apply' ,
76
- inject ( function ( $rootScope , $compile ) {
77
- element = $compile ( '<input type="text" ng-blur="blur()">' ) ( $rootScope ) ;
78
- $rootScope . blur = jasmine . createSpy ( 'blur' ) ;
87
+ describe ( 'call the listener asynchronously during $apply' , function ( ) {
88
+ function run ( scope ) {
89
+ inject ( function ( $compile ) {
90
+ element = $compile ( '<input type="text" ng-blur="blur()">' ) ( scope ) ;
91
+ scope . blur = jasmine . createSpy ( 'blur' ) ;
79
92
80
- $rootScope . $apply ( function ( ) {
81
- element . triggerHandler ( 'blur' ) ;
82
- expect ( $rootScope . blur ) . not . toHaveBeenCalled ( ) ;
83
- } ) ;
93
+ scope . $apply ( function ( ) {
94
+ element . triggerHandler ( 'blur' ) ;
95
+ expect ( scope . blur ) . not . toHaveBeenCalled ( ) ;
96
+ } ) ;
84
97
85
- expect ( $rootScope . blur ) . toHaveBeenCalledOnce ( ) ;
86
- } ) ) ;
98
+ expect ( scope . blur ) . toHaveBeenCalledOnce ( ) ;
99
+ } ) ;
100
+ }
101
+
102
+ it ( 'should call the listener with non isolate scopes' , inject ( function ( $rootScope ) {
103
+ run ( $rootScope . $new ( ) ) ;
104
+ } ) ) ;
105
+
106
+ it ( 'should call the listener with isolate scopes' , inject ( function ( $rootScope ) {
107
+ run ( $rootScope . $new ( true ) ) ;
108
+ } ) ) ;
109
+
110
+ } ) ;
87
111
88
112
it ( 'should call the listener synchronously inside of $apply if outside of $apply' ,
89
113
inject ( function ( $rootScope , $compile ) {
0 commit comments