Ver Fonte

tests for buggy touch dayClick

Adam Shaw há 9 anos atrás
pai
commit
259d89b7f4
1 ficheiros alterados com 49 adições e 0 exclusões
  1. 49 0
      tests/automated/dayClick.js

+ 49 - 0
tests/automated/dayClick.js

@@ -139,4 +139,53 @@ describe('dayClick', function() {
 			});
 		});
 	});
+
+	describe('when touch', function() {
+		beforeEach(function() {
+			options.isTouch = true;
+		});
+
+		it('fires correctly when simulated short drag on a cell', function(done) {
+			options.dayClick = function(date, jsEvent, view) {
+				expect(moment.isMoment(date)).toEqual(true);
+				expect(typeof jsEvent).toEqual('object'); // TODO: more descrimination
+				expect(typeof view).toEqual('object'); // "
+				expect(date.hasTime()).toEqual(false);
+				expect(date).toEqualMoment('2014-05-07');
+			};
+			spyOn(options, 'dayClick').and.callThrough();
+			$('#cal').fullCalendar(options);
+
+			var dayCell = $('.fc-day:eq(10)'); // 2014-05-07 (regardless of isRTL)
+
+			// for simulating the mousedown/mouseup/click (relevant for selectable)
+			dayCell.simulate('drag', {
+				isTouch: true,
+				callback: function() {
+					expect(options.dayClick).toHaveBeenCalled();
+					done();
+				}
+			});
+		});
+
+		it('fires correctly when simulated click on a cell', function(done) {
+			options.dayClick = function(date, jsEvent, view) {
+				expect(moment.isMoment(date)).toEqual(true);
+				expect(typeof jsEvent).toEqual('object'); // TODO: more descrimination
+				expect(typeof view).toEqual('object'); // "
+				expect(date.hasTime()).toEqual(false);
+				expect(date).toEqualMoment('2014-05-07');
+			};
+			spyOn(options, 'dayClick').and.callThrough();
+			$('#cal').fullCalendar(options);
+
+			var dayCell = $('.fc-day:eq(10)'); // 2014-05-07 (regardless of isRTL)
+
+			$.simulateTouchClick(dayCell);
+
+			expect(options.dayClick).toHaveBeenCalled();
+			done();
+		});
+	});
+
 });