فهرست منبع

add additional testing scenarios for incre-d's allDayText & weekNumberCalculation tests

Adam Shaw 11 سال پیش
والد
کامیت
0e965e4387
2فایلهای تغییر یافته به همراه81 افزوده شده و 21 حذف شده
  1. 27 0
      tests/automated/allDayText.js
  2. 54 21
      tests/automated/weekNumberCalculation.js

+ 27 - 0
tests/automated/allDayText.js

@@ -53,6 +53,33 @@ describe('allDayText', function() {
 		});
 	});
 
+	describe('when allDaySlots is set true and language is not default', function() {
+		describe('in agendaWeek', function() {
+			it('should use the language\'s all-day value', function() {
+				var options = {
+					defaultView: 'agendaWeek',
+					allDaySlot: true,
+					lang: 'pt-br'
+				};
+				$('#cal').fullCalendar(options);
+				var allDayText = $('.fc-agenda-allday .fc-agenda-axis').text();
+				expect(allDayText).toEqual('dia inteiro');
+			});
+		});
+		describe('in agendaDay', function() {
+			it('should use the language\'s all-day value', function() {
+				var options = {
+					defaultView: 'agendaDay',
+					allDaySlot: true,
+					lang: 'pt-br'
+				};
+				$('#cal').fullCalendar(options);
+				var allDayText = $('.fc-agenda-allday .fc-agenda-axis').text();
+				expect(allDayText).toEqual('dia inteiro');
+			});
+		});
+	});
+
 	describe('when allDaySlots is set true and allDayText is specified', function() {
 		describe('in agendaWeek', function() {
 			it('should show specified all day text', function() {

+ 54 - 21
tests/automated/weekNumberCalculation.js

@@ -1,35 +1,68 @@
 
 describe('weekNumberCalculation', function() {
 
+	var options;
+
+	beforeEach(function() {
+		options = {
+			weekNumbers: true
+		};
+	});
+
+	function getRenderedWeekNumber() {
+		// works for both kinds of views
+		var text = $('.fc-agenda-axis.fc-week-number, .fc-week:first .fc-week-number').text();
+		return parseInt(text.replace(/\D/g, ''));
+	}
+
 	beforeEach(function() {
 		affix('#cal');
 	});
 
-	describe('when using the default', function() {
-		it('should return iso standard', function() {
-			$('#cal').fullCalendar({
-				editable: true,
-				weekNumbers: true,
-				weekNumberCalculation: 'ISO'
+	[ 'basicDay', 'agendaDay' ].forEach(function(viewType) {
+		describe('when in ' + viewType + ' view', function() {
+
+			beforeEach(function() {
+				options.defaultView = viewType;
+			});
+
+			it('should display the American standard when using \'local\'', function() {
+				options.defaultDate = '2013-11-23'; // a Saturday
+				options.weekNumberCalculation = 'local';
+				$('#cal').fullCalendar(options);
+				expect(getRenderedWeekNumber()).toBe(47);
+			});
+
+			it('should display a language-specific local week number', function() {
+				options.defaultDate = '2013-11-23'; // a Saturday
+				options.lang = 'ar';
+				options.weekNumberCalculation = 'local';
+				$('#cal').fullCalendar(options);
+				expect(getRenderedWeekNumber()).toBe(48);
+			});
+
+			// another local test, but to make sure it is different from ISO
+			it('should display the American standard when using \'local\'', function() {
+				options.defaultDate = '2013-11-17'; // a Sunday
+				options.weekNumberCalculation = 'local';
+				$('#cal').fullCalendar(options);
+				expect(getRenderedWeekNumber()).toBe(47);
+			});
+
+			it('should display ISO standard when using \'ISO\'', function() {
+				options.defaultDate = '2013-11-17'; // a Sunday
+				options.weekNumberCalculation = 'ISO';
+				$('#cal').fullCalendar(options);
+				expect(getRenderedWeekNumber()).toBe(46);
 			});
-			$('#cal').fullCalendar('gotoDate', '2013-11-17');
-			var weekNum = parseInt($('.fc-week.fc-first .fc-week-number div').text());
-			expect(weekNum).toEqual(43);
-		});
-	});
 
-	describe('when using a defined weekNumber calculation', function() {
-		it('should return the calculated number', function() {
-			$('#cal').fullCalendar({
-				editable: true,
-				weekNumbers: true,
-				weekNumberCalculation: function() {
+			it('should display the calculated number when a custom function', function() {
+				options.weekNumberCalculation = function() {
 					return 4;
-				}
+				};
+				$('#cal').fullCalendar(options);
+				expect(getRenderedWeekNumber()).toBe(4);
 			});
-			$('#cal').fullCalendar('gotoDate', '2013-11-17');
-			var weekNum = parseInt($('.fc-week.fc-first .fc-week-number div').text());
-			expect(weekNum).toEqual(4);
 		});
 	});
 });