Răsfoiți Sursa

tweaks to new footer code

Adam Shaw 9 ani în urmă
părinte
comite
af6834c66c
2 a modificat fișierele cu 12 adăugiri și 11 ștergeri
  1. 1 1
      src/Calendar.js
  2. 11 10
      tests/automated/footer-navigation.js

+ 1 - 1
src/Calendar.js

@@ -78,7 +78,7 @@ var Calendar = FC.Calendar = Class.extend({
 		if ($.inArray(unit, intervalUnits) != -1) {
 
 			// put views that have buttons first. there will be duplicates, but oh well
-			viewTypes = this.header.getViewsWithButtons();
+			viewTypes = this.header.getViewsWithButtons(); // TODO: include footer as well?
 			$.each(FC.views, function(viewType) { // all views
 				viewTypes.push(viewType);
 			});

+ 11 - 10
tests/automated/footer-navigation.js

@@ -1,21 +1,22 @@
 
-describe('footer navigation', function() {
+fdescribe('footer navigation', function() {
+	var options;
 
 	beforeEach(function() {
 		affix('#calendar');
-		var options = {
+		options = {
+			now: '2010-02-01',
 			footer: {
 				left: 'next,prev,prevYear,nextYear today',
 				center: '',
 				right: 'title'
 			}
 		};
-		$('#calendar').fullCalendar(options);
 	});
 
 	describe('and click next', function() {
 		it('should change view to next month', function() {
-			$('#calendar').fullCalendar('gotoDate', '2010-02-01');
+			$('#calendar').fullCalendar(options);
 			$('.fc-footer-toolbar .fc-next-button').simulate('click');
 			var newDate = $('#calendar').fullCalendar('getDate');
 			expect(newDate).toEqualMoment('2010-03-01');
@@ -24,7 +25,7 @@ describe('footer navigation', function() {
 
 	describe('and click prev', function() {
 		it('should change view to prev month', function() {
-			$('#calendar').fullCalendar('gotoDate', '2010-02-01');
+			$('#calendar').fullCalendar(options);
 			$('.fc-footer-toolbar .fc-prev-button').simulate('click');
 			var newDate = $('#calendar').fullCalendar('getDate');
 			expect(newDate).toEqualMoment('2010-01-01');
@@ -33,7 +34,7 @@ describe('footer navigation', function() {
 
 	describe('and click prevYear', function() {
 		it('should change view to prev month', function() {
-			$('#calendar').fullCalendar('gotoDate', '2010-02-01');
+			$('#calendar').fullCalendar(options);
 			$('.fc-footer-toolbar .fc-prevYear-button').simulate('click');
 			var newDate = $('#calendar').fullCalendar('getDate');
 			expect(newDate).toEqualMoment('2009-02-01');
@@ -42,7 +43,7 @@ describe('footer navigation', function() {
 
 	describe('and click nextYear', function() {
 		it('should change view to prev month', function() {
-			$('#calendar').fullCalendar('gotoDate', '2010-02-01');
+			$('#calendar').fullCalendar(options);
 			$('.fc-footer-toolbar .fc-nextYear-button').simulate('click');
 			var newDate = $('#calendar').fullCalendar('getDate');
 			expect(newDate).toEqualMoment('2011-02-01');
@@ -51,11 +52,11 @@ describe('footer navigation', function() {
 
 	describe('and click today', function() {
 		it('should change view to prev month', function() {
-			$('#calendar').fullCalendar('gotoDate', '2010-02-01');
+			options.defaultDate = '2010-03-15'; // something other than the `now` date
+			$('#calendar').fullCalendar(options);
 			$('.fc-footer-toolbar .fc-today-button').simulate('click');
 			var newDate = $('#calendar').fullCalendar('getDate'); // will be ambig zone
-			newDate.local(); // assign the local timezone
-			expect(newDate).toEqualNow();
+			expect(newDate).toEqualMoment('2010-02-01');
 		});
 	});
 });