|
2 | 2 | 'use strict';
|
3 | 3 |
|
4 | 4 | describe('uiGridScroller', function() {
|
5 |
| - var element, scrollHandler, gridUtil, uiGridScroller, uiGridScrollerConstants, |
6 |
| - callbacks = {}; |
| 5 | + var element, scrollHandler, gridUtil, uiGridScroller, uiGridScrollerConstants; |
7 | 6 |
|
8 | 7 | beforeEach(function() {
|
9 | 8 | element = {
|
|
19 | 18 | }
|
20 | 19 | }
|
21 | 20 | },
|
22 |
| - on: jasmine.createSpy('on').and.callFake(function(eventName, callback) { |
23 |
| - callbacks[eventName] = callback; |
24 |
| - }), |
25 |
| - off: jasmine.createSpy('off'), |
26 |
| - trigger: function(eventName, args) { |
27 |
| - args.type = eventName; |
28 |
| - callbacks[eventName](args); |
29 |
| - } |
| 21 | + on: jasmine.createSpy('on'), |
| 22 | + off: jasmine.createSpy('off') |
30 | 23 | };
|
31 | 24 | scrollHandler = jasmine.createSpy('scrollHandler');
|
32 | 25 |
|
|
37 | 30 | uiGridScrollerConstants = _uiGridScrollerConstants_;
|
38 | 31 | gridUtil = _gridUtil_;
|
39 | 32 | });
|
40 |
| - |
41 |
| - spyOn(window, 'requestAnimationFrame').and.callFake(jasmine.createSpy('requestAnimationFrame')); |
42 | 33 | });
|
43 | 34 |
|
44 | 35 | describe('when gridUtils.isTouchEnabled returns true', function() {
|
|
61 | 52 | it('should initialize touchcancel', function() {
|
62 | 53 | expect(element.on).toHaveBeenCalledWith('touchcancel', jasmine.any(Function));
|
63 | 54 | });
|
64 |
| - xdescribe('events', function() { |
65 |
| - describe('on touchstart', function() { |
66 |
| - beforeEach(function() { |
67 |
| - element.trigger('touchstart', { |
68 |
| - touches: [{ |
69 |
| - pageX: 0, |
70 |
| - pageY: 0 |
71 |
| - }] |
72 |
| - }); |
73 |
| - }); |
74 |
| - it('should remove the scroll event from the element', function() { |
75 |
| - expect(element.off).toHaveBeenCalledWith('scroll', scrollHandler); |
76 |
| - }); |
77 |
| - it('should update the uiGridScroller.initiated value to TOUCHABLE', function() { |
78 |
| - expect(uiGridScroller.initiated).toEqual(uiGridScrollerConstants.scrollType.TOUCHABLE); |
79 |
| - }); |
80 |
| - it('should update the uiGridScroller.isAnimating value to false', function() { |
81 |
| - expect(uiGridScroller.isAnimating).toBe(false); |
82 |
| - }); |
83 |
| - }); |
84 |
| - describe('on touchmove', function() { |
85 |
| - var preventDefaultSpy; |
86 |
| - |
87 |
| - beforeEach(function() { |
88 |
| - preventDefaultSpy = jasmine.createSpy('preventDefault'); |
89 |
| - }); |
90 |
| - describe('when the uiGridScroller has been initiated with a touch event', function() { |
91 |
| - beforeEach(function() { |
92 |
| - uiGridScroller.initiated = uiGridScrollerConstants.scrollType.TOUCHABLE; |
93 |
| - element.trigger('touchmove', { |
94 |
| - touches: [{ |
95 |
| - pageX: 0, |
96 |
| - pageY: 0 |
97 |
| - }], |
98 |
| - preventDefault: preventDefaultSpy |
99 |
| - }); |
100 |
| - }); |
101 |
| - it('should prevent the default behavior', function() { |
102 |
| - expect(preventDefaultSpy).toHaveBeenCalled(); |
103 |
| - }); |
104 |
| - it('should call the scrollHandler', function() { |
105 |
| - expect(scrollHandler).toHaveBeenCalled(); |
106 |
| - }); |
107 |
| - }); |
108 |
| - describe('when the uiGridScroller has not been initiated with a touch event', function() { |
109 |
| - beforeEach(function() { |
110 |
| - uiGridScroller.initiated = uiGridScrollerConstants.scrollType.NONE; |
111 |
| - element.trigger('touchmove', { |
112 |
| - touches: [{ |
113 |
| - pageX: 0, |
114 |
| - pageY: 0 |
115 |
| - }], |
116 |
| - preventDefault: preventDefaultSpy |
117 |
| - }); |
118 |
| - }); |
119 |
| - it('should prevent the default behavior', function() { |
120 |
| - expect(preventDefaultSpy).toHaveBeenCalled(); |
121 |
| - }); |
122 |
| - it('should not call the scrollHandler', function() { |
123 |
| - expect(scrollHandler).not.toHaveBeenCalled(); |
124 |
| - }); |
125 |
| - }); |
126 |
| - }); |
127 |
| - // function testEndFunction(eventName) { |
128 |
| - // describe('when the uiGridScroller has been initiated with a touch event', function() { |
129 |
| - // beforeEach(function() { |
130 |
| - // uiGridScroller.isAnimating = false; |
131 |
| - // uiGridScroller.initiated = uiGridScrollerConstants.scrollType.TOUCHABLE; |
132 |
| - // element.trigger(eventName, { |
133 |
| - // touches: [{ |
134 |
| - // pageX: 0, |
135 |
| - // pageY: 0 |
136 |
| - // }] |
137 |
| - // }); |
138 |
| - // }); |
139 |
| - // it('should update the uiGridScroller.initiated value to NONE', function() { |
140 |
| - // expect(uiGridScroller.initiated).toEqual(uiGridScrollerConstants.scrollType.NONE); |
141 |
| - // }); |
142 |
| - // it('should update the uiGridScroller.isAnimating value to true', function() { |
143 |
| - // expect(uiGridScroller.isAnimating).toBe(true); |
144 |
| - // }); |
145 |
| - // it('should call requestAnimationFrame in the window', function() { |
146 |
| - // expect(window.requestAnimationFrame).toHaveBeenCalled(); |
147 |
| - // }); |
148 |
| - // }); |
149 |
| - // describe('when the uiGridScroller has not been initiated with a touch event', function() { |
150 |
| - // beforeEach(function() { |
151 |
| - // uiGridScroller.isAnimating = false; |
152 |
| - // uiGridScroller.initiated = uiGridScrollerConstants.scrollType.MOUSE; |
153 |
| - // element.trigger(eventName, { |
154 |
| - // touches: [{ |
155 |
| - // pageX: 0, |
156 |
| - // pageY: 0 |
157 |
| - // }] |
158 |
| - // }); |
159 |
| - // }); |
160 |
| - // it('should not update the uiGridScroller.initiated value', function() { |
161 |
| - // expect(uiGridScroller.initiated).toEqual(uiGridScrollerConstants.scrollType.MOUSE); |
162 |
| - // }); |
163 |
| - // it('should not update the uiGridScroller.isAnimating value', function() { |
164 |
| - // expect(uiGridScroller.isAnimating).toBe(false); |
165 |
| - // }); |
166 |
| - // it('should not call requestAnimationFrame in the window', function() { |
167 |
| - // expect(window.requestAnimationFrame).not.toHaveBeenCalled(); |
168 |
| - // }); |
169 |
| - // }); |
170 |
| - // } |
171 |
| - // describe('on touchend', function() { |
172 |
| - // testEndFunction('touchend'); |
173 |
| - // }); |
174 |
| - // describe('on touchcancel', function() { |
175 |
| - // testEndFunction('touchcancel'); |
176 |
| - // }); |
177 |
| - }); |
178 | 55 | afterEach(function() {
|
179 | 56 | element.on.calls.reset();
|
180 | 57 | element.off.calls.reset();
|
|
0 commit comments