Sfoglia il codice sorgente

tests for duplicate rendering of agenda skeleton / now indicator

Adam Shaw 8 anni fa
parent
commit
b8c69bcee7

+ 20 - 0
tests/legacy/nowIndicator.js

@@ -1,4 +1,5 @@
 describe('now indicator', function() {
+	var FC = $.fullCalendar;
 	var options;
 
 	beforeEach(function() {
@@ -61,6 +62,25 @@ describe('now indicator', function() {
 				});
 			});
 		});
+
+		// https://github.com/fullcalendar/fullcalendar/issues/3872
+		it('doesnt double render indicator arrow', function(done) {
+
+			// force the indicator to update every second
+			var getNowIndicatorUnit = spyOnMethod(FC.TimeGrid, 'getNowIndicatorUnit', true)
+				.and.returnValue('second');
+
+			options.defaultDate = '2016-01-01'; // does NOT have "now" in view
+			options.nowIndicator = true;
+			$('#cal').fullCalendar(options);
+			$('#cal').fullCalendar('today'); // the bug only happens after navigate
+
+			setTimeout(function() {
+				expect($('.fc-now-indicator-arrow').length).toBe(1);
+				getNowIndicatorUnit.restore();
+				done();
+			}, 2100); // allows for more than 1 update
+		});
 	});
 
 	function isNowIndicatorRendered() {

+ 7 - 1
tests/view-dates/next.js

@@ -4,7 +4,7 @@ describe('next', function() {
 		defaultDate: '2017-06-08'
 	});
 
-	describe('when in a week view', function() {
+	describe('when in agendaWeek view', function() {
 		pushOptions({
 			defaultView: 'agendaWeek'
 		});
@@ -28,6 +28,12 @@ describe('next', function() {
 				ViewDateUtils.expectActiveRange('2017-06-18', '2017-06-25');
 			});
 		});
+
+		it('does not duplicate-render skeleton', function() {
+			initCalendar();
+			currentCalendar.next();
+			expect(TimeGridRenderUtils.isStructureValid()).toBe(true);
+		});
 	});
 
 	describe('when in a month view', function() {

+ 6 - 0
tests/view-render/TimeGridRenderUtils.js

@@ -8,5 +8,11 @@ var TimeGridRenderUtils = {
 				isMajor: !$(tr).hasClass('fc-minor')
 			};
 		}).get();
+	},
+
+	// for https://github.com/fullcalendar/fullcalendar-scheduler/issues/363
+	isStructureValid: function() {
+		return $('.fc-time-grid .fc-content-skeleton').length === 1;
 	}
+
 };

+ 1 - 0
tests/view-type/changeView.js

@@ -46,6 +46,7 @@ describe('changeView', function() {
 						case 2:
 							expect(view.type).toBe('agendaWeek');
 							checkViewIntegrity();
+							expect(TimeGridRenderUtils.isStructureValid()).toBe(true);
 							currentCalendar.changeView('basicWeek');
 							break;
 						case 3: