@@ -37,67 +37,60 @@ describe('Controller: uiLayoutCtrl', function () {
37
37
expect ( uic . isLayoutElement ( notUiEl ) ) . toEqual ( false ) ;
38
38
} ) ;
39
39
40
- describe ( 'mouseMoveHandler ' , function ( ) {
40
+ describe ( 'getMousePosition ' , function ( ) {
41
41
42
- var controller , jQueryWindow ;
42
+ var controller ;
43
43
44
44
beforeEach ( function ( ) {
45
-
46
- jQueryWindow = { } ;
47
-
48
- spyOn ( window , 'requestAnimationFrame' ) ;
49
-
50
45
controller = $controller ( 'uiLayoutCtrl' , {
51
46
$scope : scope ,
52
47
$attrs : { } ,
53
- $element : angular . element ( '<div></div>' ) ,
54
- $window : jQueryWindow
55
- } ) ;
48
+ $element : angular . element ( '<div></div>' ) } ) ;
56
49
} ) ;
57
50
58
- it ( 'should handle standard mouse event without exception ' , function ( ) {
51
+ it ( 'should handle standard mouse event' , function ( ) {
59
52
var mockMouseEvent = { } ;
60
53
mockMouseEvent [ controller . sizeProperties . mouseProperty ] = 0 ;
61
54
62
- controller . mouseMoveHandler ( mockMouseEvent ) ;
55
+ var result = controller . getMousePosition ( mockMouseEvent ) ;
63
56
64
- expect ( window . requestAnimationFrame ) . toHaveBeenCalled ( ) ;
57
+ expect ( result ) . toEqual ( 0 ) ;
65
58
} ) ;
66
59
67
- it ( 'should handle jQuery mouse event without exception' , function ( ) {
60
+ it ( 'should handle jQuery mouse event' , function ( ) {
61
+
68
62
var mockMouseEvent = {
69
63
originalEvent : { }
70
64
} ;
71
65
mockMouseEvent . originalEvent [ controller . sizeProperties . mouseProperty ] = 0 ;
72
66
73
- controller . mouseMoveHandler ( mockMouseEvent ) ;
74
-
75
- expect ( window . requestAnimationFrame ) . toHaveBeenCalled ( ) ;
67
+ var result = controller . getMousePosition ( mockMouseEvent ) ;
68
+
69
+ expect ( result ) . toEqual ( 0 ) ;
76
70
} ) ;
77
71
78
- it ( 'should handle standard touch event without exception' , function ( ) {
72
+ it ( 'should handle standard touch event' , function ( ) {
73
+
79
74
var mockMouseEvent = {
80
75
targetTouches : [ ]
81
76
} ;
82
77
mockMouseEvent . targetTouches [ 0 ] = { } ;
83
78
mockMouseEvent . targetTouches [ 0 ] [ controller . sizeProperties . mouseProperty ] = 0 ;
84
79
85
- controller . mouseMoveHandler ( mockMouseEvent ) ;
86
-
87
- expect ( window . requestAnimationFrame ) . toHaveBeenCalled ( ) ;
80
+ var result = controller . getMousePosition ( mockMouseEvent ) ;
81
+
82
+ expect ( result ) . toEqual ( 0 ) ;
88
83
} ) ;
89
84
90
- it ( 'should handle unrecognised standard event without exception ' , function ( ) {
85
+ it ( 'should handle unrecognised standard event' , function ( ) {
91
86
var mockMouseEvent = { } ;
92
87
93
- controller . mouseMoveHandler ( mockMouseEvent ) ;
88
+ var result = controller . getMousePosition ( mockMouseEvent ) ;
94
89
95
- expect ( window . requestAnimationFrame ) . not . toHaveBeenCalled ( ) ;
90
+ expect ( result ) . toEqual ( null ) ;
96
91
} ) ;
97
92
98
- it ( 'should handle jQuery touch event without exception' , function ( ) {
99
-
100
- jQueryWindow . jQuery = true ;
93
+ it ( 'should handle jQuery touch event' , function ( ) {
101
94
102
95
var mockMouseEvent = {
103
96
originalEvent : {
@@ -108,22 +101,20 @@ describe('Controller: uiLayoutCtrl', function () {
108
101
mockMouseEvent . originalEvent . targetTouches [ 0 ] = { } ;
109
102
mockMouseEvent . originalEvent . targetTouches [ 0 ] [ controller . sizeProperties . mouseProperty ] = 0 ;
110
103
111
- controller . mouseMoveHandler ( mockMouseEvent ) ;
112
-
113
- expect ( window . requestAnimationFrame ) . toHaveBeenCalled ( ) ;
104
+ var result = controller . getMousePosition ( mockMouseEvent ) ;
105
+
106
+ expect ( result ) . toEqual ( 0 ) ;
114
107
} ) ;
115
108
116
- it ( 'should handle unrecognised jQuery event without exception' , function ( ) {
117
-
118
- jQueryWindow . jQuery = true ;
119
-
109
+ it ( 'should handle unrecognised jQuery event' , function ( ) {
110
+
120
111
var mockMouseEvent = {
121
112
originalEvent : { }
122
113
} ;
123
114
124
- controller . mouseMoveHandler ( mockMouseEvent ) ;
125
-
126
- expect ( window . requestAnimationFrame ) . not . toHaveBeenCalled ( ) ;
115
+ var result = controller . getMousePosition ( mockMouseEvent ) ;
116
+
117
+ expect ( result ) . toEqual ( null ) ;
127
118
} ) ;
128
119
} ) ;
129
120
} ) ;
0 commit comments