Parcourir la source

updated constraint.js and external-dnd-advanced.js in legacy tests and dnd-resize-utils.js in tests/lib

kyle roux il y a 8 ans
Parent
commit
9e0ae5cac4
3 fichiers modifiés avec 205 ajouts et 94 suppressions
  1. 124 37
      tests/legacy/constraint.js
  2. 75 51
      tests/legacy/external-dnd-advanced.js
  3. 6 6
      tests/lib/dnd-resize-utils.js

+ 124 - 37
tests/legacy/constraint.js

@@ -1,23 +1,16 @@
 
 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',
@@ -31,6 +24,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',
@@ -41,7 +35,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();
@@ -52,6 +46,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',
@@ -67,6 +62,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',
@@ -80,6 +77,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',
@@ -95,6 +94,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',
@@ -111,6 +112,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',
@@ -122,12 +125,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',
@@ -141,6 +144,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',
@@ -154,6 +159,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',
@@ -167,6 +174,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',
@@ -182,6 +191,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',
@@ -197,7 +208,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'
@@ -225,6 +237,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',
@@ -238,6 +252,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',
@@ -255,6 +271,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',
@@ -268,6 +286,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',
@@ -281,6 +301,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',
@@ -297,6 +319,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',
@@ -315,6 +339,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',
@@ -329,6 +355,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',
@@ -343,6 +371,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',
@@ -357,6 +387,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',
@@ -377,7 +409,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',
@@ -392,6 +427,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',
@@ -406,6 +443,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',
@@ -426,7 +465,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'
@@ -442,6 +484,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'
@@ -457,6 +501,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',
@@ -479,6 +525,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',
@@ -499,6 +547,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',
@@ -517,6 +567,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 = [
 							{
@@ -537,6 +589,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',
@@ -557,6 +611,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',
@@ -568,12 +624,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',
@@ -589,23 +645,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'
@@ -616,6 +669,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'
@@ -626,6 +681,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'
@@ -636,6 +693,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'
@@ -646,6 +705,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'
@@ -657,6 +718,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'
@@ -664,12 +727,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'
@@ -679,6 +742,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'
@@ -688,6 +753,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'
@@ -703,6 +770,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'
@@ -713,6 +782,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'
@@ -720,6 +791,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'
@@ -733,6 +806,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'
@@ -744,6 +819,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'
@@ -755,6 +832,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',
@@ -770,6 +849,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',
@@ -783,6 +864,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',
@@ -797,12 +880,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);

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

@@ -1,13 +1,7 @@
 
-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')
@@ -17,25 +11,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');
@@ -45,9 +34,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',
@@ -56,6 +47,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',
@@ -64,6 +56,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'
@@ -71,28 +65,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);
 					});
 				});
@@ -102,6 +101,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);
 			});
@@ -135,6 +136,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
 					});
@@ -157,8 +160,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();
@@ -183,12 +188,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);
@@ -199,22 +206,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
 						});
@@ -222,21 +233,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);
 					});
 				}
@@ -244,11 +259,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();
@@ -267,9 +284,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);
 					});
 				}
@@ -279,14 +298,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);
 			});
@@ -320,9 +341,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();
 						});
@@ -389,3 +412,4 @@ describe('advanced external dnd', function() {
 	}
 
 });
+

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

@@ -5,7 +5,7 @@ function testEventDrag(options, dropDate, expectSuccess, callback, eventClassNam
 
 	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 @@ function testEventDrag(options, dropDate, expectSuccess, callback, eventClassNam
 			}
 		});
 	};
-	$('#cal').fullCalendar(options);
+	initCalendar(options);
 }
 
 
@@ -92,7 +92,7 @@ function testEventResize(options, resizeDate, expectSuccess, callback, eventClas
 
 	options.editable = true;
 	options.eventAfterAllRender = function() {
-		var calendar = $('#cal').fullCalendar('getCalendar');
+		var calendar = currentCalendar;
 		var lastDayEl;
 		var lastSlatIndex;
 		var lastSlatEl;
@@ -154,7 +154,7 @@ function testEventResize(options, resizeDate, expectSuccess, callback, eventClas
 			}
 		});
 	};
-	$('#cal').fullCalendar(options);
+	initCalendar(options);
 }
 
 
@@ -176,9 +176,9 @@ 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);