Просмотр исходного кода

Merge branch 'more_legacy_test_updates' of https://github.com/jstacoder/fullcalendar

Adam Shaw 8 лет назад
Родитель
Сommit
bc9396e4ca

+ 62 - 37
tests/legacy/DayGrid-events.js

@@ -1,12 +1,7 @@
 describe('DayGrid event rendering', function() {
-	var options;
-
-	beforeEach(function() {
-		affix('#cal');
-		options = {
-			defaultDate: '2014-08-01', // 2014-07-27 - 2014-10-07 (excl)
-			defaultView: 'month'
-		};
+	pushOptions({
+		defaultDate: '2014-08-01', // 2014-07-27 - 2014-10-07 (excl)
+		defaultView: 'month'
 	});
 
 	describe('when LTR', function() {
@@ -17,155 +12,183 @@ describe('DayGrid event rendering', function() {
 	});
 
 	function initMonthTesting(isRTL) {
-
 		it('correctly renders an event starting before view\'s start', function() {
+			var options = {};
 			options.events = [
 				{ start: '2014-07-26', end: '2014-07-30' }
 			];
-			testSeg({
+
+			var testSegOptions = {
 				firstCol: 0,
 				lastCol: 2,
 				isStart: false,
 				isEnd: true
-			});
+			};
+			testSeg(options, testSegOptions);
 		});
 
 		it('correctly renders an event starting at view\'s start', function() {
+			var options = {};
 			options.events = [
 				{ start: '2014-07-27', end: '2014-07-29' }
 			];
-			testSeg({
+
+			var testSegOptions = {
 				firstCol: 0,
 				lastCol: 1,
 				isStart: true,
 				isEnd: true
-			});
+			};
+			testSeg(options, testSegOptions);
 		});
 
 		it('correctly renders an event starting after view\'s start', function() {
+			var options = {};
 			options.events = [
 				{ start: '2014-08-01', end: '2014-08-02' }
 			];
-			testSeg({
+
+			var testSegOptions = {
 				firstCol: 5,
 				lastCol: 5,
 				isStart: true,
 				isEnd: true
-			});
+			};
+			testSeg(options, testSegOptions);
 		});
 
 		it('correctly renders an event starting on a hidden day at week start', function() {
+			var options = {};
 			options.weekends = false;
 			options.events = [
 				{ start: '2014-07-27', end: '2014-07-30' }
 			];
-			testSeg({
+
+			var testSegOptions = {
 				firstCol: 0,
 				lastCol: 1,
 				isStart: false,
 				isEnd: true
-			});
+			};
+			testSeg(options, testSegOptions);
 		});
 
 		it('correctly renders an event starting on a hidden day in middle of week', function() {
+			var options = {};
 			options.hiddenDays = [ 2 ]; // hide Tues
 			options.events = [
 				{ start: '2014-07-29', end: '2014-08-01' }
 			];
-			testSeg({
+
+			var testSegOptions = {
 				firstCol: 2,
 				lastCol: 3,
 				isStart: false,
 				isEnd: true
-			});
+			};
+			testSeg(options, testSegOptions);
 		});
 
 		it('correctly renders an event ending before view\'s end', function() {
+			var options = {};
 			options.events = [
 				{ start: '2014-09-02', end: '2014-09-05' }
 			];
-			testSeg({
+			var testSegOptions = {
 				row: 5,
 				firstCol: 2,
 				lastCol: 4,
 				isStart: true,
 				isEnd: true
-			});
+			};
+			testSeg(options, testSegOptions)
 		});
 
 		it('correctly renders an event ending at view\'s end', function() {
+			var options = {};
 			options.events = [
 				{ start: '2014-09-04', end: '2014-09-07' }
 			];
-			testSeg({
+
+			var testSegOptions = {
 				row: 5,
 				firstCol: 4,
 				lastCol: 6,
 				isStart: true,
 				isEnd: true
-			});
+			};
+			testSeg(options, testSegOptions);
 		});
 
 		it('correctly renders an event ending after view\'s end', function() {
+			var options = {};
 			options.events = [
 				{ start: '2014-09-04', end: '2014-09-08' }
 			];
-			testSeg({
+			var testSegOptions = {
 				row: 5,
 				firstCol: 4,
 				lastCol: 6,
 				isStart: true,
 				isEnd: false
-			});
+			};
+			testSeg(options, testSegOptions);
 		});
 
 		it('correctly renders an event ending at a week\'s end', function() {
+			var options = {};
 			options.events = [
 				{ start: '2014-08-28', end: '2014-08-31' }
 			];
-			testSeg({
+			var testSegOptions = {
 				row: 4,
 				firstCol: 4,
 				lastCol: 6,
 				isStart: true,
 				isEnd: true
-			});
+			};
+			testSeg(options, testSegOptions);
 		});
 
 		it('correctly renders an event ending on a hidden day at week end', function() {
+			var options = {};
 			options.weekends = false;
 			options.events = [
 				{ start: '2014-07-30', end: '2014-08-03' }
 			];
-			testSeg({
+			var testSegOptions = {
 				firstCol: 2,
 				lastCol: 4,
 				isStart: true,
 				isEnd: false
-			});
+			};
+			testSeg(options, testSegOptions);
 		});
 
 		it('correctly renders an event ending on a hidden day in middle of week', function() {
+			var options = {};
 			options.hiddenDays = [ 4 ]; // Thurs
 			options.events = [
 				{ start: '2014-07-28', end: '2014-08-01' }
 			];
-			testSeg({
+			var testSegOptions = {
 				firstCol: 1,
 				lastCol: 3,
 				isStart: true,
 				isEnd: false
-			});
+			};
+			testSeg(options, testSegOptions);
 		});
 
-		function testSeg(testSegOptions) {
-			options.isRTL = isRTL;
-			$('#cal').fullCalendar(options);
+		function testSeg(calendarOptions, testSegOptions) {
+			calendarOptions.isRTL = isRTL;
+			initCalendar(calendarOptions);
 			directionallyTestSeg(testSegOptions, isRTL);
 		}
 	}
 
 	it('rendering of events across weeks stays consistent', function() {
+		var options = {};
 		options.events = [
 			{
 				title: 'event1',
@@ -180,7 +203,7 @@ describe('DayGrid event rendering', function() {
 				className: 'event2'
 			}
 		];
-		$('#cal').fullCalendar(options);
+		initCalendar(options);
 		var row0 = $('.fc-day-grid .fc-row:eq(0)');
 		var row0event1 = row0.find('.event1');
 		var row0event2 = row0.find('.event2');
@@ -192,22 +215,24 @@ describe('DayGrid event rendering', function() {
 	});
 
 	it('renders an event with no url with no <a> href', function() {
+		var options = {};
 		options.events = [ {
 			title: 'event1',
 			start: '2014-08-01'
 		} ];
-		$('#cal').fullCalendar(options);
+		initCalendar(options);
 		var seg = $('.fc-event');
 		expect(seg).not.toHaveAttr('href');
 	});
 
 	it('renders an event with a url with an <a> href', function() {
+		var options = {};
 		options.events = [ {
 			title: 'event1',
 			start: '2014-08-01',
 			url: 'http://google.com/'
 		} ];
-		$('#cal').fullCalendar(options);
+		initCalendar(options);
 		var seg = $('.fc-event');
 		expect(seg).toHaveAttr('href');
 	});

+ 14 - 18
tests/legacy/addEventSource.js

@@ -1,24 +1,20 @@
-describe('addEventSource', function() {
-
-	var options;
+describe('addEventSource', function() {	
 	var eventArray = [
 		{ id: 0, title: 'event zero', start: '2014-06-24', className: 'event-zero' },
 		{ id: 1, title: 'event one', start: '2014-06-24', className: 'event-non-zero event-one' },
 		{ id: 2, title: 'event two', start: '2014-06-24', className: 'event-non-zero event-two' }
 	];
 
-	beforeEach(function() {
-		affix('#cal');
-		options = {
-			defaultDate: '2014-06-24',
-			defaultView: 'month'
-		};
+	pushOptions({
+		defaultDate: '2014-06-24',
+		defaultView: 'month'
 	});
 
+
 	it('correctly adds an array source', function(done) {
 		go(
 			function() {
-				$('#cal').fullCalendar('addEventSource', eventArray);
+				currentCalendar.addEventSource(eventArray);
 			},
 			null,
 			done
@@ -28,7 +24,7 @@ describe('addEventSource', function() {
 	it('correctly adds a function source', function(done) {
 		go(
 			function() {
-				$('#cal').fullCalendar('addEventSource', function(start, end, timezone, callback) {
+				currentCalendar.addEventSource(function(start, end, timezone, callback) {
 					callback(eventArray);
 				});
 			},
@@ -40,7 +36,7 @@ describe('addEventSource', function() {
 	it('correctly adds an extended array source', function(done) {
 		go(
 			function() {
-				$('#cal').fullCalendar('addEventSource', {
+				currentCalendar.addEventSource({
 					className: 'arraysource',
 					events: eventArray
 				});
@@ -55,7 +51,7 @@ describe('addEventSource', function() {
 	it('correctly adds an extended array source', function(done) {
 		go(
 			function() {
-				$('#cal').fullCalendar('addEventSource', {
+				currentCalendar.addEventSource({
 					className: 'funcsource',
 					events: function(start, end, timezone, callback) {
 						callback(eventArray);
@@ -72,7 +68,7 @@ describe('addEventSource', function() {
 
 	function go(addFunc, extraTestFunc, doneFunc) {
 		var callCnt = 0;
-
+		var options = {};
 		options.eventAfterAllRender = function() {
 			callCnt++;
 			if (callCnt == 2) { // once for initial render. second time for addEventSource
@@ -84,8 +80,8 @@ describe('addEventSource', function() {
 				}
 
 				// move the calendar back out of view, then back in (for issue 2191)
-				$('#cal').fullCalendar('next');
-				$('#cal').fullCalendar('prev');
+				currentCalendar.next();
+				currentCalendar.prev();
 
 				// otherwise, prev/next would be cancelled out by doneFunc's calendar destroy
 				setTimeout(function() {
@@ -100,14 +96,14 @@ describe('addEventSource', function() {
 			}
 		};
 
-		$('#cal').fullCalendar(options);
+		initCalendar(options);
 		addFunc();
 	}
 
 	// Checks to make sure all events have been rendered and that the calendar
 	// has internal info on all the events.
 	function checkAllEvents() {
-		expect($('#cal').fullCalendar('clientEvents').length).toEqual(3);
+		expect(currentCalendar.clientEvents().length).toEqual(3);
 		expect($('.fc-event').length).toEqual(3);
 	}
 

+ 6 - 10
tests/legacy/allDaySlot.js

@@ -1,17 +1,13 @@
 
 describe('allDaySlots', function() {
 
-	beforeEach(function() {
-		affix('#cal');
-	});
-
 	describe('when allDaySlots is not set', function() {
 		describe('in agendaWeek', function() {
 			it('should default to having an allDaySlots table', function() {
 				var options = {
 					defaultView: 'agendaWeek'
 				};
-				$('#cal').fullCalendar(options);
+				initCalendar(options);
 				var allDaySlotCount = $('.fc-day-grid').length;
 				expect(allDaySlotCount).toEqual(1);
 			});
@@ -21,7 +17,7 @@ describe('allDaySlots', function() {
 				var options = {
 					defaultView: 'agendaDay'
 				};
-				$('#cal').fullCalendar(options);
+				initCalendar(options);
 				var allDaySlotCount = $('.fc-day-grid').length;
 				expect(allDaySlotCount).toEqual(1);
 			});
@@ -35,7 +31,7 @@ describe('allDaySlots', function() {
 					defaultView: 'agendaWeek',
 					allDaySlot: true
 				};
-				$('#cal').fullCalendar(options);
+				initCalendar(options);
 				var allDaySlotCount = $('.fc-day-grid').length;
 				expect(allDaySlotCount).toEqual(1);
 			});
@@ -46,7 +42,7 @@ describe('allDaySlots', function() {
 					defaultView: 'agendaDay',
 					allDaySlot: true
 				};
-				$('#cal').fullCalendar(options);
+				initCalendar(options);
 				var allDaySlotCount = $('.fc-day-grid').length;
 				expect(allDaySlotCount).toEqual(1);
 			});
@@ -60,7 +56,7 @@ describe('allDaySlots', function() {
 					defaultView: 'agendaWeek',
 					allDaySlot: false
 				};
-				$('#cal').fullCalendar(options);
+				initCalendar(options);
 				var allDaySlotCount = $('.fc-day-grid').length;
 				expect(allDaySlotCount).toEqual(0);
 			});
@@ -71,7 +67,7 @@ describe('allDaySlots', function() {
 					defaultView: 'agendaDay',
 					allDaySlot: false
 				};
-				$('#cal').fullCalendar(options);
+				initCalendar(options);
 				var allDaySlotCount = $('.fc-day-grid').length;
 				expect(allDaySlotCount).toEqual(0);
 			});

+ 8 - 12
tests/legacy/allDayText.js

@@ -1,17 +1,13 @@
 
 describe('allDayText', function() {
 
-	beforeEach(function() {
-		affix('#cal');
-	});
-
 	describe('when allDaySlots is not set', function() {
 		describe('in agendaWeek', function() {
 			it('should default allDayText to using \'all-day\'', function() {
 				var options = {
 					defaultView: 'agendaWeek'
 				};
-				$('#cal').fullCalendar(options);
+				initCalendar(options);
 				var allDayText = $('.fc-day-grid > .fc-row > .fc-bg .fc-axis').text();
 				expect(allDayText).toEqual('all-day');
 			});
@@ -21,7 +17,7 @@ describe('allDayText', function() {
 				var options = {
 					defaultView: 'agendaDay'
 				};
-				$('#cal').fullCalendar(options);
+				initCalendar(options);
 				var allDayText = $('.fc-day-grid > .fc-row > .fc-bg .fc-axis').text();
 				expect(allDayText).toEqual('all-day');
 			});
@@ -35,7 +31,7 @@ describe('allDayText', function() {
 					defaultView: 'agendaWeek',
 					allDaySlot: true
 				};
-				$('#cal').fullCalendar(options);
+				initCalendar(options);
 				var allDayText = $('.fc-day-grid > .fc-row > .fc-bg .fc-axis').text();
 				expect(allDayText).toEqual('all-day');
 			});
@@ -46,7 +42,7 @@ describe('allDayText', function() {
 					defaultView: 'agendaDay',
 					allDaySlot: true
 				};
-				$('#cal').fullCalendar(options);
+				initCalendar(options);
 				var allDayText = $('.fc-day-grid > .fc-row > .fc-bg .fc-axis').text();
 				expect(allDayText).toEqual('all-day');
 			});
@@ -61,7 +57,7 @@ describe('allDayText', function() {
 					allDaySlot: true,
 					locale: 'pt-br'
 				};
-				$('#cal').fullCalendar(options);
+				initCalendar(options);
 				var allDayText = $('.fc-day-grid > .fc-row > .fc-bg .fc-axis').text();
 				expect(allDayText).toEqual('dia inteiro');
 			});
@@ -73,7 +69,7 @@ describe('allDayText', function() {
 					allDaySlot: true,
 					locale: 'pt-br'
 				};
-				$('#cal').fullCalendar(options);
+				initCalendar(options);
 				var allDayText = $('.fc-day-grid > .fc-row > .fc-bg .fc-axis').text();
 				expect(allDayText).toEqual('dia inteiro');
 			});
@@ -88,7 +84,7 @@ describe('allDayText', function() {
 					allDaySlot: true,
 					allDayText: 'axis-phosy'
 				};
-				$('#cal').fullCalendar(options);
+				initCalendar(options);
 				var allDayText = $('.fc-day-grid > .fc-row > .fc-bg .fc-axis').text();
 				expect(allDayText).toEqual('axis-phosy');
 			});
@@ -99,7 +95,7 @@ describe('allDayText', function() {
 					defaultView: 'agendaDay',
 					allDayText: 'axis-phosy'
 				};
-				$('#cal').fullCalendar(options);
+				initCalendar(options);
 				var allDayText = $('.fc-day-grid > .fc-row > .fc-bg .fc-axis').text();
 				expect(allDayText).toEqual('axis-phosy');
 			});

+ 17 - 23
tests/legacy/businessHours.js

@@ -3,24 +3,18 @@
 import { doElsMatchSegs, getBoundingRect } from '../lib/dom-utils';
 import { getTimeGridTop, getTimeGridDayEls, getTimeGridSlotEls } from '../lib/time-grid';
 
-describe('businessHours', function() {
-	var options;
-
-	beforeEach(function() {
-		options = {
-			defaultDate: '2014-11-25',
-			defaultView: 'month',
-			businessHours: true
-		};
-		affix('#cal');
-	});
-
+describe('businessHours', function() {	
+	pushOptions({
+		defaultDate: '2014-11-25',
+		defaultView: 'month',
+		businessHours: true
+	});			
 
 	it('doesn\'t break when starting out in a larger month time range', function() {
-		$('#cal').fullCalendar(options); // start out in the month range
-		$('#cal').fullCalendar('changeView', 'agendaWeek');
-		$('#cal').fullCalendar('next'); // move out of the original month range...
-		$('#cal').fullCalendar('next'); // ... out. should render correctly.
+		initCalendar(); // start out in the month range
+		currentCalendar.changeView('agendaWeek');
+		currentCalendar.next(); // move out of the original month range...
+		currentCalendar.next(); // ... out. should render correctly.
 
 		// whole days
 		expect($('.fc-day-grid .fc-nonbusiness').length).toBe(2); // each multi-day stretch is one element
@@ -54,7 +48,7 @@ describe('businessHours', function() {
 		[ 'agendaWeek', 'month' ].forEach(function(viewName) {
 
 			it('allows dynamic turning on', function() {
-				$('#cal').fullCalendar({
+				initCalendar({
 					defaultView: viewName,
 					businessHours: false
 				});
@@ -62,14 +56,14 @@ describe('businessHours', function() {
 				expect(rootEl.length).toBe(1);
 
 				expect(queryNonBusinessSegs().length).toBe(0);
-				$('#cal').fullCalendar('option', 'businessHours', true);
+				currentCalendar.option('businessHours', true);
 				expect(queryNonBusinessSegs().length).toBeGreaterThan(0);
 
 				expect($('.fc-view > *:first')[0]).toBe(rootEl[0]); // same element. didn't completely rerender
 			});
 
 			it('allows dynamic turning off', function() {
-				$('#cal').fullCalendar({
+				initCalendar({
 					defaultView: viewName,
 					businessHours: true
 				});
@@ -77,7 +71,7 @@ describe('businessHours', function() {
 				expect(rootEl.length).toBe(1);
 
 				expect(queryNonBusinessSegs().length).toBeGreaterThan(0);
-				$('#cal').fullCalendar('option', 'businessHours', false);
+				currentCalendar.option('businessHours', false);
 				expect(queryNonBusinessSegs().length).toBe(0);
 
 				expect($('.fc-view > *:first')[0]).toBe(rootEl[0]); // same element. didn't completely rerender
@@ -89,7 +83,7 @@ describe('businessHours', function() {
 	describe('for multiple day-of-week definitions', function() {
 
 		it('rendes two day-of-week groups', function() {
-			$('#cal').fullCalendar({
+			initCalendar({
 				defaultDate: '2014-12-07',
 				defaultView: 'agendaWeek',
 				businessHours: [
@@ -131,7 +125,7 @@ describe('businessHours', function() {
 		});
 
 		it('wont\'t process businessHour items that omit dow', function() {
-			$('#cal').fullCalendar({
+			initCalendar({
 				defaultDate: '2014-12-07',
 				defaultView: 'agendaWeek',
 				businessHours: [
@@ -172,7 +166,7 @@ describe('businessHours', function() {
 
 
 	it('will grey-out a totally non-business-hour view', function() {
-		$('#cal').fullCalendar({
+		initCalendar({
 			defaultDate: '2016-07-23', // sat
 			defaultView: 'agendaDay',
 			businessHours: true

+ 25 - 34
tests/legacy/columnHeaderFormat.js

@@ -1,10 +1,7 @@
 
 describe('columnHeaderFormat', function() {
-    beforeEach(function() {
-        affix('#cal');
-    });
-
-    describe('when columnHeaderFormat is not set', function() {
+    
+    describe('when columnFormat is not set', function() {
 
         var viewWithFormat = [ { view: 'month', expected: 'Sun', selector: 'th.fc-day-header.fc-sun' },
             { view: 'basicWeek', expected: 'Sun 5/11', selector: 'th.fc-day-header.fc-sun' },
@@ -13,18 +10,17 @@ describe('columnHeaderFormat', function() {
             { view: 'agendaDay', expected: 'Sunday', selector: 'th.fc-widget-header.fc-sun' } ];
 
         beforeEach(function() {
-            $('#cal').fullCalendar({
+            initCalendar({
                 defaultDate: '2014-05-11'
             });
         });
 
-        it('should have default values', function() {
-            var cal = $('#cal');
+        it('should have default values', function() {            
 
             for (var i = 0; i <  viewWithFormat.length; i++) {
                 var crtView = viewWithFormat[i];
-                cal.fullCalendar('changeView', crtView.view);
-                expect(cal.find(crtView.selector).text()).toBe(crtView.expected);
+                currentCalendar.changeView(crtView.view);
+                expect(currentCalendar.el.find(crtView.selector).text()).toBe(crtView.expected);
             };
         });
     });
@@ -38,7 +34,7 @@ describe('columnHeaderFormat', function() {
             { view: 'agendaDay', expected: 'Sunday 5/11', selector: 'th.fc-widget-header.fc-sun' } ];
 
         beforeEach(function() {
-            $('#cal').fullCalendar({
+            initCalendar({
                 defaultDate: '2014-05-11',
                 views: {
                     month: { columnHeaderFormat: 'dddd' },
@@ -50,13 +46,12 @@ describe('columnHeaderFormat', function() {
             });
         });
 
-        it('should have the correct values', function() {
-            var cal = $('#cal');
+        it('should have the correct values', function() {            
 
             for (var i = 0; i <  viewWithFormat.length; i++) {
                 var crtView = viewWithFormat[i];
-                cal.fullCalendar('changeView', crtView.view);
-                expect(cal.find(crtView.selector).text()).toBe(crtView.expected);
+                currentCalendar.changeView(crtView.view);
+                expect(currentCalendar.el.find(crtView.selector).text()).toBe(crtView.expected);
             };
         });
     });
@@ -70,19 +65,18 @@ describe('columnHeaderFormat', function() {
             { view: 'agendaDay', expected: 'dimanche', selector: 'th.fc-widget-header.fc-sun' } ];
 
         beforeEach(function() {
-            $('#cal').fullCalendar({
+            initCalendar({
                 defaultDate: '2014-05-11',
                 locale: 'fr'
             });
         });
 
-        it('should have the translated dates', function() {
-            var cal = $('#cal');
+        it('should have the translated dates', function() {            
 
             for (var i = 0; i <  viewWithFormat.length; i++) {
                 var crtView = viewWithFormat[i];
-                cal.fullCalendar('changeView', crtView.view);
-                expect(cal.find(crtView.selector).text()).toBe(crtView.expected);
+                currentCalendar.changeView(crtView.view);
+                expect(currentCalendar.el.find(crtView.selector).text()).toBe(crtView.expected);
             };
         });
     });
@@ -96,19 +90,18 @@ describe('columnHeaderFormat', function() {
             { view: 'agendaDay', expected: 'Sunday', selector: 'th.fc-widget-header.fc-sun' } ];
 
         beforeEach(function() {
-            $('#cal').fullCalendar({
+            initCalendar({
                 defaultDate: '2014-05-11',
                 locale: 'en-gb'
             });
         });
 
-        it('should have the translated dates', function() {
-            var cal = $('#cal');
+        it('should have the translated dates', function() {            
 
             for (var i = 0; i <  viewWithFormat.length; i++) {
                 var crtView = viewWithFormat[i];
-                cal.fullCalendar('changeView', crtView.view);
-                expect(cal.find(crtView.selector).text()).toBe(crtView.expected);
+                currentCalendar.changeView(crtView.view);
+                expect(currentCalendar.el.find(crtView.selector).text()).toBe(crtView.expected);
             };
         });
     });
@@ -122,19 +115,17 @@ describe('columnHeaderFormat', function() {
             { view: 'agendaDay', expected: '일요일', selector: 'th.fc-widget-header.fc-sun' } ];
 
         beforeEach(function() {
-            $('#cal').fullCalendar({
+            initCalendar({
                 defaultDate: '2014-05-11',
                 locale: 'ko'
             });
         });
 
         it('should have the translated dates and columnHeaderFormat should be computed differently', function() {
-            var cal = $('#cal');
-
             for (var i = 0; i <  viewWithFormat.length; i++) {
                 var crtView = viewWithFormat[i];
-                cal.fullCalendar('changeView', crtView.view);
-                expect(cal.find(crtView.selector).text()).toBe(crtView.expected);
+                currentCalendar.changeView(crtView.view);
+                expect(currentCalendar.el.find(crtView.selector).text()).toBe(crtView.expected);
             };
         });
     });
@@ -142,7 +133,7 @@ describe('columnHeaderFormat', function() {
     describe('using custom views', function() {
 
         it('multi-year default only displays day-of-week', function() {
-            $('#cal').fullCalendar({
+            initCalendar({
                 views: {
                     multiYear: {
                         type: 'basic',
@@ -156,7 +147,7 @@ describe('columnHeaderFormat', function() {
         });
 
         it('multi-month default only displays day-of-week', function() {
-            $('#cal').fullCalendar({
+            initCalendar({
                 views: {
                     multiMonth: {
                         type: 'basic',
@@ -170,7 +161,7 @@ describe('columnHeaderFormat', function() {
         });
 
         it('multi-week default only displays day-of-week', function() {
-            $('#cal').fullCalendar({
+            initCalendar({
                 views: {
                     multiWeek: {
                         type: 'basic',
@@ -184,7 +175,7 @@ describe('columnHeaderFormat', function() {
         });
 
         it('multi-day default displays short full date', function() {
-            $('#cal').fullCalendar({
+            initCalendar({
                 views: {
                     multiDay: {
                         type: 'basic',

+ 124 - 37
tests/legacy/constraint.js

@@ -2,23 +2,16 @@ import { testEventDrag, testEventResize, testSelection } from '../lib/dnd-resize
 
 describe('event constraint', function() {
 
-	var options;
-
-	beforeEach(function() {
-		options = {};
-		options.defaultDate = '2014-11-10';
-		options.defaultView = 'agendaWeek';
-		options.scrollTime = '00:00';
-		affix('#cal');
-		$('#cal').width(1100);
+	pushOptions({
+		defaultDate: '2014-11-10',
+		defaultView: 'agendaWeek',
+		scrollTime: '00:00',				
 	});
-
 	describe('when used with a specific date range', function() {
-
 		describe('when an event is being dragged', function() {
-
 			describe('to the middle of the constraint range', function() {
 				it('allows a drag', function(done) {
+					var options = {};
 					options.events = [ {
 						start: '2014-11-10T01:00:00',
 						end: '2014-11-10T02:00:00',
@@ -32,6 +25,7 @@ describe('event constraint', function() {
 
 				describe('when in month view with timed event', function() {
 					it('allows a drag, respects time of day', function(done) {
+						var options = {};				
 						options.defaultView = 'month';
 						options.events = [ {
 							start: '2014-11-10T05:00:00',
@@ -42,7 +36,7 @@ describe('event constraint', function() {
 							}
 						} ];
 						testEventDrag(options, '2014-11-14', true, function() {
-							var event = $('#cal').fullCalendar('clientEvents')[0];
+							var event = currentCalendar.clientEvents()[0];
 							expect(event.start).toEqualMoment('2014-11-14T05:00:00');
 							expect(event.end).toEqualMoment('2014-11-14T07:00:00');
 							done();
@@ -53,6 +47,7 @@ describe('event constraint', function() {
 
 			describe('to the start of the constraint range', function() {
 				it('allows a drag', function(done) {
+					var options = {};					
 					options.events = [ {
 						start: '2014-11-10T01:00:00',
 						end: '2014-11-10T02:00:00',
@@ -68,6 +63,8 @@ describe('event constraint', function() {
 			describe('to the end of the constraint range', function() {
 				describe('when the event has an explicit end', function() {
 					it('allows a drag', function(done) {
+						var options = {};
+					
 						options.events = [ {
 							start: '2014-11-10T01:00:00',
 							end: '2014-11-10T02:00:00',
@@ -81,6 +78,8 @@ describe('event constraint', function() {
 				});
 				describe('when the event has an implied end', function() {
 					it('allows a drag', function(done) {
+						var options = {};
+					
 						options.defaultTimedEventDuration = '01:30:00';
 						options.events = [ {
 							start: '2014-11-10T01:00:00',
@@ -96,6 +95,8 @@ describe('event constraint', function() {
 
 			describe('before a constraint range', function() {
 				it('does not allow a drag', function(done) {
+					var options = {};
+					
 					options.events = [ {
 						start: '2014-11-10T01:00:00',
 						end: '2014-11-10T02:00:00',
@@ -112,6 +113,8 @@ describe('event constraint', function() {
 				describe('using an event object\'s constraint', function() {
 					describe('when in agendaWeek view with timed events', function() {
 						it('does not allow a drag', function(done) {
+							var options = {};
+							
 							options.events = [ {
 								start: '2014-11-10T01:00:00',
 								end: '2014-11-10T02:00:00',
@@ -123,12 +126,12 @@ describe('event constraint', function() {
 							testEventDrag(options, '2014-11-10T06:00:00', false, done);
 						});
 					});
-					describe('when in month view', function() {
-						beforeEach(function() {
-							options.defaultView = 'month';
-						});
+					describe('when in month view', function() {						
+						pushOptions({defaultView:'month'});
 						describe('with timed event and all-day constraint', function() {
 							it('does not allow a drag', function(done) {
+								var options = {};
+					
 								options.events = [ {
 									start: '2014-11-10T01:00:00',
 									end: '2014-11-10T02:00:00',
@@ -142,6 +145,8 @@ describe('event constraint', function() {
 						});
 						describe('with timed event and timed constraint', function() {
 							it('does not allow a drag', function(done) {
+								var options = {};
+					
 								options.events = [ {
 									start: '2014-11-10T01:00:00',
 									end: '2014-11-10T02:00:00',
@@ -155,6 +160,8 @@ describe('event constraint', function() {
 						});
 						describe('with all-day event and all-day constraint', function() {
 							it('does not allow a drag', function(done) {
+								var options = {};
+					
 								options.events = [ {
 									start: '2014-11-10',
 									end: '2014-11-12',
@@ -168,6 +175,8 @@ describe('event constraint', function() {
 						});
 						describe('with all-day event and timed constraint', function() {
 							it('does not allow a drag', function(done) {
+								var options = {};
+					
 								options.events = [ {
 									start: '2014-11-10',
 									end: '2014-11-12',
@@ -183,6 +192,8 @@ describe('event constraint', function() {
 				});
 				describe('using an event source\'s constraint', function() {
 					it('does not allow a drag', function(done) {
+						var options = {};
+					
 						options.eventSources = [ {
 							events: [ {
 								start: '2014-11-10T01:00:00',
@@ -198,7 +209,8 @@ describe('event constraint', function() {
 				});
 				describe('using eventConstraint', function() {
 					it('does not allow a drag and doesnt call eventDataTransform', function(done) {
-
+						var options = {};
+						
 						options.events = [ {
 							start: '2014-11-10T01:00:00',
 							end: '2014-11-10T02:00:00'
@@ -226,6 +238,8 @@ describe('event constraint', function() {
 			describe('intersecting the constraint start', function() {
 				describe('with no timezone', function() {
 					it('does not allow a drag', function(done) {
+						var options = {};
+					
 						options.events = [ {
 							start: '2014-11-10T03:00:00',
 							end: '2014-11-10T05:00:00',
@@ -239,6 +253,8 @@ describe('event constraint', function() {
 				});
 				describe('with UTC timezone', function() {
 					it('does not allow a drag', function(done) {
+						var options = {};
+					
 						options.timezone = 'UTC';
 						options.events = [ {
 							start: '2014-11-10T03:00:00+00:00',
@@ -256,6 +272,8 @@ describe('event constraint', function() {
 			describe('intersecting the constraint end', function() {
 				describe('when the event has an explicit end', function() {
 					it('does not allow a drag', function(done) {
+						var options = {};
+					
 						options.events = [ {
 							start: '2014-11-10T03:00:00',
 							end: '2014-11-10T05:00:00',
@@ -269,6 +287,8 @@ describe('event constraint', function() {
 				});
 				describe('when the event has an implied end', function() {
 					it('does not allow a drag', function(done) {
+						var options = {};
+					
 						options.defaultTimedEventDuration = '02:30';
 						options.events = [ {
 							start: '2014-11-10T03:00:00',
@@ -282,6 +302,8 @@ describe('event constraint', function() {
 				});
 				describe('with UTC timezone', function() {
 					it('does not allow a drag', function(done) {
+						var options = {};
+					
 						options.timezone = 'UTC';
 						options.events = [ {
 							start: '2014-11-10T03:00:00+00:00',
@@ -298,6 +320,8 @@ describe('event constraint', function() {
 
 			describe('into a constraint it encompasses', function() {
 				it('does not allow a drag', function(done) {
+					var options = {};
+					
 					options.events = [ {
 						start: '2014-11-10T01:00:00',
 						end: '2014-11-10T05:00:00',
@@ -316,6 +340,8 @@ describe('event constraint', function() {
 
 			describe('when the start is already outside the constraint', function() {
 				it('does not allow a resize', function(done) {
+					var options = {};
+					
 					options.events = [ {
 						start: '2014-11-12T01:00:00',
 						end: '2014-11-12T03:00:00',
@@ -330,6 +356,8 @@ describe('event constraint', function() {
 
 			describe('when resized well within the constraint', function() {
 				it('allows a resize', function(done) {
+					var options = {};
+					
 					options.events = [ {
 						start: '2014-11-12T02:00:00',
 						end: '2014-11-12T04:00:00',
@@ -344,6 +372,8 @@ describe('event constraint', function() {
 
 			describe('when resized to the end of the constraint', function() {
 				it('allows a resize', function(done) {
+					var options = {};
+					
 					options.events = [ {
 						start: '2014-11-12T02:00:00',
 						end: '2014-11-12T04:00:00',
@@ -358,6 +388,8 @@ describe('event constraint', function() {
 
 			describe('when resized past the end of the constraint', function() {
 				it('does not allow a resize', function(done) {
+					var options = {};
+					
 					options.events = [ {
 						start: '2014-11-12T02:00:00',
 						end: '2014-11-12T04:00:00',
@@ -378,7 +410,10 @@ describe('event constraint', function() {
 		describe('when an event is being dragged', function() {
 
 			describe('to the middle of the constraint range', function() {
+
 				it('allows a drag', function(done) {
+					var options = {};
+					
 					options.events = [ {
 						start: '2014-11-12T01:00:00',
 						end: '2014-11-12T03:00:00',
@@ -393,6 +428,8 @@ describe('event constraint', function() {
 
 			describe('outside of a constraint range', function() {
 				it('does not allow a drag', function(done) {
+					var options = {};
+					
 					options.events = [ {
 						start: '2014-11-12T01:00:00',
 						end: '2014-11-12T03:00:00',
@@ -407,6 +444,8 @@ describe('event constraint', function() {
 
 			describe('on an off-day of a constraint range', function() {
 				it('does not allow a drag', function(done) {
+					var options = {};
+					
 					options.events = [ {
 						start: '2014-11-12T01:00:00',
 						end: '2014-11-12T03:00:00',
@@ -427,7 +466,10 @@ describe('event constraint', function() {
 		describe('when an event is being dragged', function() {
 
 			describe('to the middle of the constraint range', function() {
+				
 				it('allows a drag', function(done) {
+					var options = {};
+					
 					options.businessHours = {
 						start: '02:00',
 						end: '06:00'
@@ -443,6 +485,8 @@ describe('event constraint', function() {
 
 			describe('outside of a constraint range', function() {
 				it('does not allow a drag', function(done) {
+					var options = {};
+					
 					options.businessHours = {
 						start: '02:00',
 						end: '06:00'
@@ -458,6 +502,8 @@ describe('event constraint', function() {
 
 			describe('on an off-day of a constraint range', function() {
 				it('does not allow a drag', function(done) {
+					var options = {};
+					
 					options.businessHours = {
 						start: '02:00',
 						end: '06:00',
@@ -480,6 +526,8 @@ describe('event constraint', function() {
 
 			describe('to the middle of the constraint range', function() {
 				it('allows a drag', function(done) {
+					var options = {};
+					
 					options.events = [
 						{
 							start: '2014-11-12T01:00:00',
@@ -500,6 +548,8 @@ describe('event constraint', function() {
 			describe('outside of a foreground event constraint', function() {
 				describe('with an explicit end time', function() {
 					it('does not allow a drag', function(done) {
+						var options = {};
+					
 						options.events = [
 							{
 								start: '2014-11-12T01:00:00',
@@ -518,6 +568,8 @@ describe('event constraint', function() {
 				});
 				describe('when an implied end time', function() {
 					it('does not allow a drag', function(done) {
+						var options = {};
+						
 						options.defaultTimedEventDuration = '01:00:00';
 						options.events = [
 							{
@@ -538,6 +590,8 @@ describe('event constraint', function() {
 
 			describe('outside of a background-event constraint', function() {
 				it('does not allow a drag', function(done) {
+					var options = {};
+					
 					options.events = [
 						{
 							start: '2014-11-12T01:00:00',
@@ -558,6 +612,8 @@ describe('event constraint', function() {
 
 			describe('when the event ID constraint matches no events', function() {
 				it('does not allow a drag', function(done) {
+					var options = {};
+					
 					options.events = [
 						{
 							start: '2014-11-12T01:00:00',
@@ -569,12 +625,12 @@ describe('event constraint', function() {
 				});
 			});
 
-			describe('when in month view', function() {
-				beforeEach(function() {
-					options.defaultView = 'month';
-				});
+			describe('when in month view', function() {				
+				pushOptions({defaultView: 'month'});
 				describe('when the event ID constraint matches no events', function() {
 					it('does not allow a drag', function(done) {
+						var options = {};
+					
 						options.events = [
 							{
 								start: '2014-11-12',
@@ -590,23 +646,20 @@ describe('event constraint', function() {
 	});
 });
 
-describe('selectConstraint', function() {
-
-	var options;
-
-	beforeEach(function() {
-		options = {};
-		options.defaultDate = '2014-11-10';
-		options.defaultView = 'agendaWeek';
-		options.scrollTime = '00:00';
-		affix('#cal');
-		$('#cal').width(1100);
+describe('selectConstraint', function() {	
+			
+	pushOptions({
+		defaultDate:'2014-11-10',			
+		defaultView:'agendaWeek',
+		scrollTime:'00:00',				
 	});
 
 	describe('when used with a specific date range', function() {
 
 		describe('when dragged clearly within', function() {
 			it('allows a selection', function(done) {
+				var options = {};
+				
 				options.selectConstraint = {
 					start: '2014-11-12T01:00:00',
 					end: '2014-11-12T20:00:00'
@@ -617,6 +670,8 @@ describe('selectConstraint', function() {
 
 		describe('when dragged within, starting with the constraint start', function() {
 			it('allows a selection', function(done) {
+				var options = {};
+				
 				options.selectConstraint = {
 					start: '2014-11-12T01:00:00',
 					end: '2014-11-12T20:00:00'
@@ -627,6 +682,8 @@ describe('selectConstraint', function() {
 
 		describe('when dragged within, ending with the constraint end', function() {
 			it('allows a selection', function(done) {
+				var options = {};
+				
 				options.selectConstraint = {
 					start: '2014-11-12T01:00:00',
 					end: '2014-11-12T05:00:00'
@@ -637,6 +694,8 @@ describe('selectConstraint', function() {
 
 		describe('when dragged intersecting the constraint start', function() {
 			it('does not allow a selection', function(done) {
+				var options = {};
+				
 				options.selectConstraint = {
 					start: '2014-11-12T03:00:00',
 					end: '2014-11-12T20:00:00'
@@ -647,6 +706,8 @@ describe('selectConstraint', function() {
 
 		describe('when dragged intersecting the constraint end', function() {
 			it('does not allow a selection', function(done) {
+				var options = {};
+				
 				options.selectConstraint = {
 					start: '2014-11-12T03:00:00',
 					end: '2014-11-12T07:00:00'
@@ -658,6 +719,8 @@ describe('selectConstraint', function() {
 		describe('when dragged after the constraint', function() {
 			describe('when in agendaWeek view with timed events', function() {
 				it('does not allow a selection', function(done) {
+					var options = {};
+					
 					options.selectConstraint = {
 						start: '2014-11-12T03:00:00',
 						end: '2014-11-12T05:00:00'
@@ -665,12 +728,12 @@ describe('selectConstraint', function() {
 					testSelection(options, '05:00', '2014-11-12T07:00:00', false, done);
 				});
 			});
-			describe('when in month view', function() {
-				beforeEach(function() {
-					options.defaultView = 'month';
-				});
+			describe('when in month view', function() {				
+				pushOptions({defaultView: 'month'});
 				describe('when an all-day constraint', function() {
 					it('does not allow a selection', function(done) {
+						var options = {};
+					
 						options.selectConstraint = {
 							start: '2014-11-13',
 							end: '2014-11-14'
@@ -680,6 +743,8 @@ describe('selectConstraint', function() {
 				});
 				describe('when a timed constraint, out of bounds', function() {
 					it('does not allow a selection', function(done) {
+						var options = {};
+					
 						options.selectConstraint = {
 							start: '2014-11-12T01:00:00',
 							end: '2014-11-14T00:00:00'
@@ -689,6 +754,8 @@ describe('selectConstraint', function() {
 				});
 				describe('when a timed constraint, in bounds', function() {
 					it('allows a selection', function(done) {
+						var options = {};
+					
 						options.selectConstraint = {
 							start: '2014-11-12T00:00:00',
 							end: '2014-11-14T00:00:00'
@@ -704,6 +771,8 @@ describe('selectConstraint', function() {
 
 		describe('to the middle of the constraint range', function() {
 			it('allows a selection when in bounds', function(done) {
+				var options = {};
+				
 				options.selectConstraint = {
 					start: '01:00:00',
 					end: '05:00:00'
@@ -714,6 +783,8 @@ describe('selectConstraint', function() {
 
 		describe('outside of a constraint range', function() {
 			it('does not allow a selection when single day', function(done) {
+				var options = {};
+				
 				options.selectConstraint = {
 					start: '01:00:00',
 					end: '05:00:00'
@@ -721,6 +792,8 @@ describe('selectConstraint', function() {
 				testSelection(options, '02:00', '2014-11-12T06:00:00', false, done);
 			});
 			it('does not allow a selection when multiday', function(done) {
+				var options = {};
+				
 				options.selectConstraint = {
 					start: '01:00:00',
 					end: '05:00:00'
@@ -734,6 +807,8 @@ describe('selectConstraint', function() {
 
 		describe('to the middle of the constraint range', function() {
 			it('allows a selection', function(done) {
+				var options = {};
+				
 				options.businessHours = {
 					start: '01:00:00',
 					end: '05:00:00'
@@ -745,6 +820,8 @@ describe('selectConstraint', function() {
 
 		describe('outside of a constraint range', function() {
 			it('does not allow a selection', function(done) {
+				var options = {};
+				
 				options.businessHours = {
 					start: '01:00:00',
 					end: '05:00:00'
@@ -756,6 +833,8 @@ describe('selectConstraint', function() {
 
 		describe('with a custom dow when dragged to a dead day', function() {
 			it('does not allow a selection', function(done) {
+				var options = {};
+				
 				options.businessHours = {
 					start: '01:00:00',
 					end: '05:00:00',
@@ -771,6 +850,8 @@ describe('selectConstraint', function() {
 
 		describe('to the middle of the constraint range', function() {
 			it('allows a selection', function(done) {
+				var options = {};
+				
 				options.events = [ {
 					id: 'yo',
 					start: '2014-11-12T02:00:00',
@@ -784,6 +865,8 @@ describe('selectConstraint', function() {
 
 		describe('outside of a constraint range', function() {
 			it('does not allow a selection', function(done) {
+				var options = {};
+				
 				options.events = [ {
 					id: 'yo',
 					start: '2014-11-12T02:00:00',
@@ -798,12 +881,16 @@ describe('selectConstraint', function() {
 		describe('when event ID does not match any events', function() {
 			describe('when in agendaWeek view', function() {
 				it('does not allow a selection', function(done) {
+					var options = {};
+					
 					options.selectConstraint = 'yooo';
 					testSelection(options, '03:00', '2014-11-12T06:00:00', false, done);
 				});
 			});
 			describe('when in month view', function() {
 				it('does not allow a selection', function(done) {
+					var options = {};
+					
 					options.defaultView = 'month';
 					options.selectConstraint = 'yooo';
 					testSelection(options, null, '2014-11-15', false, done);

+ 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;
 		});

+ 75 - 51
tests/legacy/external-dnd-advanced.js

@@ -1,14 +1,8 @@
 import { testEventDrag } from '../lib/dnd-resize-utils';
 
-describe('advanced external dnd', function() {
-	var options;
+describe('advanced external dnd', function() {	
 
-	beforeEach(function() {
-		options = {
-			defaultDate: '2014-11-13',
-			scrollTime: '00:00:00',
-			droppable: true
-		};
+	beforeEach(function(){
 		affix('.drag');
 		$('.drag')
 			.text('yo')
@@ -18,25 +12,20 @@ describe('advanced external dnd', function() {
 				color: 'white'
 			})
 			.draggable();
-		affix('#cal');
-		$('#cal').width(1200);
+	})
+	pushOptions({
+		defaultDate: '2014-11-13',
+		scrollTime: '00:00:00',
+		droppable: true
 	});
 
-
-	describe('in agenda slots', function() {
-		beforeEach(function() {
-			options.defaultView = 'agendaWeek';
-		});
-
+	describe('in agenda slots', function() {		
+		pushOptions({defaultView:'agendaWeek'});
 		describe('when no element event data', function() {
-
-			describe('when given duration through defaultTimedEventDuration', function() {
-				beforeEach(function() {
-					options.defaultTimedEventDuration = '2:30';
-				});
+			describe('when given duration through defaultTimedEventDuration', function() {				
+				pushOptions({defaultTimedEventDuration:'2:30'});				
 				defineTests();
 			});
-
 			describe('when given duration through data-duration', function() {
 				beforeEach(function() {
 					$('.drag').data('duration', '2:30');
@@ -46,9 +35,11 @@ describe('advanced external dnd', function() {
 
 			function defineTests() {
 				it('fires correctly', function(done) {
+					var options = {};
 					testExternalElDrag(options, '2014-11-13T03:00:00', true, done);
 				});
 				it('is not affected by eventOverlap:false', function(done) {
+					var options = {};
 					options.eventOverlap = false;
 					options.events = [ {
 						start: '2014-11-13T01:00:00',
@@ -57,6 +48,7 @@ describe('advanced external dnd', function() {
 					testExternalElDrag(options, '2014-11-13T03:00:00', true, done);
 				});
 				it('is not affected by an event object\'s overlap:false', function(done) {
+					var options = {};
 					options.events = [ {
 						start: '2014-11-13T01:00:00',
 						end: '2014-11-13T05:00:00',
@@ -65,6 +57,8 @@ describe('advanced external dnd', function() {
 					testExternalElDrag(options, '2014-11-13T03:00:00', true, done);
 				});
 				it('is not affected by eventConstraint', function(done) {
+					var options = {};
+					
 					options.eventConstraint = {
 						start: '03:00',
 						end: '10:00'
@@ -72,28 +66,33 @@ describe('advanced external dnd', function() {
 					testExternalElDrag(options, '2014-11-13T02:00:00', true, done);
 				});
 				describe('with selectOverlap:false', function() {
-					beforeEach(function() {
-						options.selectOverlap = false;
-						options.events = [ {
+					pushOptions({
+						selectOverlap: false,
+						events: [ {
 							start: '2014-11-13T04:00:00',
 							end: '2014-11-13T08:00:00'
-						} ];
+						}]
 					});
 					it('is not allowed to overlap an event', function(done) {
+						var options = {};
 						testExternalElDrag(options, '2014-11-13T02:00:00', false, done);
 					});
 				});
 				describe('with a selectConstraint', function() {
-					beforeEach(function() {
-						options.selectConstraint = {
+					pushOptions({
+						selectConstraint :{
 							start: '04:00',
-							end: '08:00'
-						};
-					});
+							end: '08:00',
+						}
+					})				
 					it('can be dropped within', function(done) {
+						var options = {};
+					
 						testExternalElDrag(options, '2014-11-13T05:30:00', true, done);
 					});
 					it('cannot be dropped when not fully contained', function(done) {
+						var options = {};
+					
 						testExternalElDrag(options, '2014-11-13T06:00:00', false, done);
 					});
 				});
@@ -103,6 +102,8 @@ describe('advanced external dnd', function() {
 		describe('when event data is given', function() {
 
 			it('fires correctly', function(done) {
+				var options = {};
+				
 				$('.drag').data('event', { title: 'hey' });
 				testExternalEventDrag(options, '2014-11-13T02:00:00', true, done);
 			});
@@ -136,6 +137,8 @@ describe('advanced external dnd', function() {
 				});
 				function defineTests() {
 					it('voids the given time when dropped on a timed slot', function(done) {
+						var options = {};
+					
 						testExternalEventDrag(options, '2014-11-13T02:00:00', true, done);
 							// will test the resulting event object's start
 					});
@@ -158,8 +161,10 @@ describe('advanced external dnd', function() {
 				});
 				function defineTests() {
 					it('accepts the given duration when dropped on a timed slot', function(done) {
+						var options = {};
+					
 						testExternalEventDrag(options, '2014-11-13T02:00:00', true, function() {
-							var event = $('#cal').fullCalendar('clientEvents')[0];
+							var event = currentCalendar.clientEvents()[0];
 							expect(event.start).toEqualMoment('2014-11-13T02:00:00');
 							expect(event.end).toEqualMoment('2014-11-13T07:00:00');
 							done();
@@ -184,12 +189,14 @@ describe('advanced external dnd', function() {
 				});
 				function defineTests() {
 					it('keeps the event when navigating away and back', function(done) {
+						var options = {};
+					
 						testExternalEventDrag(options, '2014-11-13T02:00:00', true, function() {
 							setTimeout(function() { // make sure to escape handlers
 								expect($('.fc-event').length).toBe(1);
-								$('#cal').fullCalendar('next');
+								currentCalendar.next();
 								expect($('.fc-event').length).toBe(0);
-								$('#cal').fullCalendar('prev');
+								currentCalendar.prev();
 								expect($('.fc-event').length).toBe(1);
 								done();
 							}, 0);
@@ -200,22 +207,26 @@ describe('advanced external dnd', function() {
 
 			describe('when an overlap is specified', function() {
 				describe('via eventOverlap', function() {
-					beforeEach(function() {
-						options.eventOverlap = false;
-						options.events = [ {
+					pushOptions({
+						eventOverlap: false,
+						events: [ {
 							start: '2014-11-13T05:00:00',
 							end: '2014-11-13T08:00:00'
-						} ];
+						} ]
+					})
+					beforeEach(function(){
 						$('.drag').data('event', true);
 					});
 					defineTests();
 				});
 				describe('via an overlap on this event', function() {
-					beforeEach(function() {
-						options.events = [ {
+					pushOptions({
+						events: [{
 							start: '2014-11-13T05:00:00',
 							end: '2014-11-13T08:00:00'
-						} ];
+						}]
+					});
+					beforeEach(function() {						
 						$('.drag').data('event', {
 							overlap: false
 						});
@@ -223,21 +234,25 @@ describe('advanced external dnd', function() {
 					defineTests();
 				});
 				describe('via an overlap on the other event', function() {
-					beforeEach(function() {
-						options.events = [ {
+					pushOptions({
+						events: [{
 							start: '2014-11-13T05:00:00',
 							end: '2014-11-13T08:00:00',
 							overlap: false
-						} ];
+						}]
+					});
+					beforeEach(function() {						
 						$('.drag').data('event', true);
 					});
 					defineTests();
 				});
 				function defineTests() {
 					it('allows a drop when not colliding with the other event', function(done) {
+						var options = {};
 						testExternalEventDrag(options, '2014-11-13T08:00:00', true, done);
 					});
 					it('prevents a drop when colliding with the other event', function(done) {
+						var options = {};						
 						testExternalEventDrag(options, '2014-11-13T06:00:00', false, done);
 					});
 				}
@@ -245,11 +260,13 @@ describe('advanced external dnd', function() {
 
 			describe('when a constraint is specified', function() {
 				describe('via eventConstraint', function() {
-					beforeEach(function() {
-						options.eventConstraint = {
+					pushOptions({
+						eventConstraint: {
 							start: '04:00',
 							end: '08:00'
-						};
+						}
+					});
+					beforeEach(function() {						
 						$('.drag').data('event', { duration: '02:00' });
 					});
 					defineTests();
@@ -268,9 +285,11 @@ describe('advanced external dnd', function() {
 				});
 				function defineTests() {
 					it('allows a drop when inside the constraint', function(done) {
+						var options = {};
 						testExternalEventDrag(options, '2014-11-13T05:00:00', true, done);
 					});
 					it('disallows a drop when partially outside of the constraint', function(done) {
+						var options = {};						
 						testExternalEventDrag(options, '2014-11-13T07:00:00', false, done);
 					});
 				}
@@ -280,14 +299,16 @@ describe('advanced external dnd', function() {
 
 	// TODO: write more tests for DayGrid!
 
-	describe('in month whole-days', function() {
-		beforeEach(function() {
-			options.defaultView = 'month';
+	describe('in month whole-days', function() {		
+		pushOptions({
+			defaultView: 'month'
 		});
 
 		describe('when event data is given', function() {
 
 			it('fires correctly', function(done) {
+				var options = {};
+				
 				$('.drag').data('event', { title: 'hey' });
 				testExternalEventDrag(options, '2014-11-13', true, done);
 			});
@@ -321,9 +342,11 @@ describe('advanced external dnd', function() {
 				});
 				function defineTests() {
 					it('accepts the given start time for the dropped day', function(done) {
+						var options = {};
+						
 						testExternalEventDrag(options, '2014-11-13', true, function() {
 							// the whole-day start was already checked. we still need to check the exact time
-							var event = $('#cal').fullCalendar('clientEvents')[0];
+							var event = currentCalendar.clientEvents()[0];
 							expect(event.start).toEqualMoment('2014-11-13T05:00:00');
 							done();
 						});
@@ -390,3 +413,4 @@ describe('advanced external dnd', function() {
 	}
 
 });
+

+ 6 - 6
tests/lib/dnd-resize-utils.js

@@ -5,7 +5,7 @@ export function testEventDrag(options, dropDate, expectSuccess, callback, eventC
 
 	options.editable = true;
 	options.eventAfterAllRender = function() {
-		var calendar = $('#cal').fullCalendar('getCalendar');
+		var calendar = currentCalendar;
 		var isDraggingExternal = false;
 		var dayEl;
 		var eventEl;
@@ -83,7 +83,7 @@ export function testEventDrag(options, dropDate, expectSuccess, callback, eventC
 			}
 		});
 	};
-	$('#cal').fullCalendar(options);
+	initCalendar(options);
 }
 
 
@@ -92,7 +92,7 @@ export function testEventResize(options, resizeDate, expectSuccess, callback, ev
 
 	options.editable = true;
 	options.eventAfterAllRender = function() {
-		var calendar = $('#cal').fullCalendar('getCalendar');
+		var calendar = currentCalendar;
 		var lastDayEl;
 		var lastSlatIndex;
 		var lastSlatEl;
@@ -154,7 +154,7 @@ export function testEventResize(options, resizeDate, expectSuccess, callback, ev
 			}
 		});
 	};
-	$('#cal').fullCalendar(options);
+	initCalendar(options);
 }
 
 
@@ -176,9 +176,9 @@ export function testSelection(options, startTime, end, expectSuccess, callback)
 				selectionEnd.format() === end.format();
 	};
 	spyOn(options, 'select').and.callThrough();
-	$('#cal').fullCalendar(options);
+	initCalendar(options);
 
-	calendar = $('#cal').fullCalendar('getCalendar');
+	calendar = currentCalendar;
 	start = calendar.moment('2014-11-12');
 	end = calendar.moment(end);