Sfoglia il codice sorgente

updated tests/legacy/ constructor, current-date,custom-view-class, custom-view-duration

kyle roux 8 anni fa
parent
commit
3438b73021

+ 17 - 21
tests/legacy/constructor.js

@@ -1,12 +1,10 @@
 
-describe('constructor', function() {
-
-	beforeEach(function() {
-		affix('#calendar');
-	});
-
+describe('constructor', function() {	
+	beforeEach(function(){
+		initCalendar();
+	})
 	it('should return a jQuery object for chaining', function() {
-		var res = $('#calendar').fullCalendar();
+		var res = $(currentCalendar.el);
 		expect(res instanceof jQuery).toBe(true);
 	});
 
@@ -17,7 +15,7 @@ describe('constructor', function() {
 			slotDuration: { minutes: 45 }
 		};
 		var optionsCopy = $.extend({}, options, true);
-		$('#calendar').fullCalendar(options);
+		initCalendar(options);
 		expect(options).toEqual(optionsCopy);
 	});
 
@@ -33,7 +31,7 @@ describe('constructor', function() {
 			]
 		};
 		var optionsCopy = $.extend(true, {}, options); // recursive copy
-		$('#calendar').fullCalendar(options);
+		initCalendar(options);
 		expect(options).toEqual(optionsCopy);
 	});
 
@@ -51,35 +49,33 @@ describe('constructor', function() {
 			]
 		};
 		var optionsCopy = $.extend(true, {}, options); // recursive copy
-		$('#calendar').fullCalendar(options);
+		initCalendar(options);
 		expect(options).toEqual(optionsCopy);
 	});
 
