소스 검색

updates tests/legacy/{ListView,allDayDefault,background-events}.js

kyle roux 8 년 전
부모
커밋
36d819aecc
3개의 변경된 파일185개의 추가작업 그리고 170개의 파일을 삭제
  1. 66 62
      tests/legacy/ListView.js
  2. 25 33
      tests/legacy/allDayDefault.js
  3. 94 75
      tests/legacy/background-events.js

+ 66 - 62
tests/legacy/ListView.js

@@ -1,32 +1,26 @@
 describe('ListView rendering', function() {
 describe('ListView rendering', function() {
-	var options;
-
-	beforeEach(function() {
-		affix('#cal');
-		options = {
-			defaultView: 'listWeek',
-			now: '2016-08-20'
-		};
+	pushOptions({
+		defaultView: 'listWeek',
+		now: '2016-08-20'
 	});
 	});
 
 
 	describe('with all-day events', function() {
 	describe('with all-day events', function() {
 
 
 		describe('when single-day', function() {
 		describe('when single-day', function() {
-			beforeEach(function() {
-				options.events = [
-					{
-						title: 'event 1',
-						start: '2016-08-15'
-					},
-					{
-						title: 'event 2',
-						start: '2016-08-17'
-					}
-				];
-			});
+			pushOptions({
+				events: [
+				{
+					title: 'event 1',
+					start: '2016-08-15'
+				},
+				{
+					title: 'event 2',
+					start: '2016-08-17'
+				}
+			]});
 
 
 			it('renders only days with events', function() {
 			it('renders only days with events', function() {
-				$('#cal').fullCalendar(options);
+				initCalendar();
 
 
 				var days = getDayInfo();
 				var days = getDayInfo();
 				var events = getEventInfo();
 				var events = getEventInfo();
@@ -43,29 +37,29 @@ describe('ListView rendering', function() {
 			});
 			});
 
 
 			it('filters events through eventRender', function() {
 			it('filters events through eventRender', function() {
+				var options = {};
 				options.eventRender = function(event, el) {
 				options.eventRender = function(event, el) {
 					el.find('.fc-event-dot').replaceWith('<span class="custom-icon" />');
 					el.find('.fc-event-dot').replaceWith('<span class="custom-icon" />');
 				};
 				};
 
 
-				$('#cal').fullCalendar(options);
+				initCalendar(options);
 
 
 				expect($('.custom-icon').length).toBe(2);
 				expect($('.custom-icon').length).toBe(2);
 			});
 			});
 		});
 		});
 
 
 		describe('when multi-day', function() {
 		describe('when multi-day', function() {
-			beforeEach(function() {
-				options.events = [
-					{
-						title: 'event 1',
-						start: '2016-08-15',
-						end: '2016-08-18' // 3 days
-					}
-				];
-			});
+			pushOptions({
+				events: [
+				{
+					title: 'event 1',
+					start: '2016-08-15',
+					end: '2016-08-18' // 3 days
+				}
+			]})
 
 
 			it('renders all-day for every day', function() {
 			it('renders all-day for every day', function() {
-				$('#cal').fullCalendar(options);
+				initCalendar();
 
 
 				var events = getEventInfo();
 				var events = getEventInfo();
 
 
@@ -83,22 +77,21 @@ describe('ListView rendering', function() {
 	describe('with timed events', function() {
 	describe('with timed events', function() {
 
 
 		describe('when single-day', function() {
 		describe('when single-day', function() {
-			beforeEach(function() {
-				options.events = [
-					{
-						title: 'event 1',
-						start: '2016-08-15T07:00'
-					},
-					{
-						title: 'event 2',
-						start: '2016-08-17T09:00',
-						end: '2016-08-17T11:00'
-					}
-				];
-			});
+			pushOptions({
+				events: [
+				{
+					title: 'event 1',
+					start: '2016-08-15T07:00'
+				},
+				{
+					title: 'event 2',
+					start: '2016-08-17T09:00',
+					end: '2016-08-17T11:00'
+				}
+			]});
 
 
 			it('renders times', function() {
 			it('renders times', function() {
-				$('#cal').fullCalendar(options);
+				initCalendar();
 
 
 				var events = getEventInfo();
 				var events = getEventInfo();
 
 
@@ -110,8 +103,9 @@ describe('ListView rendering', function() {
 			});
 			});
 
 
 			it('doesn\'t render times when displayEventTime is false', function() {
 			it('doesn\'t render times when displayEventTime is false', function() {
+				var options = {};
 				options.displayEventTime = false;
 				options.displayEventTime = false;
-				$('#cal').fullCalendar(options);
+				initCalendar(options);
 
 
 				var events = getEventInfo();
 				var events = getEventInfo();
 
 
@@ -123,8 +117,9 @@ describe('ListView rendering', function() {
 			});
 			});
 
 
 			it('doesn\'t render end times when displayEventEnd is false', function() {
 			it('doesn\'t render end times when displayEventEnd is false', function() {
+				var options = {};
 				options.displayEventEnd = false;
 				options.displayEventEnd = false;
-				$('#cal').fullCalendar(options);
+				initCalendar(options);
 
 
 				var events = getEventInfo();
 				var events = getEventInfo();
 
 
@@ -137,8 +132,9 @@ describe('ListView rendering', function() {
 
 
 			// regression test for when localized event dates get unlocalized and leak into view rendering
 			// regression test for when localized event dates get unlocalized and leak into view rendering
 			it('renders dates and times in locale', function() {
 			it('renders dates and times in locale', function() {
+				var options = {};
 				options.locale = 'fr';
 				options.locale = 'fr';
-				$('#cal').fullCalendar(options);
+				initCalendar(options);
 
 
 				var days = getDayInfo();
 				var days = getDayInfo();
 				var events = getEventInfo();
 				var events = getEventInfo();
@@ -160,11 +156,12 @@ describe('ListView rendering', function() {
 		});
 		});
 
 
 		describe('when multi-day', function() {
 		describe('when multi-day', function() {
-			beforeEach(function() {
-				options.nextDayThreshold = '00:00';
+			pushOptions({
+				nextDayThreshold: '00:00'
 			});
 			});
 
 
 			it('renders partial and full days', function() {
 			it('renders partial and full days', function() {
+				var options = {};
 				options.events = [
 				options.events = [
 					{
 					{
 						title: 'event 1',
 						title: 'event 1',
@@ -172,7 +169,7 @@ describe('ListView rendering', function() {
 						end: '2016-08-17T11:00'
 						end: '2016-08-17T11:00'
 					}
 					}
 				];
 				];
-				$('#cal').fullCalendar(options);
+				initCalendar(options);
 
 
 				var events = getEventInfo();
 				var events = getEventInfo();
 
 
@@ -186,6 +183,7 @@ describe('ListView rendering', function() {
 			});
 			});
 
 
 			it('truncates an out-of-range start', function() {
 			it('truncates an out-of-range start', function() {
+				var options = {};
 				options.events = [
 				options.events = [
 					{
 					{
 						title: 'event 1',
 						title: 'event 1',
@@ -193,7 +191,7 @@ describe('ListView rendering', function() {
 						end: '2016-08-16T11:00'
 						end: '2016-08-16T11:00'
 					}
 					}
 				];
 				];
-				$('#cal').fullCalendar(options);
+				initCalendar(options);
 
 
 				var events = getEventInfo();
 				var events = getEventInfo();
 
 
@@ -207,6 +205,7 @@ describe('ListView rendering', function() {
 			});
 			});
 
 
 			it('truncates an out-of-range start', function() {
 			it('truncates an out-of-range start', function() {
+				var options = {};
 				options.events = [
 				options.events = [
 					{
 					{
 						title: 'event 1',
 						title: 'event 1',
@@ -214,7 +213,7 @@ describe('ListView rendering', function() {
 						end: '2016-08-21T11:00'
 						end: '2016-08-21T11:00'
 					}
 					}
 				];
 				];
-				$('#cal').fullCalendar(options);
+				initCalendar(options);
 
 
 				var events = getEventInfo();
 				var events = getEventInfo();
 
 
@@ -229,6 +228,7 @@ describe('ListView rendering', function() {
 		});
 		});
 
 
 		it('renders same days when equal to nextDayThreshold', function() {
 		it('renders same days when equal to nextDayThreshold', function() {
+			var options = {};
 			options.nextDayThreshold = '09:00';
 			options.nextDayThreshold = '09:00';
 			options.events = [
 			options.events = [
 				{
 				{
@@ -238,7 +238,7 @@ describe('ListView rendering', function() {
 				}
 				}
 			];
 			];
 
 
-			$('#cal').fullCalendar(options);
+			initCalendar(options);
 
 
 			var events = getEventInfo();
 			var events = getEventInfo();
 
 
@@ -252,6 +252,7 @@ describe('ListView rendering', function() {
 		});
 		});
 
 
 		it('renders fewer days when before nextDayThreshold', function() {
 		it('renders fewer days when before nextDayThreshold', function() {
+			var options = {};
 			options.nextDayThreshold = '09:00';
 			options.nextDayThreshold = '09:00';
 			options.events = [
 			options.events = [
 				{
 				{
@@ -261,7 +262,7 @@ describe('ListView rendering', function() {
 				}
 				}
 			];
 			];
 
 
-			$('#cal').fullCalendar(options);
+			initCalendar(options);
 
 
 			var events = getEventInfo();
 			var events = getEventInfo();
 
 
@@ -275,12 +276,13 @@ describe('ListView rendering', function() {
 
 
 	describe('when an event has no title', function() {
 	describe('when an event has no title', function() {
 		it('renders no text for its title', function() {
 		it('renders no text for its title', function() {
+			var options = {};
 			options.events = [
 			options.events = [
 				{
 				{
 					start: '2016-08-15'
 					start: '2016-08-15'
 				}
 				}
 			];
 			];
-			$('#cal').fullCalendar(options);
+			initCalendar(options);
 
 
 			var events = getEventInfo();
 			var events = getEventInfo();
 
 
@@ -292,12 +294,13 @@ describe('ListView rendering', function() {
 
 
 	describe('when no events', function() {
 	describe('when no events', function() {
 		it('renders an empty message', function() {
 		it('renders an empty message', function() {
-			$('#cal').fullCalendar(options);
+			initCalendar();
 			expect(getIsEmptyMessage()).toBe(true);
 			expect(getIsEmptyMessage()).toBe(true);
 		});
 		});
 	});
 	});
 
 
 	it('sorts events correctly', function() {
 	it('sorts events correctly', function() {
+		var options = {};
 		options.now = '2016-08-29';
 		options.now = '2016-08-29';
 		options.events = [
 		options.events = [
 			{
 			{
@@ -340,7 +343,7 @@ describe('ListView rendering', function() {
 			}
 			}
 		];
 		];
 
 
-		$('#cal').fullCalendar(options);
+		initCalendar(options);
 
 
 		var days = getDayInfo();
 		var days = getDayInfo();
 		var events = getEventInfo();
 		var events = getEventInfo();
@@ -384,18 +387,19 @@ describe('ListView rendering', function() {
 	});
 	});
 
 
 	it('updates rendered events despite fetch range being lazy', function() {
 	it('updates rendered events despite fetch range being lazy', function() {
+		var options = {};
 		options.now = '2016-09-12';
 		options.now = '2016-09-12';
 		options.defaultView = 'month';
 		options.defaultView = 'month';
 		options.events = [
 		options.events = [
 			{ title: 'event1', start: '2016-09-12' }
 			{ title: 'event1', start: '2016-09-12' }
 		];
 		];
 
 
-		$('#cal').fullCalendar(options);
-		$('#cal').fullCalendar('changeView', 'listWeek');
+		initCalendar(options);
+		currentCalendar.changeView('listWeek');
 
 
 		expect($('.fc-list-item').length).toBe(1);
 		expect($('.fc-list-item').length).toBe(1);
 
 
-		$('#cal').fullCalendar('prev');
+		currentCalendar.prev();
 
 
 		expect($('.fc-list-item').length).toBe(0);
 		expect($('.fc-list-item').length).toBe(0);
 	});
 	});

+ 25 - 33
tests/legacy/allDayDefault.js

@@ -1,14 +1,9 @@
 
 
 describe('allDayDefault', function() {
 describe('allDayDefault', function() {
-
-	beforeEach(function() {
-		affix('#cal');
-	});
-
 	describe('when undefined', function() {
 	describe('when undefined', function() {
 
 
 		it('guesses false if T in ISO8601 start date', function() {
 		it('guesses false if T in ISO8601 start date', function() {
-			$('#cal').fullCalendar({
+			initCalendar({
 				events: [
 				events: [
 					{
 					{
 						id: '1',
 						id: '1',
@@ -16,12 +11,12 @@ describe('allDayDefault', function() {
 					}
 					}
 				]
 				]
 			});
 			});
-			var eventObj = $('#cal').fullCalendar('clientEvents', '1')[0];
+			var eventObj = currentCalendar.clientEvents('1')[0];
 			expect(eventObj.allDay).toEqual(false);
 			expect(eventObj.allDay).toEqual(false);
 		});
 		});
 
 
 		it('guesses false if T in ISO8601 end date', function() {
 		it('guesses false if T in ISO8601 end date', function() {
-			$('#cal').fullCalendar({
+			initCalendar({
 				events: [
 				events: [
 					{
 					{
 						id: '1',
 						id: '1',
@@ -30,12 +25,12 @@ describe('allDayDefault', function() {
 					}
 					}
 				]
 				]
 			});
 			});
-			var eventObj = $('#cal').fullCalendar('clientEvents', '1')[0];
+			var eventObj = currentCalendar.clientEvents('1')[0];
 			expect(eventObj.allDay).toEqual(false);
 			expect(eventObj.allDay).toEqual(false);
 		});
 		});
 
 
 		it('guesses true if ISO8601 start date with no time and unspecified end date', function() {
 		it('guesses true if ISO8601 start date with no time and unspecified end date', function() {
-			$('#cal').fullCalendar({
+			initCalendar({
 				events: [
 				events: [
 					{
 					{
 						id: '1',
 						id: '1',
@@ -43,12 +38,12 @@ describe('allDayDefault', function() {
 					}
 					}
 				]
 				]
 			});
 			});
-			var eventObj = $('#cal').fullCalendar('clientEvents', '1')[0];
+			var eventObj = currentCalendar.clientEvents('1')[0];			
 			expect(eventObj.allDay).toEqual(true);
 			expect(eventObj.allDay).toEqual(true);
 		});
 		});
 
 
 		it('guesses true if ISO8601 start and end date with no times', function() {
 		it('guesses true if ISO8601 start and end date with no times', function() {
-			$('#cal').fullCalendar({
+			initCalendar({
 				events: [
 				events: [
 					{
 					{
 						id: '1',
 						id: '1',
@@ -57,12 +52,12 @@ describe('allDayDefault', function() {
 					}
 					}
 				]
 				]
 			});
 			});
-			var eventObj = $('#cal').fullCalendar('clientEvents', '1')[0];
+			var eventObj = currentCalendar.clientEvents('1')[0];			
 			expect(eventObj.allDay).toEqual(true);
 			expect(eventObj.allDay).toEqual(true);
 		});
 		});
 
 
 		it('guesses false if start is a unix timestamp (which implies it has a time)', function() {
 		it('guesses false if start is a unix timestamp (which implies it has a time)', function() {
-			$('#cal').fullCalendar({
+			initCalendar({
 				events: [
 				events: [
 					{
 					{
 						id: '1',
 						id: '1',
@@ -71,12 +66,13 @@ describe('allDayDefault', function() {
 					}
 					}
 				]
 				]
 			});
 			});
-			var eventObj = $('#cal').fullCalendar('clientEvents', '1')[0];
+			
+			var eventObj = currentCalendar.clientEvents('1')[0];
 			expect(eventObj.allDay).toEqual(false);
 			expect(eventObj.allDay).toEqual(false);
 		});
 		});
 
 
 		it('guesses false if end is a unix timestamp (which implies it has a time)', function() {
 		it('guesses false if end is a unix timestamp (which implies it has a time)', function() {
-			$('#cal').fullCalendar({
+			initCalendar({
 				events: [
 				events: [
 					{
 					{
 						id: '1',
 						id: '1',
@@ -85,7 +81,7 @@ describe('allDayDefault', function() {
 					}
 					}
 				]
 				]
 			});
 			});
-			var eventObj = $('#cal').fullCalendar('clientEvents', '1')[0];
+			var eventObj = currentCalendar.clientEvents('1')[0];			
 			expect(eventObj.allDay).toEqual(false);
 			expect(eventObj.allDay).toEqual(false);
 		});
 		});
 
 
@@ -94,7 +90,7 @@ describe('allDayDefault', function() {
 	describe('when specified', function() {
 	describe('when specified', function() {
 
 
 		it('has an effect when an event\'s allDay is not specified', function() {
 		it('has an effect when an event\'s allDay is not specified', function() {
-			$('#cal').fullCalendar({
+			initCalendar({
 				allDayDefault: false,
 				allDayDefault: false,
 				events: [
 				events: [
 					{
 					{
@@ -103,12 +99,12 @@ describe('allDayDefault', function() {
 					}
 					}
 				]
 				]
 			});
 			});
-			var eventObj = $('#cal').fullCalendar('clientEvents', '1')[0];
+			var eventObj = currentCalendar.clientEvents('1')[0];
 			expect(eventObj.allDay).toEqual(false);
 			expect(eventObj.allDay).toEqual(false);
 		});
 		});
 
 
 		it('has no effect when an event\'s allDay is specified', function() {
 		it('has no effect when an event\'s allDay is specified', function() {
-			$('#cal').fullCalendar({
+			initCalendar({
 				allDayDefault: false,
 				allDayDefault: false,
 				events: [
 				events: [
 					{
 					{
@@ -118,7 +114,7 @@ describe('allDayDefault', function() {
 					}
 					}
 				]
 				]
 			});
 			});
-			var eventObj = $('#cal').fullCalendar('clientEvents', '1')[0];
+			var eventObj = currentCalendar.clientEvents('1')[0];
 			expect(eventObj.allDay).toEqual(true);
 			expect(eventObj.allDay).toEqual(true);
 		});
 		});
 
 
@@ -128,12 +124,8 @@ describe('allDayDefault', function() {
 
 
 describe('source.allDayDefault', function() {
 describe('source.allDayDefault', function() {
 
 
-	beforeEach(function() {
-		affix('#cal');
-	});
-
 	it('has an effect when an event\'s allDay is not specified', function() {
 	it('has an effect when an event\'s allDay is not specified', function() {
-		$('#cal').fullCalendar({
+		initCalendar({
 			eventSources: [
 			eventSources: [
 				{
 				{
 					allDayDefault: false,
 					allDayDefault: false,
@@ -146,12 +138,12 @@ describe('source.allDayDefault', function() {
 				}
 				}
 			]
 			]
 		});
 		});
-		var eventObj = $('#cal').fullCalendar('clientEvents', '1')[0];
+		var eventObj = currentCalendar.clientEvents('1')[0];
 		expect(eventObj.allDay).toEqual(false);
 		expect(eventObj.allDay).toEqual(false);
 	});
 	});
 
 
 	it('a true value can override the global allDayDefault', function() {
 	it('a true value can override the global allDayDefault', function() {
-		$('#cal').fullCalendar({
+		initCalendar({
 			allDayDefault: false,
 			allDayDefault: false,
 			eventSources: [
 			eventSources: [
 				{
 				{
@@ -165,12 +157,12 @@ describe('source.allDayDefault', function() {
 				}
 				}
 			]
 			]
 		});
 		});
-		var eventObj = $('#cal').fullCalendar('clientEvents', '1')[0];
+		var eventObj = currentCalendar.clientEvents('1')[0];
 		expect(eventObj.allDay).toEqual(true);
 		expect(eventObj.allDay).toEqual(true);
 	});
 	});
 
 
 	it('a false value can override the global allDayDefault', function() {
 	it('a false value can override the global allDayDefault', function() {
-		$('#cal').fullCalendar({
+		initCalendar({
 			allDayDefault: true,
 			allDayDefault: true,
 			eventSources: [
 			eventSources: [
 				{
 				{
@@ -184,12 +176,12 @@ describe('source.allDayDefault', function() {
 				}
 				}
 			]
 			]
 		});
 		});
-		var eventObj = $('#cal').fullCalendar('clientEvents', '1')[0];
+		var eventObj = currentCalendar.clientEvents('1')[0];
 		expect(eventObj.allDay).toEqual(false);
 		expect(eventObj.allDay).toEqual(false);
 	});
 	});
 
 
 	it('has no effect when an event\'s allDay is specified', function() {
 	it('has no effect when an event\'s allDay is specified', function() {
-		$('#cal').fullCalendar({
+		initCalendar({
 			eventSources: [
 			eventSources: [
 				{
 				{
 					allDayDefault: true,
 					allDayDefault: true,
@@ -203,7 +195,7 @@ describe('source.allDayDefault', function() {
 				}
 				}
 			]
 			]
 		});
 		});
-		var eventObj = $('#cal').fullCalendar('clientEvents', '1')[0];
+		var eventObj = currentCalendar.clientEvents('1')[0];
 		expect(eventObj.allDay).toEqual(false);
 		expect(eventObj.allDay).toEqual(false);
 	});
 	});
 
 

+ 94 - 75
tests/legacy/background-events.js

@@ -1,26 +1,18 @@
 
 
 describe('background events', function() {
 describe('background events', function() {
 
 
-	// SEE ALSO: event-color.js
-
-	var options;
-
-	beforeEach(function() {
-		options = {
-			defaultDate: '2014-11-04',
-			scrollTime: '00:00'
-		};
-		affix('#cal');
-		$('#cal').width(1100);
+	// SEE ALSO: event-color.js	
+	pushOptions({
+		defaultDate: '2014-11-04',
+		scrollTime: '00:00'
 	});
 	});
 
 
-	describe('when in month view', function() {
-		beforeEach(function() {
-			options.defaultView = 'month';
-		});
+	describe('when in month view', function() {		
+		pushOptions({defaultView:'month'});		
 
 
 		describe('when LTR', function() {
 		describe('when LTR', function() {
 			it('render correctly on a single day', function(done) {
 			it('render correctly on a single day', function(done) {
+				var options = {};
 				options.events = [ {
 				options.events = [ {
 					title: 'hi',
 					title: 'hi',
 					start: '2014-11-04',
 					start: '2014-11-04',
@@ -34,9 +26,10 @@ describe('background events', function() {
 					expect($('.fc-bgevent .fc-resizer').length).toBe(0); // can't resize
 					expect($('.fc-bgevent .fc-resizer').length).toBe(0); // can't resize
 					done();
 					done();
 				};
 				};
-				$('#cal').fullCalendar(options);
+				initCalendar(options);
 			});
 			});
 			it('render correctly spanning multiple weeks', function(done) {
 			it('render correctly spanning multiple weeks', function(done) {
+				var options = {};
 				options.events = [ {
 				options.events = [ {
 					title: 'hi',
 					title: 'hi',
 					start: '2014-11-04',
 					start: '2014-11-04',
@@ -52,9 +45,10 @@ describe('background events', function() {
 					expect($('.fc-event').length).toBe(0);
 					expect($('.fc-event').length).toBe(0);
 					done();
 					done();
 				};
 				};
-				$('#cal').fullCalendar(options);
+				initCalendar(options);
 			});
 			});
 			it('render correctly when two span on top of each other', function(done) {
 			it('render correctly when two span on top of each other', function(done) {
+				var options = {};
 				options.events = [
 				options.events = [
 					{
 					{
 						start: '2014-11-04',
 						start: '2014-11-04',
@@ -75,10 +69,11 @@ describe('background events', function() {
 					expect($('.fc-event').length).toBe(0);
 					expect($('.fc-event').length).toBe(0);
 					done();
 					done();
 				};
 				};
-				$('#cal').fullCalendar(options);
+				initCalendar(options);
 			});
 			});
 			describe('when weekNumbers', function() {
 			describe('when weekNumbers', function() {
 				it('renders to right of week numbers', function(done) {
 				it('renders to right of week numbers', function(done) {
+					var options = {};
 					options.weekNumbers = true;
 					options.weekNumbers = true;
 					options.events = [ {
 					options.events = [ {
 						start: '2014-11-02',
 						start: '2014-11-02',
@@ -92,10 +87,11 @@ describe('background events', function() {
 						expect($('.fc-event').length).toBe(0);
 						expect($('.fc-event').length).toBe(0);
 						done();
 						done();
 					};
 					};
-					$('#cal').fullCalendar(options);
+					initCalendar(options);
 				});
 				});
 			});
 			});
 			it('renders "business hours" on whole days', function(done) {
 			it('renders "business hours" on whole days', function(done) {
+				var options = {};
 				options.businessHours = true;
 				options.businessHours = true;
 				options.eventAfterAllRender = function() {
 				options.eventAfterAllRender = function() {
 					setTimeout(function() { // no trigger when business hours renders. this will have to do.
 					setTimeout(function() { // no trigger when business hours renders. this will have to do.
@@ -103,15 +99,15 @@ describe('background events', function() {
 						done();
 						done();
 					}, 0)
 					}, 0)
 				};
 				};
-				$('#cal').fullCalendar(options);
+				initCalendar(options);
 			});
 			});
 		});
 		});
 
 
-		describe('when RTL', function() {
-			beforeEach(function() {
-				options.isRTL = true;
-			});
+		describe('when RTL', function() {			
+			pushOptions({isRTL: true});
+			
 			it('render correctly on a single day', function(done) {
 			it('render correctly on a single day', function(done) {
+				var options = {};
 				options.events = [ {
 				options.events = [ {
 					title: 'hi',
 					title: 'hi',
 					start: '2014-11-04',
 					start: '2014-11-04',
@@ -124,9 +120,10 @@ describe('background events', function() {
 					expect($('.fc-event').length).toBe(0);
 					expect($('.fc-event').length).toBe(0);
 					done();
 					done();
 				};
 				};
-				$('#cal').fullCalendar(options);
+				initCalendar(options);
 			});
 			});
 			it('render correctly spanning multiple weeks', function(done) {
 			it('render correctly spanning multiple weeks', function(done) {
+				var options = {};
 				options.events = [ {
 				options.events = [ {
 					title: 'hi',
 					title: 'hi',
 					start: '2014-11-04',
 					start: '2014-11-04',
@@ -142,10 +139,11 @@ describe('background events', function() {
 					expect($('.fc-event').length).toBe(0);
 					expect($('.fc-event').length).toBe(0);
 					done();
 					done();
 				};
 				};
-				$('#cal').fullCalendar(options);
+				initCalendar(options);
 			});
 			});
 			describe('when weekNumbers', function() {
 			describe('when weekNumbers', function() {
 				it('renders to left of week numbers', function(done) {
 				it('renders to left of week numbers', function(done) {
+					var options = {};
 					options.weekNumbers = true;
 					options.weekNumbers = true;
 					options.events = [ {
 					options.events = [ {
 						start: '2014-11-02',
 						start: '2014-11-02',
@@ -159,7 +157,7 @@ describe('background events', function() {
 						expect($('.fc-event').length).toBe(0);
 						expect($('.fc-event').length).toBe(0);
 						done();
 						done();
 					};
 					};
-					$('#cal').fullCalendar(options);
+					initCalendar(options);
 				});
 				});
 			});
 			});
 		});
 		});
@@ -168,6 +166,7 @@ describe('background events', function() {
 
 
 			describe('when LTR', function() {
 			describe('when LTR', function() {
 				it('render correctly on a single day', function(done) {
 				it('render correctly on a single day', function(done) {
+					var options = {};
 					options.events = [ {
 					options.events = [ {
 						title: 'hi',
 						title: 'hi',
 						start: '2014-11-04',
 						start: '2014-11-04',
@@ -190,9 +189,10 @@ describe('background events', function() {
 						expect($('.fc-event').length).toBe(0);
 						expect($('.fc-event').length).toBe(0);
 						done();
 						done();
 					};
 					};
-					$('#cal').fullCalendar(options);
+					initCalendar(options);
 				});
 				});
 				it('render correctly spanning multiple weeks', function(done) {
 				it('render correctly spanning multiple weeks', function(done) {
+					var options = {};
 					options.events = [ {
 					options.events = [ {
 						title: 'hi',
 						title: 'hi',
 						start: '2014-11-04',
 						start: '2014-11-04',
@@ -217,9 +217,10 @@ describe('background events', function() {
 						expect($('.fc-event').length).toBe(0);
 						expect($('.fc-event').length).toBe(0);
 						done();
 						done();
 					};
 					};
-					$('#cal').fullCalendar(options);
+					initCalendar(options);
 				});
 				});
 				it('render correctly when starts before start of month', function(done) {
 				it('render correctly when starts before start of month', function(done) {
+					var options = {};
 					options.events = [ {
 					options.events = [ {
 						start: '2014-10-24',
 						start: '2014-10-24',
 						end: '2014-11-06',
 						end: '2014-11-06',
@@ -239,9 +240,10 @@ describe('background events', function() {
 
 
 						done();
 						done();
 					};
 					};
-					$('#cal').fullCalendar(options);
+					initCalendar(options);
 				});
 				});
 				it('render correctly when ends after end of month', function(done) {
 				it('render correctly when ends after end of month', function(done) {
+					var options = {};
 					options.events = [ {
 					options.events = [ {
 						start: '2014-11-27',
 						start: '2014-11-27',
 						end: '2014-12-08',
 						end: '2014-12-08',
@@ -261,9 +263,10 @@ describe('background events', function() {
 
 
 						done();
 						done();
 					};
 					};
-					$('#cal').fullCalendar(options);
+					initCalendar(options);
 				});
 				});
 				it('render correctly with two related events, in reverse order', function(done) {
 				it('render correctly with two related events, in reverse order', function(done) {
+					var options = {};
 					options.events = [
 					options.events = [
 						{
 						{
 							id: 'hi',
 							id: 'hi',
@@ -293,15 +296,15 @@ describe('background events', function() {
 
 
 						done();
 						done();
 					};
 					};
-					$('#cal').fullCalendar(options);
+					initCalendar(options);
 				});
 				});
 			});
 			});
 
 
-			describe('when RTL', function() {
-				beforeEach(function() {
-					options.isRTL = true;
-				});
+			describe('when RTL', function() {			
+				pushOptions({isRTL:true});
+				
 				it('render correctly on a single day', function(done) {
 				it('render correctly on a single day', function(done) {
+					var options = {};
 					options.events = [ {
 					options.events = [ {
 						title: 'hi',
 						title: 'hi',
 						start: '2014-11-04',
 						start: '2014-11-04',
@@ -324,13 +327,14 @@ describe('background events', function() {
 
 
 						done();
 						done();
 					};
 					};
-					$('#cal').fullCalendar(options);
+					initCalendar(options);
 				});
 				});
 			});
 			});
 		});
 		});
 
 
 		describe('when in month view', function() {
 		describe('when in month view', function() {
 			it('can be activated when rendering set on the source', function(done) {
 			it('can be activated when rendering set on the source', function(done) {
+				var options = {};
 				options.defaultView = 'month';
 				options.defaultView = 'month';
 				options.eventSources = [ {
 				options.eventSources = [ {
 					rendering: 'background',
 					rendering: 'background',
@@ -343,12 +347,13 @@ describe('background events', function() {
 					expect($('.fc-event').length).toBe(0);
 					expect($('.fc-event').length).toBe(0);
 					done();
 					done();
 				};
 				};
-				$('#cal').fullCalendar(options);
+				initCalendar(options);
 			});
 			});
 		});
 		});
 
 
 		describe('when in agenda view and timed event', function() {
 		describe('when in agenda view and timed event', function() {
 			it('can be activated when rendering set on the source', function(done) {
 			it('can be activated when rendering set on the source', function(done) {
+				var options = {};
 				options.defaultView = 'agendaWeek';
 				options.defaultView = 'agendaWeek';
 				options.eventSources = [ {
 				options.eventSources = [ {
 					rendering: 'background',
 					rendering: 'background',
@@ -361,18 +366,17 @@ describe('background events', function() {
 					expect($('.fc-event').length).toBe(0);
 					expect($('.fc-event').length).toBe(0);
 					done();
 					done();
 				};
 				};
-				$('#cal').fullCalendar(options);
+				initCalendar(options);
 			});
 			});
 		});
 		});
 	});
 	});
 
 
-	describe('when in agendaWeek view', function() {
-		beforeEach(function() {
-			options.defaultView = 'agendaWeek';
-		});
+	describe('when in agendaWeek view', function() {		
+		pushOptions({defaultView:'agendaWeek'});		
 
 
 		describe('when LTR', function() {
 		describe('when LTR', function() {
 			it('render correctly on one day', function(done) {
 			it('render correctly on one day', function(done) {
+				var options = {};
 				options.events = [ {
 				options.events = [ {
 					start: '2014-11-04T01:00:00',
 					start: '2014-11-04T01:00:00',
 					end: '2014-11-04T05:00:00',
 					end: '2014-11-04T05:00:00',
@@ -387,9 +391,10 @@ describe('background events', function() {
 					expect($('.fc-bgevent .fc-resizer').length).toBe(0); // can't resize
 					expect($('.fc-bgevent .fc-resizer').length).toBe(0); // can't resize
 					done();
 					done();
 				};
 				};
-				$('#cal').fullCalendar(options);
+				initCalendar(options);
 			});
 			});
 			it('render correctly spanning multiple days', function(done) {
 			it('render correctly spanning multiple days', function(done) {
+				var options = {};
 				options.events = [ {
 				options.events = [ {
 					start: '2014-11-04T01:00:00',
 					start: '2014-11-04T01:00:00',
 					end: '2014-11-05T05:00:00',
 					end: '2014-11-05T05:00:00',
@@ -402,9 +407,10 @@ describe('background events', function() {
 					// TODO: maybe check y coords
 					// TODO: maybe check y coords
 					done();
 					done();
 				};
 				};
-				$('#cal').fullCalendar(options);
+				initCalendar(options);
 			});
 			});
 			it('render correctly when two span on top of each other', function(done) {
 			it('render correctly when two span on top of each other', function(done) {
+				var options = {};
 				options.events = [
 				options.events = [
 					{
 					{
 						start: '2014-11-04T01:00:00',
 						start: '2014-11-04T01:00:00',
@@ -424,22 +430,24 @@ describe('background events', function() {
 					// TODO: maybe check y coords
 					// TODO: maybe check y coords
 					done();
 					done();
 				};
 				};
-				$('#cal').fullCalendar(options);
+				initCalendar(options);
 			});
 			});
 			describe('when businessHours', function() {
 			describe('when businessHours', function() {
 				it('renders correctly if assumed default', function() {
 				it('renders correctly if assumed default', function() {
+					var options = {};
 					options.businessHours = true;
 					options.businessHours = true;
-					$('#cal').fullCalendar(options);
+					initCalendar(options);
 					expect($('.fc-day-grid .fc-nonbusiness').length).toBe(2); // whole days in the day area
 					expect($('.fc-day-grid .fc-nonbusiness').length).toBe(2); // whole days in the day area
 					expect($('.fc-time-grid .fc-nonbusiness').length).toBe(12); // strips of gray on the timed area
 					expect($('.fc-time-grid .fc-nonbusiness').length).toBe(12); // strips of gray on the timed area
 				});
 				});
 				it('renders correctly if custom', function() {
 				it('renders correctly if custom', function() {
+					var options = {};
 					options.businessHours = {
 					options.businessHours = {
 						start: '02:00',
 						start: '02:00',
 						end: '06:00',
 						end: '06:00',
 						dow: [ 1, 2, 3, 4 ] // Mon-Thu
 						dow: [ 1, 2, 3, 4 ] // Mon-Thu
 					};
 					};
-					$('#cal').fullCalendar(options);
+					initCalendar(options);
 
 
 					// whole days
 					// whole days
 					expect($('.fc-day-grid .fc-nonbusiness').length).toBe(2); // each multi-day stretch is one element
 					expect($('.fc-day-grid .fc-nonbusiness').length).toBe(2); // each multi-day stretch is one element
@@ -456,11 +464,10 @@ describe('background events', function() {
 				});
 				});
 			});
 			});
 		});
 		});
-		describe('when RTL', function() {
-			beforeEach(function() {
-				options.isRTL = true;
-			});
+		describe('when RTL', function() {			
+			pushOptions({isRTL:true});
 			it('render correctly on one day', function(done) {
 			it('render correctly on one day', function(done) {
+				var options = {};
 				options.events = [ {
 				options.events = [ {
 					start: '2014-11-04T01:00:00',
 					start: '2014-11-04T01:00:00',
 					end: '2014-11-04T05:00:00',
 					end: '2014-11-04T05:00:00',
@@ -473,9 +480,10 @@ describe('background events', function() {
 					expect($('.fc-bgevent')).toBeAbove('.fc-slats tr:eq(10)'); // 5am
 					expect($('.fc-bgevent')).toBeAbove('.fc-slats tr:eq(10)'); // 5am
 					done();
 					done();
 				};
 				};
-				$('#cal').fullCalendar(options);
+				initCalendar(options);
 			});
 			});
 			it('render correctly spanning multiple days', function(done) {
 			it('render correctly spanning multiple days', function(done) {
+				var options = {};
 				options.events = [ {
 				options.events = [ {
 					start: '2014-11-04T01:00:00',
 					start: '2014-11-04T01:00:00',
 					end: '2014-11-05T05:00:00',
 					end: '2014-11-05T05:00:00',
@@ -487,16 +495,17 @@ describe('background events', function() {
 					expect(queryBgEventsInCol(4).length).toBe(1);
 					expect(queryBgEventsInCol(4).length).toBe(1);
 					done();
 					done();
 				};
 				};
-				$('#cal').fullCalendar(options);
+				initCalendar(options);
 			});
 			});
 			describe('when businessHours', function() {
 			describe('when businessHours', function() {
 				it('renders correctly if custom', function() {
 				it('renders correctly if custom', function() {
+					var options = {};
 					options.businessHours = {
 					options.businessHours = {
 						start: '02:00',
 						start: '02:00',
 						end: '06:00',
 						end: '06:00',
 						dow: [ 1, 2, 3, 4 ] // Mon-Thu
 						dow: [ 1, 2, 3, 4 ] // Mon-Thu
 					};
 					};
-					$('#cal').fullCalendar(options);
+					initCalendar(options);
 
 
 					// whole days
 					// whole days
 					expect($('.fc-day-grid .fc-nonbusiness').length).toBe(2); // each stretch of days is one element
 					expect($('.fc-day-grid .fc-nonbusiness').length).toBe(2); // each stretch of days is one element
@@ -519,6 +528,7 @@ describe('background events', function() {
 			describe('when LTR', function() {
 			describe('when LTR', function() {
 
 
 				it('render correctly on one day', function(done) {
 				it('render correctly on one day', function(done) {
+					var options = {};
 					options.events = [ {
 					options.events = [ {
 						start: '2014-11-04T01:00:00',
 						start: '2014-11-04T01:00:00',
 						end: '2014-11-04T05:00:00',
 						end: '2014-11-04T05:00:00',
@@ -536,10 +546,11 @@ describe('background events', function() {
 						// TODO: maybe check y coords
 						// TODO: maybe check y coords
 						done();
 						done();
 					};
 					};
-					$('#cal').fullCalendar(options);
+					initCalendar(options);
 				});
 				});
 
 
 				it('render correctly spanning multiple days', function(done) {
 				it('render correctly spanning multiple days', function(done) {
+					var options = {};
 					options.events = [ {
 					options.events = [ {
 						start: '2014-11-04T01:00:00',
 						start: '2014-11-04T01:00:00',
 						end: '2014-11-05T05:00:00',
 						end: '2014-11-05T05:00:00',
@@ -557,10 +568,11 @@ describe('background events', function() {
 						// TODO: maybe check y coords
 						// TODO: maybe check y coords
 						done();
 						done();
 					};
 					};
-					$('#cal').fullCalendar(options);
+					initCalendar(options);
 				});
 				});
 
 
 				it('render correctly when starts before start of week', function(done) {
 				it('render correctly when starts before start of week', function(done) {
+					var options = {};
 					options.events = [ {
 					options.events = [ {
 						start: '2014-10-30T01:00:00',
 						start: '2014-10-30T01:00:00',
 						end: '2014-11-04T05:00:00',
 						end: '2014-11-04T05:00:00',
@@ -578,10 +590,11 @@ describe('background events', function() {
 						// TODO: maybe check y coords
 						// TODO: maybe check y coords
 						done();
 						done();
 					};
 					};
-					$('#cal').fullCalendar(options);
+					initCalendar(options);
 				});
 				});
 
 
 				it('render correctly when ends after end of week', function(done) {
 				it('render correctly when ends after end of week', function(done) {
+					var options = {};
 					options.events = [ {
 					options.events = [ {
 						start: '2014-11-04T01:00:00',
 						start: '2014-11-04T01:00:00',
 						end: '2014-11-12T05:00:00',
 						end: '2014-11-12T05:00:00',
@@ -595,10 +608,11 @@ describe('background events', function() {
 						// TODO: maybe check y coords
 						// TODO: maybe check y coords
 						done();
 						done();
 					};
 					};
-					$('#cal').fullCalendar(options);
+					initCalendar(options);
 				});
 				});
 
 
 				it('render correctly with two related events, in reverse order', function(done) {
 				it('render correctly with two related events, in reverse order', function(done) {
+					var options = {};
 					options.events = [
 					options.events = [
 						{
 						{
 							id: 'hello',
 							id: 'hello',
@@ -625,10 +639,11 @@ describe('background events', function() {
 						// TODO: maybe check y coords
 						// TODO: maybe check y coords
 						done();
 						done();
 					};
 					};
-					$('#cal').fullCalendar(options);
+					initCalendar(options);
 				});
 				});
 
 
 				it('render correctly with two related events, nested', function(done) {
 				it('render correctly with two related events, nested', function(done) {
+					var options = {};
 					options.events = [
 					options.events = [
 						{
 						{
 							id: 'hello',
 							id: 'hello',
@@ -658,16 +673,15 @@ describe('background events', function() {
 
 
 						done();
 						done();
 					};
 					};
-					$('#cal').fullCalendar(options);
+					initCalendar(options);
 				});
 				});
 
 
 			});
 			});
 
 
-			describe('when RTL', function() {
-				beforeEach(function() {
-					options.isRTL = true;
-				});
+			describe('when RTL', function() {				
+				pushOptions({isRTL:true});	
 				it('render correctly on one day', function(done) {
 				it('render correctly on one day', function(done) {
+					var options = {};
 					options.events = [ {
 					options.events = [ {
 						start: '2014-11-04T01:00:00',
 						start: '2014-11-04T01:00:00',
 						end: '2014-11-04T05:00:00',
 						end: '2014-11-04T05:00:00',
@@ -685,12 +699,13 @@ describe('background events', function() {
 						// TODO: maybe check y coords
 						// TODO: maybe check y coords
 						done();
 						done();
 					};
 					};
-					$('#cal').fullCalendar(options);
+					initCalendar(options);
 				});
 				});
 			});
 			});
 
 
 			describe('when out of view range', function() {
 			describe('when out of view range', function() {
 				it('should still render', function(done) {
 				it('should still render', function(done) {
+					var options = {};
 					options.events = [ {
 					options.events = [ {
 						start: '2014-01-01T01:00:00',
 						start: '2014-01-01T01:00:00',
 						end: '2014-01-01T05:00:00',
 						end: '2014-01-01T05:00:00',
@@ -700,12 +715,13 @@ describe('background events', function() {
 						expect($('.fc-bgevent').length).toBe(7);
 						expect($('.fc-bgevent').length).toBe(7);
 						done();
 						done();
 					};
 					};
-					$('#cal').fullCalendar(options);
+					initCalendar(options);
 				});
 				});
 			});
 			});
 		});
 		});
 
 
 		it('can have custom Event Object color', function(done) {
 		it('can have custom Event Object color', function(done) {
+			var options = {};
 			options.events = [ {
 			options.events = [ {
 				start: '2014-11-04T01:00:00',
 				start: '2014-11-04T01:00:00',
 				rendering: 'background',
 				rendering: 'background',
@@ -715,10 +731,11 @@ describe('background events', function() {
 				expect($('.fc-bgevent').css('background-color')).toMatch(RED_REGEX);
 				expect($('.fc-bgevent').css('background-color')).toMatch(RED_REGEX);
 				done();
 				done();
 			};
 			};
-			$('#cal').fullCalendar(options);
+			initCalendar(options);
 		});
 		});
 
 
 		it('can have custom Event Object backgroundColor', function(done) {
 		it('can have custom Event Object backgroundColor', function(done) {
+			var options = {};
 			options.events = [ {
 			options.events = [ {
 				start: '2014-11-04T01:00:00',
 				start: '2014-11-04T01:00:00',
 				rendering: 'background',
 				rendering: 'background',
@@ -728,10 +745,11 @@ describe('background events', function() {
 				expect($('.fc-bgevent').css('background-color')).toMatch(RED_REGEX);
 				expect($('.fc-bgevent').css('background-color')).toMatch(RED_REGEX);
 				done();
 				done();
 			};
 			};
-			$('#cal').fullCalendar(options);
+			initCalendar(options);
 		});
 		});
 
 
 		it('can have custom Event Source color', function(done) {
 		it('can have custom Event Source color', function(done) {
+			var options = {};
 			options.eventSources = [ {
 			options.eventSources = [ {
 				color: 'red',
 				color: 'red',
 				events: [ {
 				events: [ {
@@ -743,10 +761,11 @@ describe('background events', function() {
 				expect($('.fc-bgevent').css('background-color')).toMatch(RED_REGEX);
 				expect($('.fc-bgevent').css('background-color')).toMatch(RED_REGEX);
 				done();
 				done();
 			};
 			};
-			$('#cal').fullCalendar(options);
+			initCalendar(options);
 		});
 		});
 
 
 		it('can have custom Event Source backgroundColor', function(done) {
 		it('can have custom Event Source backgroundColor', function(done) {
+			var options = {};
 			options.eventSources = [ {
 			options.eventSources = [ {
 				backgroundColor: 'red',
 				backgroundColor: 'red',
 				events: [ {
 				events: [ {
@@ -758,10 +777,11 @@ describe('background events', function() {
 				expect($('.fc-bgevent').css('background-color')).toMatch(RED_REGEX);
 				expect($('.fc-bgevent').css('background-color')).toMatch(RED_REGEX);
 				done();
 				done();
 			};
 			};
-			$('#cal').fullCalendar(options);
+			initCalendar(options);
 		});
 		});
 
 
 		it('is affected by global eventColor', function(done) {
 		it('is affected by global eventColor', function(done) {
+			var options = {};
 			options.eventColor = 'red';
 			options.eventColor = 'red';
 			options.eventSources = [ {
 			options.eventSources = [ {
 				events: [ {
 				events: [ {
@@ -773,10 +793,11 @@ describe('background events', function() {
 				expect($('.fc-bgevent').css('background-color')).toMatch(RED_REGEX);
 				expect($('.fc-bgevent').css('background-color')).toMatch(RED_REGEX);
 				done();
 				done();
 			};
 			};
-			$('#cal').fullCalendar(options);
+			initCalendar(options);
 		});
 		});
 
 
 		it('is affected by global eventBackgroundColor', function(done) {
 		it('is affected by global eventBackgroundColor', function(done) {
+			var options = {};
 			options.eventBackgroundColor = 'red';
 			options.eventBackgroundColor = 'red';
 			options.eventSources = [ {
 			options.eventSources = [ {
 				events: [ {
 				events: [ {
@@ -788,11 +809,10 @@ describe('background events', function() {
 				expect($('.fc-bgevent').css('background-color')).toMatch(RED_REGEX);
 				expect($('.fc-bgevent').css('background-color')).toMatch(RED_REGEX);
 				done();
 				done();
 			};
 			};
-			$('#cal').fullCalendar(options);
+			initCalendar(options);
 		});
 		});
 	});
 	});
 
 
-
 	function queryBgEventsInCol(col) {
 	function queryBgEventsInCol(col) {
 		return $('.fc-time-grid .fc-content-skeleton td:not(.fc-axis):eq(' + col + ') .fc-bgevent');
 		return $('.fc-time-grid .fc-content-skeleton td:not(.fc-axis):eq(' + col + ') .fc-bgevent');
 	}
 	}
@@ -800,5 +820,4 @@ describe('background events', function() {
 	function queryNonBusinessSegsInCol(col) {
 	function queryNonBusinessSegsInCol(col) {
 		return $('.fc-time-grid .fc-content-skeleton td:not(.fc-axis):eq(' + col + ') .fc-nonbusiness');
 		return $('.fc-time-grid .fc-content-skeleton td:not(.fc-axis):eq(' + col + ') .fc-nonbusiness');
 	}
 	}
-
 });
 });