MCPcopy Create free account
hub / github.com/angular-ui/ui-grid / testTouchStart

Function testTouchStart

packages/edit/test/uiGridCell.spec.js:188–226  ·  view source on GitHub ↗
(withOriginalEvent)

Source from the content-addressed store, hash-verified

186
187 describe('touchStart', function() {
188 function testTouchStart(withOriginalEvent) {
189 beforeEach(function() {
190 var event = new jQuery.Event('touchstart');
191
192 if (withOriginalEvent) {
193 event.originalEvent = new jQuery.Event('touchstart');
194 }
195 scope.grid.api.core.scrollToIfNecessary = jasmine.createSpy('scrollToIfNecessary').and.returnValue({then: angular.noop});
196 recompile();
197 element.trigger(event);
198 $timeout.flush();
199 scope.$apply();
200 });
201 afterEach(function() {
202 scope.grid.api.core.scrollToIfNecessary.calls.reset();
203 });
204 it('should trigger scrolling if necessary', function(done) {
205 setTimeout(function() {
206 expect(scope.grid.api.core.scrollToIfNecessary).toHaveBeenCalled();
207 done();
208 }, 1);
209 });
210 describe('touchEnd', function() {
211 beforeEach(function() {
212 var touchStartEvent = new jQuery.Event('touchstart'),
213 touchEndEvent = new jQuery.Event('touchend');
214
215 spyOn($timeout, 'cancel').and.callThrough();
216 element.trigger(touchStartEvent);
217 element.trigger(touchEndEvent);
218 });
219 afterEach(function() {
220 $timeout.cancel.calls.reset();
221 });
222 it('should cancel any touchstart timeout', function() {
223 expect($timeout.cancel).toHaveBeenCalled();
224 });
225 });
226 }
227 describe('when original event is defined', function() {
228 testTouchStart(true);
229 });

Callers 1

uiGridCell.spec.jsFile · 0.85

Calls 2

recompileFunction · 0.50
doneFunction · 0.50

Tested by

no test coverage detected