Browse Source

more tests

Adam Shaw 9 năm trước cách đây
mục cha
commit
79a2409753

+ 7 - 2
tests/automated-better/event-drag/EventDragUtils.js

@@ -22,10 +22,13 @@ var EventDragUtils = {
 		currentCalendar.on('eventDragStop', function() {
 			setTimeout(function() {
 				deferred.resolve({ isSuccess: false }); // won't do anything if already eventDrop
-			}, 100); // must be greater that dragRevertDuration
+			}, 20);  // will happen after eventDrop's timeout
 		});
+
 		currentCalendar.on('eventDrop', function(event) { // always called after eventDragStop, if success
-			deferred.resolve({ isSuccess: false, event: event });
+			setTimeout(function() {
+				deferred.resolve({ isSuccess: true, event: event });
+			}, 10); // will happen first
 		});
 
 		return deferred.promise();
@@ -33,6 +36,8 @@ var EventDragUtils = {
 
 };
 
+// makes the setTimeout's work.
+// also makes the tests faster.
 pushOptions({
 	dragRevertDuration: 0
 });

+ 34 - 0
tests/automated-better/event-drag/disableNonCurrentDates.js

@@ -0,0 +1,34 @@
+
+describe('disableNonCurrentDates event dragging', function() {
+	pushOptions({
+		defaultView: 'month',
+		defaultDate: '2017-06-01',
+		disableNonCurrentDates: true,
+		events: [
+			{ start: '2017-06-07', end: '2017-06-10' }
+		],
+		editable: true
+	});
+
+	describe('when dragging pointer into disabled region', function() {
+		it('won\'t allow the drop', function() {
+			initCalendar();
+			return EventDragUtils.drag(
+				DayGridRenderUtils.getSingleDayEl('2017-06-08')[0].getBoundingClientRect(),
+				DayGridRenderUtils.getDisabledEl(3)[0].getBoundingClientRect() // the cell before Jun 1
+			).then(function(res) {
+				expect(res.isSuccess).toBe(false);
+			});
+		});
+	});
+
+	describe('when dragging an event\'s start into a disabled region', function() {
+		it('allow the drop if the cursor stays over non-disabled cells', function() {
+			initCalendar();
+			return DayGridEventDragUtils.drag('2017-06-08', '2017-06-01')
+				.then(function(res) {
+					expect(res.isSuccess).toBe(true);
+				});
+		});
+	});
+});

+ 23 - 0
tests/automated-better/event-drag/maxDate.js

@@ -0,0 +1,23 @@
+
+describe('maxDate event dragging', function() {
+
+	describe('when in month view', function() {
+		pushOptions({
+			defaultView: 'month',
+			defaultDate: '2017-06-01',
+			maxDate: '2017-06-09',
+			events: [
+				{ start: '2017-06-04', end: '2017-06-07' }
+			],
+			editable: true
+		});
+
+		it('won\'t go after maxDate', function() {
+			initCalendar();
+			return DayGridEventDragUtils.drag('2017-06-05', '2017-06-08')
+				.then(function(res) {
+					expect(res.isSuccess).toBe(false);
+				});
+		});
+	});
+});

+ 1 - 4
tests/automated-better/event-drag/minDate.js

@@ -1,7 +1,5 @@
 
 describe('minDate event dragging', function() {
-	// TODO: and dontDisplayCurrentDates
-	// TODO: event resizing
 
 	describe('when in month view', function() {
 		pushOptions({
@@ -14,7 +12,7 @@ describe('minDate event dragging', function() {
 			editable: true
 		});
 
-		it('won\'t do before minDate', function() {
+		it('won\'t go before minDate', function() {
 			initCalendar();
 			return DayGridEventDragUtils.drag('2017-06-08', '2017-06-06')
 				.then(function(res) {
@@ -22,5 +20,4 @@ describe('minDate event dragging', function() {
 				});
 		});
 	});
-
 });

+ 6 - 0
tests/automated-better/view-render/DayGridRenderUtils.js

@@ -6,6 +6,12 @@ var DayGridRenderUtils = {
 		var els = $('.fc-day-grid .fc-bg .fc-day[data-date="' + date.format('YYYY-MM-DD') + '"]');
 		expect(els).toHaveLength(1);
 		return els;
+	},
+
+	getDisabledEl: function(i) {
+		var el = $('.fc-day-grid .fc-bg .fc-disabled-day:eq(' + i + ')');
+		expect(el).toHaveLength(1);
+		return el;
 	}
 
 };