-	describe('when called on a div', function() {
-
-		beforeEach(function() {
-			$('#calendar').fullCalendar();
-		});
-
+	describe('when called on a div', function() {		
+		beforeEach(function(){
+			initCalendar();
+		})
 		it('should contain a table fc-toolbar', function() {
-			var header = $('#calendar > .fc-toolbar');
+			var header = $(currentCalendar.el).find('.fc-toolbar');
 			expect(header[0]).not.toBeUndefined();
 		});
 
 		it('should contain a div fc-view-container', function() {
-			var content = ($('#calendar > .fc-view-container'));
+			var content = $(currentCalendar.el).find('.fc-view-container');
 			expect(content[0]).not.toBeUndefined();
 		});
 
 		it('should only contain 2 elements', function() {
-			var calenderNodeCount = $('#calendar >').length;
+			var calenderNodeCount = $(currentCalendar.el).find('>').length;
 			expect(calenderNodeCount).toEqual(2);
 		});
 
 		describe('and then called again', function() {
 			it('should still only have a single set of calendar [header,content]', function() {
-				$('#calendar').fullCalendar();
-				var count = $('#calendar >').length;
+				initCalendar();
+				var count = $(currentCalendar.el).find('>').length;
 				expect(count).toEqual(2);
 			});
 		});

+ 68 - 67
tests/legacy/current-date.js

@@ -1,48 +1,47 @@
 describe('current date', function() {
 
-	var TITLE_FORMAT = 'MMMM D YYYY';
-	var options;
-
-	beforeEach(function() {
-		affix('#cal');
-		options = {
-			titleFormat: TITLE_FORMAT,
-			titleRangeSeparator: ' - ',
-			defaultDate: '2014-06-01'
-		};
-	});
+	var TITLE_FORMAT = 'MMMM D YYYY';		
+	pushOptions({
+		titleFormat: TITLE_FORMAT,
+		titleRangeSeparator: ' - ',
+		defaultDate: '2014-06-01'
+	});	
 
 	describe('defaultDate & getDate', function() { // keep getDate
 		describeWhenInMonth(function() {
 			it('should initialize at the date', function() {
+				var options = {};
 				options.defaultDate = '2011-03-10';
-				$('#cal').fullCalendar(options);
+				initCalendar(options);
 				expectViewDates('2011-02-27', '2011-04-10', '2011-03-01', '2011-04-01');
-				var currentDate = $('#cal').fullCalendar('getDate');
+				var currentDate = currentCalendar.getDate();
 				expect(moment.isMoment(currentDate)).toEqual(true); // test the type, but only here
 				expect(currentDate).toEqualMoment('2011-03-10');
 			});
 		});
 		describeWhenInWeek(function() {
 			it('should initialize at the date, given a date string', function() {
+				var options = {};				
 				options.defaultDate = '2011-03-10';
-				$('#cal').fullCalendar(options);
+				initCalendar(options);
 				expectViewDates('2011-03-06', '2011-03-13');
-				expect($('#cal').fullCalendar('getDate')).toEqualMoment('2011-03-10');
+				expect(currentCalendar.getDate()).toEqualMoment('2011-03-10');
 			});
 			it('should initialize at the date, given a Moment object', function() {
+				var options = {};				
 				options.defaultDate = $.fullCalendar.moment('2011-03-10');
-				$('#cal').fullCalendar(options);
+				initCalendar(options);
 				expectViewDates('2011-03-06', '2011-03-13');
-				expect($('#cal').fullCalendar('getDate')).toEqualMoment('2011-03-10');
+				expect(currentCalendar.getDate()).toEqualMoment('2011-03-10');
 			});
 		});
 		describeWhenInDay(function() {
 			it('should initialize at the date', function() {
+				var options = {};				
 				options.defaultDate = '2011-03-10';
-				$('#cal').fullCalendar(options);
+				initCalendar(options);
 				expectViewDates('2011-03-10');
-				expect($('#cal').fullCalendar('getDate')).toEqualMoment('2011-03-10');
+				expect(currentCalendar.getDate()).toEqualMoment('2011-03-10');
 			});
 		});
 	});
@@ -50,32 +49,32 @@ describe('current date', function() {
 	describe('gotoDate', function() {
 		describeWhenInMonth(function() {
 			it('should go to a date when given a date string', function() {
-				$('#cal').fullCalendar(options);
-				$('#cal').fullCalendar('gotoDate', '2015-04-01');
+				initCalendar();
+				currentCalendar.gotoDate('2015-04-01');
 				expectViewDates('2015-03-29', '2015-05-10', '2015-04-01', '2015-05-01');
 			});
 		});
 		describeWhenInWeek(function() {
 			it('should go to a date when given a date string', function() {
-				$('#cal').fullCalendar(options);
-				$('#cal').fullCalendar('gotoDate', '2015-04-01');
+				initCalendar();
+				currentCalendar.gotoDate('2015-04-01');
 				expectViewDates('2015-03-29', '2015-04-05');
 			});
 			it('should go to a date when given a date string with a time', function() {
-				$('#cal').fullCalendar(options);
-				$('#cal').fullCalendar('gotoDate', '2015-04-01T12:00:00');
+				initCalendar();
+				currentCalendar.gotoDate('2015-04-01T12:00:00');
 				expectViewDates('2015-03-29', '2015-04-05');
 			});
 			it('should go to a date when given a moment object', function() {
-				$('#cal').fullCalendar(options);
-				$('#cal').fullCalendar('gotoDate', $.fullCalendar.moment('2015-04-01'));
+				initCalendar();
+				currentCalendar.gotoDate($.fullCalendar.moment('2015-04-01'));
 				expectViewDates('2015-03-29', '2015-04-05');
 			});
 		});
 		describeWhenInDay(function() {
 			it('should go to a date when given a date string', function() {
-				$('#cal').fullCalendar(options);
-				$('#cal').fullCalendar('gotoDate', '2015-04-01');
+				initCalendar();
+				currentCalendar.gotoDate('2015-04-01');
 				expectViewDates('2015-04-01');
 			});
 		});
@@ -84,32 +83,32 @@ describe('current date', function() {
 	describe('incrementDate', function() {
 		describeWhenInMonth(function() {
 			it('should increment the date when given a Duration object', function() {
-				$('#cal').fullCalendar(options);
-				$('#cal').fullCalendar('incrementDate', { months: -1 });
+				initCalendar();
+				currentCalendar.incrementDate({ months: -1 });
 				expectViewDates('2014-04-27', '2014-06-08', '2014-05-01', '2014-06-01');
 			});
 		});
 		describeWhenInWeek(function() {
 			it('should increment the date when given a Duration object', function() {
-				$('#cal').fullCalendar(options);
-				$('#cal').fullCalendar('incrementDate', { weeks: -2 });
+				initCalendar();
+				currentCalendar.incrementDate({ weeks: -2 });
 				expectViewDates('2014-05-18', '2014-05-25');
 			});
 		});
 		describeWhenInDay(function() {
 			it('should increment the date when given a Duration object', function() {
-				$('#cal').fullCalendar(options);
-				$('#cal').fullCalendar('incrementDate', { days: 2 });
+				initCalendar();
+				currentCalendar.incrementDate({ days: 2 });
 				expectViewDates('2014-06-03');
 			});
 			it('should increment the date when given a Duration string', function() {
-				$('#cal').fullCalendar(options);
-				$('#cal').fullCalendar('incrementDate', '2.00:00:00');
+				initCalendar();
+				currentCalendar.incrementDate('2.00:00:00');
 				expectViewDates('2014-06-03');
 			});
 			it('should increment the date when given a Duration string with a time', function() {
-				$('#cal').fullCalendar(options);
-				$('#cal').fullCalendar('incrementDate', '2.05:30:00');
+				initCalendar();
+				currentCalendar.incrementDate('2.05:30:00');
 				expectViewDates('2014-06-03');
 			});
 		});
@@ -118,22 +117,22 @@ describe('current date', function() {
 	describe('prevYear', function() {
 		describeWhenInMonth(function() {
 			it('should move the calendar back a year', function() {
-				$('#cal').fullCalendar(options);
-				$('#cal').fullCalendar('prevYear');
+				initCalendar();
+				currentCalendar.prevYear();
 				expectViewDates('2013-05-26', '2013-07-07', '2013-06-01', '2013-07-01');
 			});
 		});
 		describeWhenInWeek(function() {
 			it('should move the calendar back a year', function() {
-				$('#cal').fullCalendar(options);
-				$('#cal').fullCalendar('prevYear');
+				initCalendar();
+				currentCalendar.prevYear();
 				expectViewDates('2013-05-26', '2013-06-02');
 			});
 		});
 		describeWhenInDay(function() {
 			it('should move the calendar back a year', function() {
-				$('#cal').fullCalendar(options);
-				$('#cal').fullCalendar('prevYear');
+				initCalendar();
+				currentCalendar.prevYear();
 				expectViewDates('2013-06-01');
 			});
 		});
@@ -142,22 +141,22 @@ describe('current date', function() {
 	describe('nextYear', function() {
 		describeWhenInMonth(function() {
 			it('should move the calendar forward a year', function() {
-				$('#cal').fullCalendar(options);
-				$('#cal').fullCalendar('nextYear');
+				initCalendar();
+				currentCalendar.nextYear();
 				expectViewDates('2015-05-31', '2015-07-12', '2015-06-01', '2015-07-01');
 			});
 		});
 		describeWhenInWeek(function() {
 			it('should move the calendar forward a year', function() {
-				$('#cal').fullCalendar(options);
-				$('#cal').fullCalendar('nextYear');
+				initCalendar();
+				currentCalendar.nextYear();
 				expectViewDates('2015-05-31', '2015-06-07');
 			});
 		});
 		describeWhenInDay(function() {
 			it('should move the calendar forward a year', function() {
-				$('#cal').fullCalendar(options);
-				$('#cal').fullCalendar('nextYear');
+				initCalendar();
+				currentCalendar.nextYear();
 				expectViewDates('2015-06-01');
 			});
 		});
@@ -166,20 +165,22 @@ 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() {
+				var options = {};
 				options.now = options.defaultDate = '2014-06-01'; // a Sunday
 				options.weekends = false;
-				$('#cal').fullCalendar(options);
-				var view = $('#cal').fullCalendar('getView');
+				initCalendar(options);
+				var view = currentCalendar.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() {
+				var options = {};
 				options.now = options.defaultDate = '2014-05-04'; // a Sunday
 				options.weekends = false;
-				$('#cal').fullCalendar(options);
-				var view = $('#cal').fullCalendar('getView');
+				initCalendar(options);
+				var view = currentCalendar.getView();
 				expect(view.start).toEqualMoment('2014-04-28');
 				expect(view.end).toEqualMoment('2014-06-07');
 				expect(view.intervalStart).toEqualMoment('2014-05-01');
@@ -187,14 +188,15 @@ describe('current date', function() {
 			});
 			describe('when navigating back a month', function() {
 				it('should not skip months', function() {
-					options.defaultDate = '2014-07-07';
+					var options = {};
+					options.defaultDate = '2014-07-07';					
 					options.weekends = false;
-					$('#cal').fullCalendar(options);
-					var view = $('#cal').fullCalendar('getView');
+					initCalendar(options);
+					var view = currentCalendar.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');
+					currentCalendar.prev(); // will move to Jun 1, which is a Sunday
+					view = currentCalendar.getView();
 					expect(view.intervalStart).toEqualMoment('2014-06-01');
 					expect(view.intervalEnd).toEqualMoment('2014-07-01');
 				});
@@ -202,10 +204,11 @@ describe('current date', function() {
 		});
 		describeWhenInDay(function() {
 			it('should display the next visible day', function() {
+				var options = {};
 				options.now = options.defaultDate = '2014-06-01'; // a Sunday
 				options.weekends = false;
-				$('#cal').fullCalendar(options);
-				var view = $('#cal').fullCalendar('getView');
+				initCalendar(options);
+				view = currentCalendar.getView();
 				expect(view.start).toEqualMoment('2014-06-02');
 				expect(view.end).toEqualMoment('2014-06-03');
 				expect(view.intervalStart).toEqualMoment('2014-06-02');
@@ -233,16 +236,14 @@ describe('current date', function() {
 	}
 
 	function describeWhenIn(viewName, func) {
-		describe('when in ' + viewName, function() {
-			beforeEach(function() {
-				options.defaultView = viewName;
-			});
+		describe('when in ' + viewName, function() {			
+			pushOptions({defaultView:viewName});
 			func();
 		});
 	}
 
 	function expectViewDates(start, end, titleStart, titleEnd) {
-		var view = $('#cal').fullCalendar('getView');
+		var view = currentCalendar.getView();
 		var calculatedEnd;
 		var title;
 

+ 4 - 8
tests/legacy/custom-view-class.js

@@ -1,9 +1,5 @@
 describe('custom view class', function() {
 
-	beforeEach(function() {
-		affix('#cal');
-	});
-
 	it('calls all standard methods with correct parameters', function() {
 		var FC = $.fullCalendar;
 		var View = FC.View;
@@ -46,7 +42,7 @@ describe('custom view class', function() {
 		CustomView = View.extend(methods);
 		FC.views.custom = CustomView;
 
-		$('#cal').fullCalendar({
+		initCalendar({
 			defaultView: 'custom',
 			defaultDate: '2014-12-25',
 			events: [
@@ -63,15 +59,15 @@ describe('custom view class', function() {
 		expect(methods.setHeight).toHaveBeenCalled();
 		expect(methods.renderEvents).toHaveBeenCalled();
 
-		$('#cal').fullCalendar('rerenderEvents');
+		currentCalendar.rerenderEvents();
 
 		expect(methods.destroyEvents).toHaveBeenCalled();
 
-		$('#cal').fullCalendar('select', '2014-12-25', '2014-01-01');
+		currentCalendar.select('2014-12-25', '2014-01-01');
 
 		expect(methods.renderSelection).toHaveBeenCalled();
 
-		$('#cal').fullCalendar('unselect');
+		currentCalendar.unselect();
 
 		expect(methods.destroySelection).toHaveBeenCalled();
 

+ 94 - 34
tests/legacy/custom-view-duration.js

@@ -1,21 +1,15 @@
-describe('custom view', function() {
-	var options;
-
-	beforeEach(function() {
-		options = {
+describe('custom view', function() {	
+	it('renders a 4 day basic view', function() {
+		var options = {
 			views: {}
 		};
-		affix('#cal');
-	});
-
-	it('renders a 4 day basic view', function() {
 		options.views.basicFourDay = {
 			type: 'basic',
 			duration: { days: 4 }
 		};
 		options.defaultView = 'basicFourDay';
 		options.defaultDate = '2014-12-25';
-		$('#cal').fullCalendar(options);
+		initCalendar(options);
 		expect($('.fc-day-grid .fc-row').length).toBe(1);
 		expect($('.fc-day-grid .fc-row .fc-day').length).toBe(4);
 		expect($('.fc-day-grid .fc-row .fc-day:first'))
@@ -23,6 +17,9 @@ describe('custom view', function() {
 	});
 
 	it('renders a 2 week basic view', function() {
+		var options = {
+			views: {}
+		};
 		options.views.basicTwoWeek = {
 			type: 'basic',
 			duration: { weeks: 2 }
@@ -30,7 +27,7 @@ describe('custom view', function() {
 		options.defaultView = 'basicTwoWeek';
 		options.defaultDate = '2014-12-25';
 		options.firstDay = 2; // Tues
-		$('#cal').fullCalendar(options);
+		initCalendar(options);
 		expect($('.fc-day-grid .fc-row').length).toBe(2);
 		expect($('.fc-day-grid .fc-day').length).toBe(14);
 		expect($('.fc-day-grid .fc-day:first')).toBeMatchedBy('.fc-tue'); // respects start-of-week
@@ -38,17 +35,23 @@ describe('custom view', function() {
 	});
 
 	it('will use the provided options', function() {
+		var options = {
+			views: {}
+		};
 		options.views.basicFourDay = {
 			type: 'basic',
 			duration: { days: 4 },
 			titleFormat: '[special]'
 		};
 		options.defaultView = 'basicFourDay';
-		$('#cal').fullCalendar(options);
+		initCalendar(options);
 		expect($('h2')).toHaveText('special');
 	});
 
 	it('will inherit options from the parent view type', function() {
+		var options = {
+			views: {}
+		};
 		options.views.basic = {
 			titleFormat: '[basictitle]'
 		};
@@ -57,11 +60,14 @@ describe('custom view', function() {
 			duration: { days: 4 }
 		};
 		options.defaultView = 'basicFourDay';
-		$('#cal').fullCalendar(options);
+		initCalendar(options);
 		expect($('h2')).toHaveText('basictitle');
 	});
 
 	it('will override an option from the parent view type', function() {
+		var options = {
+			views: {}
+		};
 		options.views.basic = {
 			titleFormat: '[basictitle]'
 		};
@@ -71,11 +77,14 @@ describe('custom view', function() {
 			titleFormat: '[basicfourweekttitle]'
 		};
 		options.defaultView = 'basicFourDay';
-		$('#cal').fullCalendar(options);
+		initCalendar(options);
 		expect($('h2')).toHaveText('basicfourweekttitle');
 	});
 
 	it('will inherit options from generic "week" type', function() {
+		var options = {
+			views: {}
+		};
 		options.views.week = {
 			titleFormat: '[weektitle]'
 		};
@@ -84,11 +93,14 @@ describe('custom view', function() {
 			duration: { weeks: 1 }
 		};
 		options.defaultView = 'basicOneWeek';
-		$('#cal').fullCalendar(options);
+		initCalendar(options);
 		expect($('h2')).toHaveText('weektitle');
 	});
 
 	it('generic type options for "basic" will override generic "week" options', function() {
+		var options = {
+			views: {}
+		};
 		options.views.week = {
 			titleFormat: '[weektitle]'
 		};
@@ -100,11 +112,14 @@ describe('custom view', function() {
 			duration: { weeks: 1 }
 		};
 		options.defaultView = 'basicOneWeek';
-		$('#cal').fullCalendar(options);
+		initCalendar(options);
 		expect($('h2')).toHaveText('basictitle');
 	});
 
 	it('will not inherit "week" options if more than a single week', function() {
+		var options = {
+			views: {}
+		};
 		options.titleFormat = '[defaultitle]';
 		options.views.week = {
 			titleFormat: '[weektitle]'
@@ -114,18 +129,21 @@ describe('custom view', function() {
 			duration: { weeks: 2 }
 		};
 		options.defaultView = 'basicTwoWeek';
-		$('#cal').fullCalendar(options);
+		initCalendar(options);
 		expect($('h2')).toHaveText('defaultitle');
 	});
 
 	it('renders a 4 day agenda view', function() {
+		var options = {
+			views: {}
+		};
 		options.views.agendaFourDay = {
 			type: 'agenda',
 			duration: { days: 4 }
 		};
 		options.defaultView = 'agendaFourDay';
 		options.defaultDate = '2014-12-25';
-		$('#cal').fullCalendar(options);
+		initCalendar(options);
 		expect($('.fc-day-grid .fc-row').length).toBe(1);
 		expect($('.fc-day-grid .fc-row .fc-day').length).toBe(4);
 		expect($('.fc-time-grid .fc-day').length).toBe(4);
@@ -133,13 +151,16 @@ describe('custom view', function() {
 	});
 
 	it('renders a two week agenda view', function() {
+		var options = {
+			views: {}
+		};
 		options.views.agendaTwoWeek = {
 			type: 'agenda',
 			duration: { weeks: 2 }
 		};
 		options.defaultView = 'agendaTwoWeek';
 		options.defaultDate = '2014-12-25';
-		$('#cal').fullCalendar(options);
+		initCalendar(options);
 		expect($('.fc-day-grid .fc-row').length).toBe(1);
 		expect($('.fc-day-grid .fc-row .fc-day').length).toBe(14); // one long row
 		expect($('.fc-time-grid .fc-day').length).toBe(14);
@@ -147,13 +168,16 @@ describe('custom view', function() {
 	});
 
 	it('renders a two month agenda view', function() {
+		var options = {
+			views: {}
+		};
 		options.views.agendaTwoMonth = {
 			type: 'agenda',
 			duration: { months: 2 }
 		};
 		options.defaultView = 'agendaTwoMonth';
 		options.defaultDate = '2014-11-27';
-		$('#cal').fullCalendar(options);
+		initCalendar(options);
 		expect($('.fc-day-grid .fc-row').length).toBe(1);
 		expect($('.fc-day-grid .fc-row .fc-day').length).toBe(61); // one long row
 		expect($('.fc-time-grid .fc-day').length).toBe(61);
@@ -162,13 +186,16 @@ describe('custom view', function() {
 	});
 
 	it('renders a two month basic view', function() {
+		var options = {
+			views: {}
+		};
 		options.views.basicTwoWeek = {
 			type: 'basic',
 			duration: { months: 2 }
 		};
 		options.defaultView = 'basicTwoWeek';
 		options.defaultDate = '2014-11-27';
-		$('#cal').fullCalendar(options);
+		initCalendar(options);
 		expect($('.fc-day-grid .fc-row').length).toBe(10);
 		expect($('.fc-day-grid .fc-row:first .fc-day').length).toBe(7);
 		expect($('.fc-day-grid .fc-day:first')).toBeMatchedBy('[data-date="2014-10-26"]');
@@ -176,13 +203,16 @@ describe('custom view', function() {
 	});
 
 	it('renders a one year basic view', function() {
+		var options = {
+			views: {}
+		};
 		options.views.basicYear = {
 			type: 'basic',
 			duration: { years: 1 }
 		};
 		options.defaultView = 'basicYear';
 		options.defaultDate = '2014-11-27';
-		$('#cal').fullCalendar(options);
+		initCalendar(options);
 		expect($('.fc-day-grid .fc-day:first')).toBeMatchedBy('[data-date="2013-12-29"]');
 		expect($('.fc-day-grid .fc-day:last')).toBeMatchedBy('[data-date="2015-01-03"]');
 	});
@@ -190,6 +220,9 @@ describe('custom view', function() {
 	describe('buttonText', function() {
 
 		it('accepts buttonText exact-match override', function() {
+			var options = {
+				views: {}
+			};
 			options.buttonText = {
 				custom: 'over-ridden'
 			};
@@ -202,11 +235,14 @@ describe('custom view', function() {
 				center: 'custom,month'
 			};
 			options.defaultView = 'custom';
-			$('#cal').fullCalendar(options);
+			initCalendar(options);
 			expect($('.fc-custom-button')).toHaveText('over-ridden');
 		});
 
 		it('accepts buttonText single-unit-match override', function() {
+			var options = {
+				views: {}
+			};
 			options.buttonText = {
 				day: '1day-over-ridden'
 			};
@@ -219,11 +255,14 @@ describe('custom view', function() {
 				center: 'custom,month'
 			};
 			options.defaultView = 'custom';
-			$('#cal').fullCalendar(options);
+			initCalendar(options);
 			expect($('.fc-custom-button')).toHaveText('1day-over-ridden');
 		});
 
 		it('does not accept buttonText unit-match override when unit is more than one', function() {
+			var options = {
+				views: {}
+			};
 			options.buttonText = {
 				day: '1day!!!???'
 			};
@@ -236,11 +275,14 @@ describe('custom view', function() {
 				center: 'custom,month'
 			};
 			options.defaultView = 'custom';
-			$('#cal').fullCalendar(options);
+			initCalendar(options);
 			expect($('.fc-custom-button')).toHaveText('awesome');
 		});
 
 		it('accepts locale\'s single-unit-match override', function() {
+			var options = {
+				views: {}
+			};
 			options.locale = 'fr';
 			options.views.custom = {
 				type: 'basic',
@@ -250,11 +292,14 @@ describe('custom view', function() {
 				center: 'custom,month'
 			};
 			options.defaultView = 'custom';
-			$('#cal').fullCalendar(options);
+			initCalendar(options);
 			expect($('.fc-custom-button')).toHaveText('Jour');
 		});
 
 		it('accepts explicit View-Specific buttonText, overriding locale\'s single-unit-match override', function() {
+			var options = {
+				views: {}
+			};
 			options.locale = 'fr';
 			options.views.custom = {
 				type: 'basic',
@@ -265,11 +310,14 @@ describe('custom view', function() {
 				center: 'custom,month'
 			};
 			options.defaultView = 'custom';
-			$('#cal').fullCalendar(options);
+			initCalendar(options);
 			expect($('.fc-custom-button')).toHaveText('awesome');
 		});
 
 		it('respects custom view\'s value', function() {
+			var options = {
+				views: {}
+			};
 			options.views.custom = {
 				type: 'basic',
 				duration: { days: 4 },
@@ -279,38 +327,47 @@ describe('custom view', function() {
 				center: 'custom,month'
 			};
 			options.defaultView = 'custom';
-			$('#cal').fullCalendar(options);
+			initCalendar(options);
 			expect($('.fc-custom-button')).toHaveText('awesome');
 		});
 
 		it('respects custom view\'s value, even when a "smart" property name', function() {
+			var options = {
+				views: {}
+			};
 			options.views.basicFourDay = { // "basicFourDay" is a pitfall for smartProperty
 				type: 'basic',
 				duration: { days: 4 },
-				buttonText: 'awesome'
+				buttonText: 'awesome'				
 			};
 			options.header = {
 				center: 'basicFourDay,month'
 			};
 			options.defaultView = 'basicFourDay';
-			$('#cal').fullCalendar(options);
+			initCalendar(options);
 			expect($('.fc-basicFourDay-button')).toHaveText('awesome');
 		});
 
 		it('falls back to humanized duration when not given', function() {
+			var options = {
+				views: {}
+			};
 			options.views.custom = {
 				type: 'basic',
 				duration: { days: 4 }
-			};
+			}			
 			options.header = {
 				center: 'custom,month'
 			};
 			options.defaultView = 'custom';
-			$('#cal').fullCalendar(options);
+			initCalendar(options);
 			expect($('.fc-custom-button')).toHaveText('4 days');
 		});
 
 		it('falls back to humanized duration and respects locale', function() {
+			var options = {
+				views: {}
+			};
 			options.locale = 'fr';
 			options.views.custom = {
 				type: 'basic',
@@ -320,18 +377,21 @@ describe('custom view', function() {
 				center: 'custom,month'
 			};
 			options.defaultView = 'custom';
-			$('#cal').fullCalendar(options);
+			initCalendar(options);
 			expect($('.fc-custom-button')).toHaveText('4 jours');
 			expect($('.fc-month-button')).toHaveText('Mois'); // test for the heck of it
 		});
 
 		it('falls back to view name when view lacks metadata', function() {
 			$.fullCalendar.views.crazy = $.fullCalendar.View.extend();
+			var options = {
+				views: {}
+			};
 			options.header = {
 				center: 'crazy,month'
 			};
 			options.defaultView = 'crazy';
-			$('#cal').fullCalendar(options);
+			initCalendar(options);
 			expect($('.fc-crazy-button')).toHaveText('crazy');
 			delete $.fullCalendar.views.crazy;
 		});