Explorar o código

automated tests for problems with prev/next

Adam Shaw %!s(int64=11) %!d(string=hai) anos
pai
achega
4510096e2d
Modificáronse 1 ficheiros con 51 adicións e 0 borrados
  1. 51 0
      tests/automated/current-date.js

+ 51 - 0
tests/automated/current-date.js

@@ -238,6 +238,57 @@ describe('current date', function() {
 		});
 		});
 	});
 	});
 
 
+	describe('when current date is a hidden day', function() {
+		describeWhenInMonth(function() {
+			it('should display the current month even if first day of month', function() {
+				options.now = options.defaultDate = '2014-06-01'; // a Sunday
+				options.weekends = false;
+				$('#cal').fullCalendar(options);
+				var view = $('#cal').fullCalendar('getView');
+				expect(view.start).toEqualMoment('2014-06-02');
+				expect(view.end).toEqualMoment('2014-07-12');
+				expect(view.intervalStart).toEqualMoment('2014-06-01');
+				expect(view.intervalEnd).toEqualMoment('2014-07-01');
+			});
+			it('should display the current month', function() {
+				options.now = options.defaultDate = '2014-05-04'; // a Sunday
+				options.weekends = false;
+				$('#cal').fullCalendar(options);
+				var view = $('#cal').fullCalendar('getView');
+				expect(view.start).toEqualMoment('2014-04-28');
+				expect(view.end).toEqualMoment('2014-06-07');
+				expect(view.intervalStart).toEqualMoment('2014-05-01');
+				expect(view.intervalEnd).toEqualMoment('2014-06-01');
+			});
+			describe('when navigating back a month', function() {
+				it('should not skip months', function() {
+					options.defaultDate = '2014-07-07';
+					options.weekends = false;
+					$('#cal').fullCalendar(options);
+					var view = $('#cal').fullCalendar('getView');
+					expect(view.intervalStart).toEqualMoment('2014-07-01');
+					expect(view.intervalEnd).toEqualMoment('2014-08-01');
+					$('#cal').fullCalendar('prev'); // will move to Jun 1, which is a Sunday
+					view = $('#cal').fullCalendar('getView');
+					expect(view.intervalStart).toEqualMoment('2014-06-01');
+					expect(view.intervalEnd).toEqualMoment('2014-07-01');
+				});
+			});
+		});
+		describeWhenInDay(function() {
+			it('should display the next visible day', function() {
+				options.now = options.defaultDate = '2014-06-01'; // a Sunday
+				options.weekends = false;
+				$('#cal').fullCalendar(options);
+				var view = $('#cal').fullCalendar('getView');
+				expect(view.start).toEqualMoment('2014-06-02');
+				expect(view.end).toEqualMoment('2014-06-03');
+				expect(view.intervalStart).toEqualMoment('2014-06-02');
+				expect(view.intervalEnd).toEqualMoment('2014-06-03');
+			});
+		});
+	});
+
 
 
 	// UTILS
 	// UTILS
 	// -----
 	// -----