Переглянути джерело

tests: agenda event touch dragging

Adam Shaw 9 роки тому
батько
коміт
6d5a9ff2f1
1 змінених файлів з 43 додано та 28 видалено
  1. 43 28
      tests/automated/event-dnd.js

+ 43 - 28
tests/automated/event-dnd.js

@@ -150,37 +150,52 @@ describe('eventDrop', function() {
 			options.defaultView = 'agendaWeek';
 			options.defaultView = 'agendaWeek';
 		});
 		});
 
 
-		describe('when dragging a timed event to another time on a different day', function() {
-			it('should be given correct arguments and delta with days/time', function(done) {
-				options.events = [ {
-					title: 'timed event',
-					start: '2014-06-11T06:00:00',
-					allDay: false
-				} ];
+		[ false, true ].forEach(function(isTouch) {
+			describe('with ' + (isTouch ? 'touch' : 'mouse'), function() {
+				beforeEach(function() {
+					options.isTouch = isTouch;
+					options.longPressDelay = isTouch ? 100 : 0;
+				});
 
 
-				init(
-					function() {
-						$('.fc-event .fc-time').simulate('drag', {
-							dx: $('th.fc-wed').width(), // 1 day
-							dy: $('.fc-slats tr:eq(1)').outerHeight() * 2.9 // 1.5 hours
-						});
-					},
-					function(event, delta, revertFunc) {
-						expect(delta.days()).toBe(1);
-						expect(delta.hours()).toBe(1);
-						expect(delta.minutes()).toBe(30);
-						expect(delta.seconds()).toBe(0);
-						expect(delta.milliseconds()).toBe(0);
+				describe('when dragging a timed event to another time on a different day', function() {
+					it('should be given correct arguments and delta with days/time', function(done) {
+						options.events = [ {
+							title: 'timed event',
+							start: '2014-06-11T06:00:00',
+							allDay: false
+						} ];
 
 
-						expect(event.start).toEqualMoment('2014-06-12T07:30:00');
-						expect(event.end).toBeNull();
-						revertFunc();
-						expect(event.start).toEqualMoment('2014-06-11T06:00:00');
-						expect(event.end).toBeNull();
+						init(
+							function() {
+								// setTimeout waits for full render, so there's no scroll,
+								// because scroll kills touch drag
+								setTimeout(function() {
+									$('.fc-event .fc-time').simulate('drag', {
+										dx: $('th.fc-wed').width(), // 1 day
+										dy: $('.fc-slats tr:eq(1)').outerHeight() * 2.9, // 1.5 hours
+										isTouch: isTouch,
+										delay: isTouch ? 200 : 0
+									});
+								}, 0);
+							},
+							function(event, delta, revertFunc) {
+								expect(delta.days()).toBe(1);
+								expect(delta.hours()).toBe(1);
+								expect(delta.minutes()).toBe(30);
+								expect(delta.seconds()).toBe(0);
+								expect(delta.milliseconds()).toBe(0);
 
 
-						done();
-					}
-				);
+								expect(event.start).toEqualMoment('2014-06-12T07:30:00');
+								expect(event.end).toBeNull();
+								revertFunc();
+								expect(event.start).toEqualMoment('2014-06-11T06:00:00');
+								expect(event.end).toBeNull();
+
+								done();
+							}
+						);
+					});
+				});
 			});
 			});
 		});
 		});