Răsfoiți Sursa

update tests for options related to newly introduced Moment/Duration

Adam Shaw 12 ani în urmă
părinte
comite
d4be172f56

+ 10 - 10
tests/automated/complex-headerDateClick.js

@@ -15,46 +15,46 @@ describe('when header options set with next|prev|prevYear|nextYear|today', funct
 
 	describe('and click next', function() {
 		it('should change view to next month', function() {
-			$('#calendar').fullCalendar('gotoDate', 2010, 1, 1);
+			$('#calendar').fullCalendar('gotoDate', '2010-02-01');
 			$('.fc-button-next').simulate('click');
 			var newDate = $('#calendar').fullCalendar('getDate');
-			expect(newDate).toEqual(new Date(2010, 2, 1));
+			expect(newDate.format()).toEqual('2010-03-01');
 		});
 	});
 
 	describe('and click prev', function() {
 		it('should change view to prev month', function() {
-			$('#calendar').fullCalendar('gotoDate', 2010, 1, 1);
+			$('#calendar').fullCalendar('gotoDate', '2010-02-01');
 			$('.fc-button-prev').simulate('click');
 			var newDate = $('#calendar').fullCalendar('getDate');
-			expect(newDate).toEqual(new Date(2009, 12, 1));
+			expect(newDate.format()).toEqual('2010-01-01');
 		});
 	});
 
 	describe('and click prevYear', function() {
 		it('should change view to prev month', function() {
-			$('#calendar').fullCalendar('gotoDate', 2010, 1, 1);
+			$('#calendar').fullCalendar('gotoDate', '2010-02-01');
 			$('.fc-button-prevYear').simulate('click');
 			var newDate = $('#calendar').fullCalendar('getDate');
-			expect(newDate).toEqual(new Date(2009, 1, 1));
+			expect(newDate.format()).toEqual('2009-02-01');
 		});
 	});
 
 	describe('and click nextYear', function() {
 		it('should change view to prev month', function() {
-			$('#calendar').fullCalendar('gotoDate', 2010, 1, 1);
+			$('#calendar').fullCalendar('gotoDate', '2010-02-01');
 			$('.fc-button-nextYear').simulate('click');
 			var newDate = $('#calendar').fullCalendar('getDate');
-			expect(newDate).toEqual(new Date(2011, 1, 1));
+			expect(newDate.format()).toEqual('2011-02-01');
 		});
 	});
 
 	describe('and click today', function() {
 		it('should change view to prev month', function() {
-			$('#calendar').fullCalendar('gotoDate', 2010, 1, 1);
+			$('#calendar').fullCalendar('gotoDate', '2010-02-01');
 			$('.fc-button-today').simulate('click');
 			var newDate = $('#calendar').fullCalendar('getDate');
-			expect(newDate.toDateString()).toEqual(new Date().toDateString());
+			expect(newDate.format()).toEqual(moment().format());
 		});
 	});
 });

+ 14 - 14
tests/automated/minTime.js

@@ -50,15 +50,15 @@ describe('minTime', function() {
 			beforeEach(function() {
 				affix('#cal2');
 			});
-			hourNumbers.forEach(function(minTimeIn) {
-				it('should start at ' + minTimeIn, function() {
+			hourNumbers.forEach(function(hourNumber) {
+				it('should start at ' + hourNumber, function() {
 					var options = {
 						defaultView: 'agendaWeek',
-						minTime: minTimeIn
+						minTime: { hours: hourNumber }
 					};
 					$('#cal2').fullCalendar(options);
 					var firstSlotText = $('.fc-slot0 th').text();
-					var expected = numToStringConverter(minTimeIn);
+					var expected = numToStringConverter(hourNumber);
 					expect(firstSlotText).toEqual(expected);
 				});
 			});
@@ -68,15 +68,15 @@ describe('minTime', function() {
 			beforeEach(function() {
 				affix('#cal2');
 			});
-			hourNumbers.forEach(function(minTimeIn) {
-				it('should start at ' + minTimeIn, function() {
+			hourNumbers.forEach(function(hourNumber) {
+				it('should start at ' + hourNumber, function() {
 					var options = {
 						defaultView: 'agendaWeek',
-						minTime: minTimeIn
+						minTime: { hours: hourNumber }
 					};
 					$('#cal2').fullCalendar(options);
 					var firstSlotText = $('.fc-slot0 th').text();
-					var expected = numToStringConverter(minTimeIn);
+					var expected = numToStringConverter(hourNumber);
 					expect(firstSlotText).toEqual(expected);
 				});
 			});
@@ -91,11 +91,11 @@ describe('minTime', function() {
 			beforeEach(function() {
 				affix('#cal2');
 			});
-			hourNumbers.forEach(function(minTimeIn) {
-				it('should start at ' + minTimeIn + 0.12, function() {
+			hourNumbers.forEach(function(hourNumber) {
+				it('should start at ' + hourNumber + ':20', function() {
 					var options = {
 						defaultView: 'agendaWeek',
-						minTime: minTimeIn + 0.12
+						minTime: { hours: hourNumber, minutes: 20 }
 					};
 					$('#cal2').fullCalendar(options);
 					var firstSlotElement = $('.fc-slot0')[0];
@@ -112,11 +112,11 @@ describe('minTime', function() {
 			beforeEach(function() {
 				affix('#cal2');
 			});
-			hourNumbers.forEach(function(minTimeIn) {
-				it('should start at ' + minTimeIn + 0.12, function() {
+			hourNumbers.forEach(function(hourNumber) {
+				it('should start at ' + hourNumber + ':20', function() {
 					var options = {
 						defaultView: 'agendaWeek',
-						minTime: minTimeIn + 0.12
+						minTime: { hours: hourNumber, minutes: 20 }
 					};
 					$('#cal2').fullCalendar(options);
 					var firstSlotElement = $('.fc-slot0')[0];

+ 6 - 6
tests/automated/slotMinutes.js

@@ -61,15 +61,15 @@ describe('slotMinutes', function() {
 			beforeEach(function() {
 				affix('#cal2');
 			});
-			slotMinutesList.forEach(function(slotMinutesIn) {
+			slotMinutesList.forEach(function(slotMinutes) {
 				it('should have slots 1440/x slots', function() {
 					var options = {
 						defaultView: 'agendaWeek',
-						slotMinutes: slotMinutesIn
+						slotDuration: { minutes: slotMinutes }
 					};
 					$('#cal2').fullCalendar(options);
 					var slotCount = $('.fc-agenda-slots tr').length;
-					var expected = Math.ceil(minutesInADay / slotMinutesIn);
+					var expected = Math.ceil(minutesInADay / slotMinutes);
 					expect(slotCount).toEqual(expected);
 				});
 			});
@@ -79,15 +79,15 @@ describe('slotMinutes', function() {
 			beforeEach(function() {
 				affix('#cal2');
 			});
-			slotMinutesList.forEach(function(slotMinutesIn) {
+			slotMinutesList.forEach(function(slotMinutes) {
 				it('should have slots 1440/x slots', function() {
 					var options = {
 						defaultView: 'agendaWeek',
-						slotMinutes: slotMinutesIn
+						slotDuration: { minutes: slotMinutes }
 					};
 					$('#cal2').fullCalendar(options);
 					var slotCount = $('.fc-agenda-slots tr').length;
-					var expected = Math.ceil(minutesInADay / slotMinutesIn);
+					var expected = Math.ceil(minutesInADay / slotMinutes);
 					expect(slotCount).toEqual(expected);
 				});
 			});

+ 26 - 26
tests/automated/weekMode.js

@@ -13,26 +13,26 @@ describe('weekMode', function() {
 			$('#cal').fullCalendar();
 		});
 		it('should show 6 weeks for a 5 week month', function() {
-			$('#cal').fullCalendar('gotoDate', 2013, 9);
+			$('#cal').fullCalendar('gotoDate', '2013-10-01');
 			var weekCount = $('.fc-week').length;
 			expect(weekCount).toEqual(6);
 		});
 		it('should show 6 weeks for a 4 week month', function() {
-			$('#cal').fullCalendar('gotoDate', 2009, 2);
+			$('#cal').fullCalendar('gotoDate', '2009-03-01');
 			var weekCount = $('.fc-week').length;
 			expect(weekCount).toEqual(6);
 		});
 		it('should show 6 weeks for a 6 week month', function() {
-			$('#cal').fullCalendar('gotoDate', 2013, 5);
+			$('#cal').fullCalendar('gotoDate', '2013-06-01');
 			var weekCount = $('.fc-week').length;
 			expect(weekCount).toEqual(6);
 		});
 		it('should not change height whether 4,5 or weeks', function() {
-			$('#cal').fullCalendar('gotoDate', 2009, 1);
+			$('#cal').fullCalendar('gotoDate', '2009-02-01');
 			var fourWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height'));
-			$('#cal').fullCalendar('gotoDate', 2013, 9);
+			$('#cal').fullCalendar('gotoDate', '2013-10-01');
 			var fiveWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height'));
-			$('#cal').fullCalendar('gotoDate', 2013, 5);
+			$('#cal').fullCalendar('gotoDate', '2013-06-01');
 			var sixWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height'));
 			expect(fourWeekHeight).toEqual(fiveWeekHeight);
 			expect(fiveWeekHeight).toEqual(sixWeekHeight);
@@ -46,17 +46,17 @@ describe('weekMode', function() {
 			});
 		});
 		it('should show 6 weeks for a 5 week month', function() {
-			$('#cal').fullCalendar('gotoDate', 2013, 9);
+			$('#cal').fullCalendar('gotoDate', '2013-10-01');
 			var weekCount = $('.fc-week').length;
 			expect(weekCount).toEqual(6);
 		});
 		it('should show 6 weeks for a 4 week month', function() {
-			$('#cal').fullCalendar('gotoDate', 2009, 2);
+			$('#cal').fullCalendar('gotoDate', '2009-03-01');
 			var weekCount = $('.fc-week').length;
 			expect(weekCount).toEqual(6);
 		});
 		it('should show 6 weeks for a 6 week month', function() {
-			$('#cal').fullCalendar('gotoDate', 2013, 5);
+			$('#cal').fullCalendar('gotoDate', '2013-06-01');
 			var weekCount = $('.fc-week').length;
 			expect(weekCount).toEqual(6);
 		});
@@ -69,45 +69,45 @@ describe('weekMode', function() {
 			});
 		});
 		it('should show 5 weeks for a 5 week month', function() {
-			$('#cal').fullCalendar('gotoDate', 2013, 9);
+			$('#cal').fullCalendar('gotoDate', '2013-10-01');
 			var weekCount = $('.fc-week').length;
 			expect(weekCount).toEqual(5);
 		});
 		it('should show 4 weeks for a 4 week month', function() {
-			$('#cal').fullCalendar('gotoDate', 2009, 1);
+			$('#cal').fullCalendar('gotoDate', '2009-02-01');
 			var weekCount = $('.fc-week').length;
 			expect(weekCount).toEqual(4);
 		});
 		it('should show 6 weeks for a 6 week month', function() {
-			$('#cal').fullCalendar('gotoDate', 2013, 5);
+			$('#cal').fullCalendar('gotoDate', '2013-06-01');
 			var weekCount = $('.fc-week').length;
 			expect(weekCount).toEqual(6);
 		});
 		it('should increase height when moving from 6 week to 5 weeks', function() {
-			$('#cal').fullCalendar('gotoDate', 2013, 9);
+			$('#cal').fullCalendar('gotoDate', '2013-10-01');
 			var fiveWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height'));
-			$('#cal').fullCalendar('gotoDate', 2013, 5);
+			$('#cal').fullCalendar('gotoDate', '2013-06-01');
 			var sixWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height'));
 			expect(fiveWeekHeight).toBeGreaterThan(sixWeekHeight);
 		});
 		it('should reduce height when moving from 5 weeks to 6 weeks', function() {
-			$('#cal').fullCalendar('gotoDate', 2013, 5);
+			$('#cal').fullCalendar('gotoDate', '2013-06-01');
 			var sixWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height'));
-			$('#cal').fullCalendar('gotoDate', 2013, 9);
+			$('#cal').fullCalendar('gotoDate', '2013-10-01');
 			var fiveWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height'));
 			expect(fiveWeekHeight).toBeGreaterThan(sixWeekHeight);
 		});
 		it('should increase height when moving from 5 weeks to 4 weeks', function() {
-			$('#cal').fullCalendar('gotoDate', 2013, 4);
+			$('#cal').fullCalendar('gotoDate', '2013-05-01');
 			var fiveWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height'));
-			$('#cal').fullCalendar('gotoDate', 2009, 1);
+			$('#cal').fullCalendar('gotoDate', '2009-02-01');
 			var fourWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height'));
 			expect(fourWeekHeight).toBeGreaterThan(fiveWeekHeight);
 		});
 		it('should reduce height when moving from 4 weeks to 5 weeks', function() {
-			$('#cal').fullCalendar('gotoDate', 2009, 1);
+			$('#cal').fullCalendar('gotoDate', '2009-02-01');
 			var fourWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height'));
-			$('#cal').fullCalendar('gotoDate', 2013, 4);
+			$('#cal').fullCalendar('gotoDate', '2013-05-01');
 			var fiveWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height'));
 			expect(fourWeekHeight).toBeGreaterThan(fiveWeekHeight);
 		});
@@ -120,26 +120,26 @@ describe('weekMode', function() {
 			});
 		});
 		it('should show 5 weeks for a 5 week month', function() {
-			$('#cal').fullCalendar('gotoDate', 2013, 9);
+			$('#cal').fullCalendar('gotoDate', '2013-10-01');
 			var weekCount = $('.fc-week').length;
 			expect(weekCount).toEqual(5);
 		});
 		it('should show 4 weeks for a 4 week month', function() {
-			$('#cal').fullCalendar('gotoDate', 2009, 1);
+			$('#cal').fullCalendar('gotoDate', '2009-02-01');
 			var weekCount = $('.fc-week').length;
 			expect(weekCount).toEqual(4);
 		});
 		it('should show 6 weeks for a 6 week month', function() {
-			$('#cal').fullCalendar('gotoDate', 2013, 5);
+			$('#cal').fullCalendar('gotoDate', '2013-06-01');
 			var weekCount = $('.fc-week').length;
 			expect(weekCount).toEqual(6);
 		});
 		it('should not change height whether 4,5 or weeks', function() {
-			$('#cal').fullCalendar('gotoDate', 2009, 1);
+			$('#cal').fullCalendar('gotoDate', '2009-02-01');
 			var fourWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height'));
-			$('#cal').fullCalendar('gotoDate', 2013, 9);
+			$('#cal').fullCalendar('gotoDate', '2013-10-01');
 			var fiveWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height'));
-			$('#cal').fullCalendar('gotoDate', 2013, 5);
+			$('#cal').fullCalendar('gotoDate', '2013-06-01');
 			var sixWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height'));
 			expect(fourWeekHeight).toEqual(fiveWeekHeight);
 			expect(fiveWeekHeight).toEqual(sixWeekHeight);

+ 4 - 3
tests/automated/weekNumberCalculation.js

@@ -9,9 +9,10 @@ describe('weekNumberCalculation', function() {
 		it('should return iso standard', function() {
 			$('#cal').fullCalendar({
 				editable: true,
-				weekNumbers: true
+				weekNumbers: true,
+				weekNumberCalculation: 'ISO'
 			});
-			$('#cal').fullCalendar('gotoDate', 2013, 10, 17);
+			$('#cal').fullCalendar('gotoDate', '2013-11-17');
 			var weekNum = parseInt($('.fc-week.fc-first .fc-week-number div').text());
 			expect(weekNum).toEqual(43);
 		});
@@ -26,7 +27,7 @@ describe('weekNumberCalculation', function() {
 					return 4;
 				}
 			});
-			$('#cal').fullCalendar('gotoDate', 2013, 10, 17);
+			$('#cal').fullCalendar('gotoDate', '2013-11-17');
 			var weekNum = parseInt($('.fc-week.fc-first .fc-week-number div').text());
 			expect(weekNum).toEqual(4);
 		});