소스 검색

Merge branch 'master' of https://github.com/acerix/fullcalendar

Adam Shaw 8 년 전
부모
커밋
8ac19ce7fc

+ 38 - 37
tests/legacy/TimeGrid-events.js

@@ -1,33 +1,31 @@
 
 describe('TimeGrid event rendering', function() {
-	var options;
 
-	beforeEach(function() {
-		affix('#cal');
-		options = {
-			defaultDate: '2014-08-23',
-			defaultView: 'agendaWeek',
-			scrollTime: '00:00:00'
-		};
+	pushOptions({
+		defaultDate: '2014-08-23',
+		defaultView: 'agendaWeek',
+		scrollTime: '00:00:00'
 	});
 
 	it('renders the start and end time of an event that spans only 1 day', function() {
-		options.events = [ {
-			title: 'event1',
-			start: '2014-08-18T02:00:00',
-			end: '2014-08-18T22:00:00'
-		} ];
-		$('#cal').fullCalendar(options);
+		initCalendar({
+			events: [ {
+				title: 'event1',
+				start: '2014-08-18T02:00:00',
+				end: '2014-08-18T22:00:00'
+			} ]
+		});
 		expect('.fc-event .fc-time').toHaveText('2:00 - 10:00');
 	});
 
 	it('renders time to/from midnight for an event that spans two days', function() {
-		options.events = [ {
-			title: 'event1',
-			start: '2014-08-18T02:00:00',
-			end: '2014-08-19T22:00:00'
-		} ];
-		$('#cal').fullCalendar(options);
+		initCalendar({
+			events: [ {
+				title: 'event1',
+				start: '2014-08-18T02:00:00',
+				end: '2014-08-19T22:00:00'
+			} ]
+		});
 		var seg1 = $('.fc-event:eq(0)');
 		var seg2 = $('.fc-event:eq(1)');
 		expect(seg1.find('.fc-time')).toHaveText('2:00 - 12:00');
@@ -35,34 +33,37 @@ describe('TimeGrid event rendering', function() {
 	});
 
 	it('renders no time on an event segment that spans through an entire day', function() {
-		options.events = [ {
-			title: 'event1',
-			start: '2014-08-18T02:00:00',
-			end: '2014-08-20T22:00:00'
-		} ];
-		$('#cal').fullCalendar(options);
+		initCalendar({
+			events: [ {
+				title: 'event1',
+				start: '2014-08-18T02:00:00',
+				end: '2014-08-20T22:00:00'
+			} ]
+		});
 		var seg2 = $('.fc-event:eq(1)');
 		expect(seg2).toBeInDOM();
 		expect(seg2.find('.fc-time')).not.toBeInDOM();
 	});
 
 	it('renders an event with no url with no <a> href', function() {
-		options.events = [ {
-			title: 'event1',
-			start: '2014-08-18T02:00:00'
-		} ];
-		$('#cal').fullCalendar(options);
+		initCalendar({
+			events: [ {
+				title: 'event1',
+				start: '2014-08-18T02:00:00'
+			} ]
+		});
 		var seg = $('.fc-event');
 		expect(seg).not.toHaveAttr('href');
 	});
 
 	it('renders an event with a url with an <a> href', function() {
-		options.events = [ {
-			title: 'event1',
-			start: '2014-08-18T02:00:00',
-			url: 'http://google.com/'
-		} ];
-		$('#cal').fullCalendar(options);
+		initCalendar({
+			events: [ {
+				title: 'event1',
+				start: '2014-08-18T02:00:00',
+				url: 'http://google.com/'
+			} ]
+		});
 		var seg = $('.fc-event');
 		expect(seg).toHaveAttr('href');
 	});

+ 10 - 14
tests/legacy/View.js

@@ -1,33 +1,29 @@
 describe('View object', function() {
 
-	var options;
-
 	/*
 	TODO: move tests from eventLimitClick.js about view.name/type into here
 	*/
 
-	beforeEach(function() {
-		affix('#cal');
-		options = {
-			defaultDate: '2015-01-01'
-		};
+	pushOptions({
+		defaultDate: '2015-01-01'
 	});
 
 	describe('title', function() {
 
 		it('is a correctly defined string', function() {
-			$('#cal').fullCalendar(options);
-			var view = $('#cal').fullCalendar('getView');
+			initCalendar();
+			var view = currentCalendar.getView();
 			expect(view.title).toBe('January 2015');
 		});
 
 		it('is available in the viewRender callback', function() {
-			options.viewRender = function(view) {
+			var viewRenderSpy = spyOnCalendarCallback('viewRender', function(view) {
 				expect(view.title).toBe('January 2015');
-			};
-			spyOn(options, 'viewRender').and.callThrough();
-			$('#cal').fullCalendar(options);
-			expect(options.viewRender).toHaveBeenCalled();
+			});
+			initCalendar();
+			expect(viewRenderSpy).toHaveBeenCalled();
 		});
+
 	});
+
 });

+ 69 - 44
tests/legacy/aspectRatio.js

@@ -1,139 +1,164 @@
 
 describe('aspectRatio', function() {
 
-	beforeEach(function() {
-		affix('#cal');
-	});
+	function getCalendarElement(width) {
+		return $('<div id="calendar">').appendTo('body').width(width)[0];
+	}
 
 	describe('when default settings are used', function() {
-		beforeEach(function() {
-			$('#cal').width(675);
-			$('#cal').fullCalendar();
-		});
+
+		var elementWidth = 675;
+
 		it('fc-content should use the ratio 1:35 to set height', function() {
+			initCalendar({}, getCalendarElement(elementWidth));
 			var height = $('.fc-view-container').height();
 			expect(Math.round(height)).toEqual(500);
 		});
+
 		it('fc-content should have width of div', function() {
+			initCalendar({}, getCalendarElement(elementWidth));
 			var width = $('.fc-view-container').width();
-			expect(Math.round(width)).toEqual(675);
+			expect(Math.round(width)).toEqual(elementWidth);
 		});
+
 	});
 
 	describe('when initializing the aspectRatio', function() {
 
+		var elementWidth = 1000;
+
 		describe('to 2', function() {
-			beforeEach(function() {
-				$('#cal').width(1000);
-				$('#cal').fullCalendar({
-					aspectRatio: 2
-				});
+
+			pushOptions({
+				aspectRatio: 2
 			});
+
 			it('should not change the width', function() {
+				initCalendar({}, getCalendarElement(elementWidth));
 				var width = $('.fc-view-container').width();
-				expect(Math.round(width)).toEqual(1000);
+				expect(Math.round(width)).toEqual(elementWidth);
 			});
+
 			it('should set the height to width sizes very close to ratio of 2', function() {
+				initCalendar({}, getCalendarElement(elementWidth));
 				var width = $('.fc-view-container').width();
 				var height = $('.fc-view-container').height();
 				var ratio = Math.round(width / height * 100);
 				expect(Math.round(ratio)).toEqual(200);
 			});
+
 		});
 
 		describe('to 1', function() {
-			beforeEach(function() {
-				$('#cal').width(1000);
-				$('#cal').fullCalendar({
-					aspectRatio: 1
-				});
+
+			pushOptions({
+				aspectRatio: 1
 			});
+
 			it('should not change the width', function() {
+				initCalendar({}, getCalendarElement(elementWidth));
 				var width = $('.fc-view-container').width();
-				expect(Math.round(width)).toEqual(1000);
+				expect(Math.round(width)).toEqual(elementWidth);
 			});
+
 			it('should set the height to width sizes very close to ratio of 2', function() {
+				initCalendar({}, getCalendarElement(elementWidth));
 				var width = $('.fc-view-container').width();
 				var height = $('.fc-view-container').height();
 				var ratio = Math.round(width / height * 100);
 				expect(Math.round(ratio)).toEqual(100);
 			});
+
 		});
 
 		describe('to less than 0.5', function() {
-			beforeEach(function() {
-				$('#cal').width(1000);
-				$('#cal').fullCalendar({
-					aspectRatio: 0.4
-				});
+
+			pushOptions({
+				aspectRatio: 0.4
 			});
+
 			it('should not change the width', function() {
+				initCalendar({}, getCalendarElement(elementWidth));
 				var width = $('.fc-view-container').width();
-				expect(Math.round(width)).toEqual(1000);
+				expect(Math.round(width)).toEqual(elementWidth);
 			});
+
 			it('should set the height to width ratio to 0.5', function() {
+				initCalendar({}, getCalendarElement(elementWidth));
 				var width = $('.fc-view-container').width();
 				var height = $('.fc-view-container').height();
 				var ratio = Math.round(width / height * 100);
 				expect(Math.round(ratio)).toEqual(50);
 			});
+
 		});
 
 		describe('to negative', function() {
-			beforeEach(function() {
-				$('#cal').width(1000);
-				$('#cal').fullCalendar({
-					aspectRatio: -2
-				});
+
+			pushOptions({
+				aspectRatio: -2
 			});
+
 			it('should not change the width', function() {
+				initCalendar({}, getCalendarElement(elementWidth));
 				var width = $('.fc-view-container').width();
-				expect(Math.round(width)).toEqual(1000);
+				expect(Math.round(width)).toEqual(elementWidth);
 			});
+
 			it('should set the height to width ratio to 0.5', function() {
+				initCalendar({}, getCalendarElement(elementWidth));
 				var width = $('.fc-view-container').width();
 				var height = $('.fc-view-container').height();
 				var ratio = Math.round(width / height * 100);
 				expect(Math.round(ratio)).toEqual(50);
 			});
+
 		});
 
 		describe('to zero', function() {
-			beforeEach(function() {
-				$('#cal').width(1000);
-				$('#cal').fullCalendar({
-					aspectRatio: 0
-				});
+
+			pushOptions({
+				aspectRatio: 0
 			});
+
 			it('should not change the width', function() {
+				initCalendar({}, getCalendarElement(elementWidth));
 				var width = $('.fc-view-container').width();
-				expect(Math.round(width)).toEqual(1000);
+				expect(Math.round(width)).toEqual(elementWidth);
 			});
+
 			it('should set the height to width ratio to 0.5', function() {
+				initCalendar({}, getCalendarElement(elementWidth));
 				var width = $('.fc-view-container').width();
 				var height = $('.fc-view-container').height();
 				var ratio = Math.round(width / height * 100);
 				expect(Math.round(ratio)).toEqual(50);
 			});
+
 		});
 
 		describe('to very large', function() {
-			beforeEach(function() {
-				$('#cal').width(1000);
-				$('#cal').fullCalendar({
-					aspectRatio: 4000
-				});
+
+			pushOptions({
+				aspectRatio: 4000
 			});
+
 			it('should not change the width', function() {
+				initCalendar({}, getCalendarElement(elementWidth));
 				var width = $('.fc-view-container').width();
-				expect(Math.round(width)).toEqual(1000);
+				expect(Math.round(width)).toEqual(elementWidth);
 			});
+
 			it('should cause rows to be natural height', function() {
+				initCalendar({}, getCalendarElement(elementWidth));
 				var actualHeight = $('.fc-view-container').height();
 				$('tr.fc-week td:first-child > div').css('min-height', '').css('background', 'red');
 				var naturalHeight = $('.fc-view-container').height();
 				expect(Math.round(actualHeight)).toEqual(Math.round(naturalHeight));
 			});
+
 		});
+
 	});
+
 });

+ 12 - 16
tests/legacy/basic-view.js

@@ -1,21 +1,19 @@
 
 describe('basic view rendering', function() {
 
-	beforeEach(function() {
-		affix('#cal');
+	pushOptions({
+		defaultView: 'month'
 	});
 
 	describe('when isRTL is false', function() {
 
-		beforeEach(function() {
-			$('#cal').fullCalendar({
-				defaultView: 'month',
-				isRTL: false
-			});
+		pushOptions({
+			isRTL: false
 		});
 
-		it('should have have days ordered sun to sat', function() {
-			var fc = $('#cal').find('.fc-day-header');
+		it('should have days ordered sun to sat', function() {
+			initCalendar();
+			var fc = $(currentCalendar.el).find('.fc-day-header');
 			expect(fc[0]).toHaveClass('fc-sun');
 			expect(fc[1]).toHaveClass('fc-mon');
 			expect(fc[2]).toHaveClass('fc-tue');
@@ -28,15 +26,13 @@ describe('basic view rendering', function() {
 
 	describe('when isRTL is true', function() {
 
-		beforeEach(function() {
-			$('#cal').fullCalendar({
-				defaultView: 'month',
-				isRTL: true
-			});
+		pushOptions({
+			isRTL: true
 		});
 
-		it('should have have days ordered sat to sun', function() {
-			var fc = $('#cal').find('.fc-day-header');
+		it('should have days ordered sat to sun', function() {
+			initCalendar();
+			var fc = $(currentCalendar.el).find('.fc-day-header');
 			expect(fc[0]).toHaveClass('fc-sat');
 			expect(fc[1]).toHaveClass('fc-fri');
 			expect(fc[2]).toHaveClass('fc-thu');

+ 62 - 78
tests/legacy/buttonIcons.js

@@ -1,92 +1,76 @@
 describe('buttonIcons', function() {
 
-    beforeEach(function() {
-        affix('#cal');
-    });
+	pushOptions({
+		header: {
+			left: 'prev,next today',
+			center: 'title',
+			right: 'prevYear, nextYear'
+		}
+	});
 
-    describe('when buttonIcons is not set', function() {
+	describe('when buttonIcons is not set', function() {
 
-        beforeEach(function() {
-            $('#cal').fullCalendar({
-                header: {
-                    left: 'prev,next today',
-                    center: 'title',
-                    right: 'prevYear, nextYear'
-                }
-            });
-        });
+		it('should have default values', function() {
+			initCalendar();
+			var $cal = $(currentCalendar.el);
+			var prevBtn = $cal.find('.fc-prev-button');
+			var nextBtn = $cal.find('.fc-next-button');
+			var nextYearBtn = $cal.find('.fc-nextYear-button');
+			var prevYearBtn = $cal.find('.fc-prevYear-button');
 
-        it('should have default values', function() {
-            var prevBtn = $('#cal').find('.fc-prev-button');
-            var nextBtn = $('#cal').find('.fc-next-button');
-            var nextYearBtn = $('#cal').find('.fc-nextYear-button');
-            var prevYearBtn = $('#cal').find('.fc-prevYear-button');
+			expect(prevBtn.find('span:first')).toHaveClass('fc-icon-left-single-arrow');
+			expect(nextBtn.find('span:first')).toHaveClass('fc-icon-right-single-arrow');
+			expect(nextYearBtn.find('span:first')).toHaveClass('fc-icon-right-double-arrow');
+			expect(prevYearBtn.find('span:first')).toHaveClass('fc-icon-left-double-arrow');
+		});
+	});
 
-            expect(prevBtn.find('span:first')).toHaveClass('fc-icon-left-single-arrow');
-            expect(nextBtn.find('span:first')).toHaveClass('fc-icon-right-single-arrow');
-            expect(nextYearBtn.find('span:first')).toHaveClass('fc-icon-right-double-arrow');
-            expect(prevYearBtn.find('span:first')).toHaveClass('fc-icon-left-double-arrow');
-        });
-    });
+	describe('when buttonIcons is set and theme is falsy', function() {
 
-    describe('when buttonIcons is set and theme is falsy', function() {
+		pushOptions({
+			buttonIcons: {
+				prev: 'some-icon-left',
+				next: 'some-icon-right',
+				prevYear: 'some-icon-leftYear',
+				nextYear: 'some-icon-rightYear'
+			}
+		});
 
-        beforeEach(function() {
-            $('#cal').fullCalendar({
-                buttonIcons: {
-                    prev: 'some-icon-left',
-                    next: 'some-icon-right',
-                    prevYear: 'some-icon-leftYear',
-                    nextYear: 'some-icon-rightYear'
-                },
-                header: {
-                    left: 'prev,next today',
-                    center: 'title',
-                    right: 'prevYear, nextYear'
-                }
-            });
-        });
+		it('should have the set values', function() {
+			initCalendar();
+			var $cal = $(currentCalendar.el);
+			var prevBtn = $cal.find('.fc-prev-button');
+			var nextBtn = $cal.find('.fc-next-button');
+			var prevYearBtn = $cal.find('.fc-prevYear-button');
+			var nextYearBtn = $cal.find('.fc-nextYear-button');
 
-        it('should have the set values', function() {
-            var prevBtn = $('#cal').find('.fc-prev-button');
-            var nextBtn = $('#cal').find('.fc-next-button');
-            var prevYearBtn = $('#cal').find('.fc-prevYear-button');
-            var nextYearBtn = $('#cal').find('.fc-nextYear-button');
+			expect(prevBtn.find('span:first')).toHaveClass('fc-icon-some-icon-left');
+			expect(prevBtn.find('span:first')).toHaveClass('fc-icon-some-icon-left');
+			expect(prevYearBtn.find('span:first')).toHaveClass('fc-icon-some-icon-leftYear');
+			expect(nextYearBtn.find('span:first')).toHaveClass('fc-icon-some-icon-rightYear');
+		});
+	});
 
+	describe('when theme is true', function() {
 
-            expect(prevBtn.find('span:first')).toHaveClass('fc-icon-some-icon-left');
-            expect(prevBtn.find('span:first')).toHaveClass('fc-icon-some-icon-left');
-            expect(prevYearBtn.find('span:first')).toHaveClass('fc-icon-some-icon-leftYear');
-            expect(nextYearBtn.find('span:first')).toHaveClass('fc-icon-some-icon-rightYear');
-        });
-    });
+		pushOptions({
+			theme: true
+		});
 
-    describe('when theme is true', function() {
+		it('buttonIcons is ignored', function() {
+			initCalendar();
+			var $cal = $(currentCalendar.el);
+			var prevBtn = $cal.find('.fc-prev-button');
+			var nextBtn = $cal.find('.fc-next-button');
+			var prevYearBtn = $cal.find('.fc-prevYear-button');
+			var nextYearBtn = $cal.find('.fc-nextYear-button');
+			var classesToSearch = [ '.fc-icon-left-single-arrow', '.fc-icon-right-double-arrow',
+									'.fc-icon-right-single-arrow', '.fc-icon-left-double-arrow' ];
 
-        beforeEach(function() {
-            $('#cal').fullCalendar({
-                theme: true,
-                header: {
-                    left: 'prev,next today',
-                    center: 'title',
-                    right: 'prevYear, nextYear'
-                }
-            });
-        });
-
-        it('buttonIcons is ignored', function() {
-            var prevBtn = $('#cal').find('.fc-prev-button');
-            var nextBtn = $('#cal').find('.fc-next-button');
-            var prevYearBtn = $('#cal').find('.fc-prevYear-button');
-            var nextYearBtn = $('#cal').find('.fc-nextYear-button');
-
-            var classesToSearch = [ '.fc-icon-left-single-arrow', '.fc-icon-right-double-arrow',
-                                    '.fc-icon-right-single-arrow', '.fc-icon-left-double-arrow' ];
-
-            for (var i = 0; i < classesToSearch.length; i++) {
-                var cls = classesToSearch[i];
-                expect($('#cal').find(cls).length).toBe(0);
-            };
-        });
-    });
+			for (var i = 0; i < classesToSearch.length; i++) {
+				var cls = classesToSearch[i];
+				expect($cal.find(cls).length).toBe(0);
+			};
+		});
+	});
 });

+ 220 - 221
tests/legacy/buttonText.js

@@ -1,225 +1,224 @@
 describe('button text', function() {
 
-  var settings;
-
-  beforeEach(function() {
-    affix('#cal');
-    settings = {
-      header: {
-        left: 'prevYear,prev,today,next,nextYear',
-        center: '',
-        right: 'month,basicWeek,basicDay,agendaWeek,agendaDay'
-      }
-    };
-  });
-
-  describe('with default locale', function() {
-
-    describe('with default buttonIcons', function() {
-
-      it('should contain default text values', function() {
-        $('#cal').fullCalendar(settings);
-
-        // will have button icons, to text will be empty
-        expect($('.fc-next-button')).toHaveText('');
-        expect($('.fc-nextYear-button')).toHaveText('');
-        expect($('.fc-prev-button')).toHaveText('');
-        expect($('.fc-prevYear-button')).toHaveText('');
-
-        expect($('.fc-today-button')).toHaveText('today');
-        expect($('.fc-month-button')).toHaveText('month');
-        expect($('.fc-basicWeek-button')).toHaveText('week');
-        expect($('.fc-agendaWeek-button')).toHaveText('week');
-        expect($('.fc-basicDay-button')).toHaveText('day');
-        expect($('.fc-agendaDay-button')).toHaveText('day');
-      });
-
-      it('should contain specified text values', function() {
-        settings.buttonText = {
-          prev: '<-',
-          next: '->',
-          prevYear: '<--',
-          nextYear: '-->',
-          today: 'tidei',
-          month: 'mun',
-          week: 'wiki',
-          day: 'dei'
-        };
-        $('#cal').fullCalendar(settings);
-
-        expect($('.fc-next-button')).toHaveText('->');
-        expect($('.fc-nextYear-button')).toHaveText('-->');
-        expect($('.fc-prev-button')).toHaveText('<-');
-        expect($('.fc-prevYear-button')).toHaveText('<--');
-
-        expect($('.fc-today-button')).toHaveText('tidei');
-        expect($('.fc-month-button')).toHaveText('mun');
-        expect($('.fc-agendaDay-button')).toHaveText('dei');
-        expect($('.fc-agendaWeek-button')).toHaveText('wiki');
-        expect($('.fc-basicDay-button')).toHaveText('dei');
-        expect($('.fc-basicWeek-button')).toHaveText('wiki');
-      });
-
-    });
-
-    describe('with buttonIcons turned off', function() {
-
-      beforeEach(function() {
-        settings.buttonIcons = false;
-      });
-
-      it('should contain default text values', function() {
-        $('#cal').fullCalendar(settings);
-
-        // will have actual text now
-        expect($('.fc-next-button')).toHaveText('next');
-        expect($('.fc-nextYear-button')).toHaveText('next year');
-        expect($('.fc-prev-button')).toHaveText('prev');
-        expect($('.fc-prevYear-button')).toHaveText('prev year');
-
-        expect($('.fc-today-button')).toHaveText('today');
-        expect($('.fc-month-button')).toHaveText('month');
-        expect($('.fc-basicWeek-button')).toHaveText('week');
-        expect($('.fc-agendaWeek-button')).toHaveText('week');
-        expect($('.fc-basicDay-button')).toHaveText('day');
-        expect($('.fc-agendaDay-button')).toHaveText('day');
-      });
-
-      it('should contain specified text values', function() {
-        settings.buttonText = {
-          prev: '<-',
-          next: '->',
-          prevYear: '<--',
-          nextYear: '-->',
-          today: 'tidei',
-          month: 'mun',
-          week: 'wiki',
-          day: 'dei'
-        };
-        $('#cal').fullCalendar(settings);
-
-        expect($('.fc-next-button')).toHaveText('->');
-        expect($('.fc-nextYear-button')).toHaveText('-->');
-        expect($('.fc-prev-button')).toHaveText('<-');
-        expect($('.fc-prevYear-button')).toHaveText('<--');
-
-        expect($('.fc-today-button')).toHaveText('tidei');
-        expect($('.fc-month-button')).toHaveText('mun');
-        expect($('.fc-agendaDay-button')).toHaveText('dei');
-        expect($('.fc-agendaWeek-button')).toHaveText('wiki');
-        expect($('.fc-basicDay-button')).toHaveText('dei');
-        expect($('.fc-basicWeek-button')).toHaveText('wiki');
-      });
-
-    });
-
-  });
-
-  describe('when locale is not default', function() {
-
-    beforeEach(function() {
-      settings.locale = 'fr';
-    });
-
-    describe('with default buttonIcons', function() {
-
-      it('should contain default text values', function() {
-        $('#cal').fullCalendar(settings);
-
-        // will contain icons, so will contain no text
-        expect($('.fc-next-button')).toHaveText('');
-        expect($('.fc-nextYear-button')).toHaveText('');
-        expect($('.fc-prev-button')).toHaveText('');
-        expect($('.fc-prevYear-button')).toHaveText('');
-
-        expect($('.fc-today-button')).toHaveText('Aujourd\'hui');
-        expect($('.fc-month-button')).toHaveText('Mois');
-        expect($('.fc-basicWeek-button')).toHaveText('Semaine');
-        expect($('.fc-agendaWeek-button')).toHaveText('Semaine');
-        expect($('.fc-basicDay-button')).toHaveText('Jour');
-        expect($('.fc-agendaDay-button')).toHaveText('Jour');
-      });
-
-      it('should contain specified text values', function() {
-        settings.buttonText = {
-          prev: '<-',
-          next: '->',
-          prevYear: '<--',
-          nextYear: '-->',
-          today: 'tidei',
-          month: 'mun',
-          week: 'wiki',
-          day: 'dei'
-        };
-        $('#cal').fullCalendar(settings);
-
-        expect($('.fc-next-button')).toHaveText('->');
-        expect($('.fc-nextYear-button')).toHaveText('-->');
-        expect($('.fc-prev-button')).toHaveText('<-');
-        expect($('.fc-prevYear-button')).toHaveText('<--');
-
-        expect($('.fc-today-button')).toHaveText('tidei');
-        expect($('.fc-month-button')).toHaveText('mun');
-        expect($('.fc-agendaDay-button')).toHaveText('dei');
-        expect($('.fc-agendaWeek-button')).toHaveText('wiki');
-        expect($('.fc-basicDay-button')).toHaveText('dei');
-        expect($('.fc-basicWeek-button')).toHaveText('wiki');
-      });
-
-    });
-
-    describe('with buttonIcons turned off', function() {
-
-      beforeEach(function() {
-        settings.buttonIcons = false;
-      });
-
-      it('should contain default text values', function() {
-        $('#cal').fullCalendar(settings);
-
-        // will have the locale's actual text now
-        expect($('.fc-next-button')).toHaveText('Suivant');
-        expect($('.fc-prev-button')).toHaveText('Précédent');
-        //// locales files don't have data for prev/next *year*
-        //expect($('.fc-nextYear-button')).toHaveText('Suivant');
-        //expect($('.fc-prevYear-button')).toHaveText('Précédent');
-
-        expect($('.fc-today-button')).toHaveText('Aujourd\'hui');
-        expect($('.fc-month-button')).toHaveText('Mois');
-        expect($('.fc-basicWeek-button')).toHaveText('Semaine');
-        expect($('.fc-agendaWeek-button')).toHaveText('Semaine');
-        expect($('.fc-basicDay-button')).toHaveText('Jour');
-        expect($('.fc-agendaDay-button')).toHaveText('Jour');
-      });
-
-      it('should contain specified text values', function() {
-        settings.buttonText = {
-          prev: '<-',
-          next: '->',
-          prevYear: '<--',
-          nextYear: '-->',
-          today: 'tidei',
-          month: 'mun',
-          week: 'wiki',
-          day: 'dei'
-        };
-        $('#cal').fullCalendar(settings);
-
-        expect($('.fc-next-button')).toHaveText('->');
-        expect($('.fc-nextYear-button')).toHaveText('-->');
-        expect($('.fc-prev-button')).toHaveText('<-');
-        expect($('.fc-prevYear-button')).toHaveText('<--');
-
-        expect($('.fc-today-button')).toHaveText('tidei');
-        expect($('.fc-month-button')).toHaveText('mun');
-        expect($('.fc-agendaDay-button')).toHaveText('dei');
-        expect($('.fc-agendaWeek-button')).toHaveText('wiki');
-        expect($('.fc-basicDay-button')).toHaveText('dei');
-        expect($('.fc-basicWeek-button')).toHaveText('wiki');
-      });
-
-    });
-
-  });
+	pushOptions({
+		header: {
+			left: 'prevYear,prev,today,next,nextYear',
+			center: '',
+			right: 'month,basicWeek,basicDay,agendaWeek,agendaDay'
+		}
+	});
+
+	describe('with default locale', function() {
+
+		describe('with default buttonIcons', function() {
+
+			it('should contain default text values', function() {
+				initCalendar();
+
+				// will have button icons, to text will be empty
+				expect($('.fc-next-button')).toHaveText('');
+				expect($('.fc-nextYear-button')).toHaveText('');
+				expect($('.fc-prev-button')).toHaveText('');
+				expect($('.fc-prevYear-button')).toHaveText('');
+
+				expect($('.fc-today-button')).toHaveText('today');
+				expect($('.fc-month-button')).toHaveText('month');
+				expect($('.fc-basicWeek-button')).toHaveText('week');
+				expect($('.fc-agendaWeek-button')).toHaveText('week');
+				expect($('.fc-basicDay-button')).toHaveText('day');
+				expect($('.fc-agendaDay-button')).toHaveText('day');
+			});
+
+			it('should contain specified text values', function() {
+				initCalendar({
+					buttonText: {
+						prev: '<-',
+						next: '->',
+						prevYear: '<--',
+						nextYear: '-->',
+						today: 'tidei',
+						month: 'mun',
+						week: 'wiki',
+						day: 'dei'
+					}
+				});
+
+				expect($('.fc-next-button')).toHaveText('->');
+				expect($('.fc-nextYear-button')).toHaveText('-->');
+				expect($('.fc-prev-button')).toHaveText('<-');
+				expect($('.fc-prevYear-button')).toHaveText('<--');
+
+				expect($('.fc-today-button')).toHaveText('tidei');
+				expect($('.fc-month-button')).toHaveText('mun');
+				expect($('.fc-agendaDay-button')).toHaveText('dei');
+				expect($('.fc-agendaWeek-button')).toHaveText('wiki');
+				expect($('.fc-basicDay-button')).toHaveText('dei');
+				expect($('.fc-basicWeek-button')).toHaveText('wiki');
+			});
+
+		});
+
+		describe('with buttonIcons turned off', function() {
+
+			pushOptions({
+				buttonIcons: false
+			});
+
+			it('should contain default text values', function() {
+				initCalendar();
+
+				// will have actual text now
+				expect($('.fc-next-button')).toHaveText('next');
+				expect($('.fc-nextYear-button')).toHaveText('next year');
+				expect($('.fc-prev-button')).toHaveText('prev');
+				expect($('.fc-prevYear-button')).toHaveText('prev year');
+
+				expect($('.fc-today-button')).toHaveText('today');
+				expect($('.fc-month-button')).toHaveText('month');
+				expect($('.fc-basicWeek-button')).toHaveText('week');
+				expect($('.fc-agendaWeek-button')).toHaveText('week');
+				expect($('.fc-basicDay-button')).toHaveText('day');
+				expect($('.fc-agendaDay-button')).toHaveText('day');
+			});
+
+			it('should contain specified text values', function() {
+				initCalendar({
+					buttonText: {
+						prev: '<-',
+						next: '->',
+						prevYear: '<--',
+						nextYear: '-->',
+						today: 'tidei',
+						month: 'mun',
+						week: 'wiki',
+						day: 'dei'
+					}
+				});
+
+				expect($('.fc-next-button')).toHaveText('->');
+				expect($('.fc-nextYear-button')).toHaveText('-->');
+				expect($('.fc-prev-button')).toHaveText('<-');
+				expect($('.fc-prevYear-button')).toHaveText('<--');
+
+				expect($('.fc-today-button')).toHaveText('tidei');
+				expect($('.fc-month-button')).toHaveText('mun');
+				expect($('.fc-agendaDay-button')).toHaveText('dei');
+				expect($('.fc-agendaWeek-button')).toHaveText('wiki');
+				expect($('.fc-basicDay-button')).toHaveText('dei');
+				expect($('.fc-basicWeek-button')).toHaveText('wiki');
+			});
+
+		});
+
+	});
+
+	describe('when locale is not default', function() {
+
+		pushOptions({
+			locale: 'fr'
+		});
+
+		describe('with default buttonIcons', function() {
+
+			it('should contain default text values', function() {
+				initCalendar();
+
+				// will contain icons, so will contain no text
+				expect($('.fc-next-button')).toHaveText('');
+				expect($('.fc-nextYear-button')).toHaveText('');
+				expect($('.fc-prev-button')).toHaveText('');
+				expect($('.fc-prevYear-button')).toHaveText('');
+
+				expect($('.fc-today-button')).toHaveText('Aujourd\'hui');
+				expect($('.fc-month-button')).toHaveText('Mois');
+				expect($('.fc-basicWeek-button')).toHaveText('Semaine');
+				expect($('.fc-agendaWeek-button')).toHaveText('Semaine');
+				expect($('.fc-basicDay-button')).toHaveText('Jour');
+				expect($('.fc-agendaDay-button')).toHaveText('Jour');
+			});
+
+			it('should contain specified text values', function() {
+				initCalendar({
+					buttonText: {
+						prev: '<-',
+						next: '->',
+						prevYear: '<--',
+						nextYear: '-->',
+						today: 'tidei',
+						month: 'mun',
+						week: 'wiki',
+						day: 'dei'
+					}
+				});
+
+				expect($('.fc-next-button')).toHaveText('->');
+				expect($('.fc-nextYear-button')).toHaveText('-->');
+				expect($('.fc-prev-button')).toHaveText('<-');
+				expect($('.fc-prevYear-button')).toHaveText('<--');
+
+				expect($('.fc-today-button')).toHaveText('tidei');
+				expect($('.fc-month-button')).toHaveText('mun');
+				expect($('.fc-agendaDay-button')).toHaveText('dei');
+				expect($('.fc-agendaWeek-button')).toHaveText('wiki');
+				expect($('.fc-basicDay-button')).toHaveText('dei');
+				expect($('.fc-basicWeek-button')).toHaveText('wiki');
+			});
+
+		});
+
+		describe('with buttonIcons turned off', function() {
+
+			pushOptions({
+				buttonIcons: false
+			});
+
+			it('should contain default text values', function() {
+				initCalendar();
+
+				// will have the locale's actual text now
+				expect($('.fc-next-button')).toHaveText('Suivant');
+				expect($('.fc-prev-button')).toHaveText('Précédent');
+				//// locales files don't have data for prev/next *year*
+				//expect($('.fc-nextYear-button')).toHaveText('Suivant');
+				//expect($('.fc-prevYear-button')).toHaveText('Précédent');
+
+				expect($('.fc-today-button')).toHaveText('Aujourd\'hui');
+				expect($('.fc-month-button')).toHaveText('Mois');
+				expect($('.fc-basicWeek-button')).toHaveText('Semaine');
+				expect($('.fc-agendaWeek-button')).toHaveText('Semaine');
+				expect($('.fc-basicDay-button')).toHaveText('Jour');
+				expect($('.fc-agendaDay-button')).toHaveText('Jour');
+			});
+
+			it('should contain specified text values', function() {
+				initCalendar({
+					buttonText: {
+						prev: '<-',
+						next: '->',
+						prevYear: '<--',
+						nextYear: '-->',
+						today: 'tidei',
+						month: 'mun',
+						week: 'wiki',
+						day: 'dei'
+					}
+				});
+
+				expect($('.fc-next-button')).toHaveText('->');
+				expect($('.fc-nextYear-button')).toHaveText('-->');
+				expect($('.fc-prev-button')).toHaveText('<-');
+				expect($('.fc-prevYear-button')).toHaveText('<--');
+
+				expect($('.fc-today-button')).toHaveText('tidei');
+				expect($('.fc-month-button')).toHaveText('mun');
+				expect($('.fc-agendaDay-button')).toHaveText('dei');
+				expect($('.fc-agendaWeek-button')).toHaveText('wiki');
+				expect($('.fc-basicDay-button')).toHaveText('dei');
+				expect($('.fc-basicWeek-button')).toHaveText('wiki');
+			});
+
+		});
+
+	});
 
 });

+ 23 - 27
tests/legacy/dayPopoverFormat.js

@@ -1,43 +1,39 @@
-
 describe('dayPopoverFormat', function() {
 
-	var options;
-
-	beforeEach(function() {
-		affix('#cal');
-		options = {
-			defaultDate: '2014-08-01',
-			eventLimit: 3,
-			events: [
-				{ title: 'event1', start: '2014-07-28', end: '2014-07-30', className: 'event1' },
-				{ title: 'event2', start: '2014-07-29', end: '2014-07-31', className: 'event2' },
-				{ title: 'event3', start: '2014-07-29', className: 'event3' },
-				{ title: 'event4', start: '2014-07-29', className: 'event4' }
-			]
-		};
+	pushOptions({
+		defaultDate: '2014-08-01',
+		eventLimit: 3,
+		events: [
+			{ title: 'event1', start: '2014-07-28', end: '2014-07-30', className: 'event1' },
+			{ title: 'event2', start: '2014-07-29', end: '2014-07-31', className: 'event2' },
+			{ title: 'event3', start: '2014-07-29', className: 'event3' },
+			{ title: 'event4', start: '2014-07-29', className: 'event4' }
+		]
 	});
 
-	function init() {
-		$('#cal').fullCalendar(options);
-		$('.fc-more').simulate('click');
-	}
-
 	it('can be set to a custom value', function() {
-		options.dayPopoverFormat = 'ddd, MMMM';
-		init();
+		initCalendar({
+			dayPopoverFormat: 'ddd, MMMM'
+		});
+		$('.fc-more').simulate('click');
 		expect($('.fc-more-popover > .fc-header .fc-title')).toHaveText('Tue, July');
 	});
 
 	it('is affected by the current locale when the value is default', function() {
-		options.locale = 'fr';
-		init();
+		initCalendar({
+			locale: 'fr'
+		});
+		$('.fc-more').simulate('click');
 		expect($('.fc-more-popover > .fc-header .fc-title')).toHaveText('29 juillet 2014');
 	});
 
 	it('still maintains the same format when explicitly set, and there is a locale', function() {
-		options.locale = 'fr';
-		options.dayPopoverFormat = 'YYYY';
-		init();
+		initCalendar({
+			locale: 'fr',
+			dayPopoverFormat: 'YYYY',
+		});
+		$('.fc-more').simulate('click');
 		expect($('.fc-more-popover > .fc-header .fc-title')).toHaveText('2014');
 	});
+
 });

+ 151 - 112
tests/legacy/event-coloring.js

@@ -2,205 +2,244 @@ import { RED_REGEX } from '../lib/dom-utils';
 
 describe('event coloring', function() {
 
-	var eventInput;
-	var options;
-
-	beforeEach(function() {
-		eventInput = {};
-		options = {
-			defaultDate: '2014-11-04'
-		};
-		affix('#cal');
+	pushOptions({
+		defaultDate: '2014-11-04'
 	});
 
 	describe('when in month view', function() {
-		beforeEach(function() {
-			options.defaultView = 'month';
-			eventInput = { start: '2014-11-04' };
+
+		pushOptions({
+			defaultView: 'month'
 		});
-		defineTests();
+
+		defineViewTests(false);
 	});
 
 	describe('when in agendaWeek view', function() {
-		beforeEach(function() {
-			options.defaultView = 'agendaWeek';
-			options.allDaySlot = false;
-			eventInput = { start: '2014-11-04T01:00:00' };
+
+		pushOptions({
+			defaultView: 'agendaWeek',
+			allDaySlot: false
 		});
-		defineTests();
-	});
 
+		defineViewTests(true);
+	});
 
-	function defineTests() {
+	function defineViewTests(eventHasTime) {
 
 		describe('for foreground events', function() {
-			testTextColor();
-			testBorderColor();
-			testBackgroundColor();
+			testTextColor(eventHasTime);
+			testBorderColor(eventHasTime);
+			testBackgroundColor(eventHasTime);
 		});
 
 		describe('for background events', function() {
-			beforeEach(function() {
-				eventInput.rendering = 'background';
-			});
-
-			testBackgroundColor();
+			testBackgroundColor(eventHasTime, 'background');
 		});
+
 	}
 
+	function testTextColor(eventHasTime) {
 
-	function testTextColor() {
+		var eventOptions = getEventOptions(eventHasTime);
 
 		it('should accept the global eventTextColor', function() {
-			options.eventTextColor = 'red';
-			options.events = [ eventInput ];
-			$('#cal').fullCalendar(options);
+			initCalendar({
+				eventTextColor: 'red',
+				events: [ getTestEvent(eventOptions) ]
+			});
 			expect(getEventCss('color')).toMatch(RED_REGEX);
 		});
 
 		it('should accept an event source\'s textColor', function() {
-			options.eventTextColor = 'blue'; // even when there's a more general setting
-			options.eventSources = [ {
-				textColor: 'red',
-				events: [ eventInput ]
-			} ];
-			$('#cal').fullCalendar(options);
+			initCalendar({
+				eventTextColor: 'blue', // even when there's a more general setting
+				eventSources: [ {
+					textColor: 'red',
+					events: [ getTestEvent(eventOptions) ]
+				} ]
+			});
 			expect(getEventCss('color')).toMatch(RED_REGEX);
 		});
 
 		it('should accept an event object\'s textColor', function() {
-			eventInput.textColor = 'red';
-			options.eventSources = [ {
+			var eventInput = getTestEvent(eventOptions, {
+				textColor: 'red'
+			});
+			initCalendar({
 				textColor: 'blue', // even when there's a more general setting
 				events: [ eventInput ]
-			} ];
-			$('#cal').fullCalendar(options);
+			});
 			expect(getEventCss('color')).toMatch(RED_REGEX);
 		});
 	}
 
+	function testBorderColor(eventHasTime) {
 
-	function testBorderColor() {
+		var eventOptions = getEventOptions(eventHasTime);
 
 		it('should accept the global eventColor for border color', function() {
-			options.eventColor = 'red';
-			options.events = [ eventInput ];
-			$('#cal').fullCalendar(options);
+			initCalendar({
+				eventColor: 'red',
+				events: [ getTestEvent(eventOptions) ]
+			});
 			expect(getEventCss('border-top-color')).toMatch(RED_REGEX);
 		});
 
 		it('should accept the global eventBorderColor', function() {
-			options.eventColor = 'blue'; // even when there's a more general setting
-			options.eventBorderColor = 'red';
-			options.events = [ eventInput ];
-			$('#cal').fullCalendar(options);
+			initCalendar({
+				eventColor: 'blue',
+				eventBorderColor: 'red',
+				events: [ getTestEvent(eventOptions) ]
+			});
 			expect(getEventCss('border-top-color')).toMatch(RED_REGEX);
 		});
 
 		it('should accept an event source\'s color for the border', function() {
-			options.eventBorderColor = 'blue'; // even when there's a more general setting
-			options.eventSources = [ {
-				color: 'red',
-				events: [ eventInput ]
-			} ];
-			$('#cal').fullCalendar(options);
+			initCalendar({
+				eventBorderColor: 'blue', // even when there's a more general setting
+				eventSources: [ {
+					color: 'red',
+					events: [ getTestEvent(eventOptions) ]
+				} ]
+			});
 			expect(getEventCss('border-top-color')).toMatch(RED_REGEX);
 		});
 
 		it('should accept an event source\'s borderColor', function() {
-			options.eventSources = [ {
-				color: 'blue', // even when there's a more general setting
-				borderColor: 'red',
-				events: [ eventInput ]
-			} ];
-			$('#cal').fullCalendar(options);
+			initCalendar({
+				eventBorderColor: 'blue', // even when there's a more general setting
+				eventSources: [ {
+					color: 'blue',
+					borderColor: 'red',
+					events: [ getTestEvent(eventOptions) ]
+				} ]
+			});
 			expect(getEventCss('border-top-color')).toMatch(RED_REGEX);
 		});
 
 		it('should accept an event object\'s color for the border', function() {
-			eventInput.color = 'red';
-			options.eventSources = [ {
-				borderColor: 'blue', // even when there's a more general setting
-				events: [ eventInput ]
-			} ];
-			$('#cal').fullCalendar(options);
+			var eventInput = getTestEvent(eventOptions, {
+				color: 'red'
+			});
+			initCalendar({
+				eventSources: [ {
+					borderColor: 'blue', // even when there's a more general setting
+					events: [ eventInput ]
+				} ]
+			});
 			expect(getEventCss('border-top-color')).toMatch(RED_REGEX);
 		});
 
 		it('should accept an event object\'s borderColor', function() {
-			eventInput.color = 'blue'; // even when there's a more general setting
-			eventInput.borderColor = 'red';
-			options.eventSources = [ {
-				events: [ eventInput ]
-			} ];
-			$('#cal').fullCalendar(options);
+			var eventInput = getTestEvent(eventOptions, {
+				color: 'blue', // even when there's a more general setting
+				borderColor: 'red'
+			});
+			initCalendar({
+				eventSources: [ {
+					events: [ eventInput ]
+				} ]
+			});
 			expect(getEventCss('border-top-color')).toMatch(RED_REGEX);
 		});
 	}
 
 
-	function testBackgroundColor() {
+	function testBackgroundColor(eventHasTime, rendering) {
+
+		var eventOptions = getEventOptions(eventHasTime);
+
+		if (typeof rendering !== 'undefined') {
+			eventOptions.rendering = rendering;
+		}
 
 		it('should accept the global eventColor for background color', function() {
-			options.eventColor = 'red';
-			options.events = [ eventInput ];
-			$('#cal').fullCalendar(options);
-			expect(getEventCss('background-color')).toMatch(RED_REGEX);
+			initCalendar({
+				eventColor: 'red',
+				events: [ getTestEvent(eventOptions) ]
+			});
+			expect(getEventCss('background-color', rendering)).toMatch(RED_REGEX);
 		});
 
 		it('should accept the global eventBackgroundColor', function() {
-			options.eventColor = 'blue'; // even when there's a more general setting
-			options.eventBackgroundColor = 'red';
-			options.events = [ eventInput ];
-			$('#cal').fullCalendar(options);
-			expect(getEventCss('background-color')).toMatch(RED_REGEX);
+			initCalendar({
+				eventColor: 'blue', // even when there's a more general setting
+				eventBackgroundColor: 'red',
+				events: [ getTestEvent(eventOptions) ],
+			});
+			expect(getEventCss('background-color', rendering)).toMatch(RED_REGEX);
 		});
 
 		it('should accept an event source\'s color for the background', function() {
-			options.eventBackgroundColor = 'blue'; // even when there's a more general setting
-			options.eventSources = [ {
-				color: 'red',
-				events: [ eventInput ]
-			} ];
-			$('#cal').fullCalendar(options);
-			expect(getEventCss('background-color')).toMatch(RED_REGEX);
+			initCalendar({
+				eventBackgroundColor: 'blue', // even when there's a more general setting
+				eventSources: [ {
+					color: 'red',
+					events: [ getTestEvent(eventOptions) ]
+				} ]
+			});
+			expect(getEventCss('background-color', rendering)).toMatch(RED_REGEX);
 		});
 
 		it('should accept an event source\'s backgroundColor', function() {
-			options.eventSources = [ {
-				color: 'blue', // even when there's a more general setting
-				backgroundColor: 'red',
-				events: [ eventInput ]
-			} ];
-			$('#cal').fullCalendar(options);
-			expect(getEventCss('background-color')).toMatch(RED_REGEX);
+			initCalendar({
+				eventSources: [ {
+					color: 'blue', // even when there's a more general setting
+					backgroundColor: 'red',
+					events: [ getTestEvent(eventOptions) ]
+				} ]
+			});
+			expect(getEventCss('background-color', rendering)).toMatch(RED_REGEX);
 		});
 
 		it('should accept an event object\'s color for the background', function() {
+			var eventInput = getTestEvent(eventOptions);
 			eventInput.color = 'red';
-			options.eventSources = [ {
-				backgroundColor: 'blue', // even when there's a more general setting
-				events: [ eventInput ]
-			} ];
-			$('#cal').fullCalendar(options);
-			expect(getEventCss('background-color')).toMatch(RED_REGEX);
+			initCalendar({
+				eventSources: [ {
+					backgroundColor: 'blue', // even when there's a more general setting
+					events: [ eventInput ]
+				} ]
+			});
+			expect(getEventCss('background-color', rendering)).toMatch(RED_REGEX);
 		});
 
 		it('should accept an event object\'s backgroundColor', function() {
+			var eventInput = getTestEvent(eventOptions);
 			eventInput.color = 'blue'; // even when there's a more general setting
 			eventInput.backgroundColor = 'red';
-			options.eventSources = [ {
-				events: [ eventInput ]
-			} ];
-			$('#cal').fullCalendar(options);
-			expect(getEventCss('background-color')).toMatch(RED_REGEX);
+			initCalendar({
+				eventSources: [ {
+					events: [ eventInput ]
+				} ]
+			});
+			expect(getEventCss('background-color', rendering)).toMatch(RED_REGEX);
 		});
 	}
 
-
-	function getEventCss(prop) {
-		var el = $(eventInput.rendering == 'background' ? '.fc-bgevent' : '.fc-event');
+	function getEventCss(prop, rendering) {
+		var el = $(rendering === 'background' ? '.fc-bgevent' : '.fc-event');
 		return el.css(prop);
 	}
 
+	function getTestEvent(defaultOptions, extraOptions) {
+		var event = {};
+		$.extend( event, defaultOptions );
+		if (extraOptions) {
+			$.extend( event, extraOptions );
+		}
+		return event;
+	}
+
+	function getEventOptions(eventHasTime) {
+		var options = {
+			start: '2014-11-04'
+		};
+		if (eventHasTime) {
+			options.start += 'T01:00:00';
+		}
+		return options;
+	};
+
 });

+ 17 - 20
tests/legacy/eventDestroy.js

@@ -1,34 +1,31 @@
-
 describe('eventDestroy', function() {
-	var options;
 
-	beforeEach(function() {
-		affix('#cal');
-		options = {
-			defaultDate: '2014-08-01'
-		};
+	pushOptions({
+		defaultDate: '2014-08-01'
 	});
 
 	function testSingleEvent(singleEventData, done) {
 		var callCnt = 0;
 
 		expect(singleEventData.id).toBeTruthy();
-		options.events = [ singleEventData ];
-		options.eventDestroy = function(event, element) {
-			if (callCnt++ === 0) { // only care about the first call. gets called again when calendar is destroyed
-				expect(event.id).toBe(singleEventData.id);
-				done();
+
+		initCalendar({
+			events: [ singleEventData ],
+			eventDestroy: function(event, element) {
+				if (callCnt++ === 0) { // only care about the first call. gets called again when calendar is destroyed
+					expect(event.id).toBe(singleEventData.id);
+					done();
+				}
 			}
-		};
+		});
 
-		$('#cal').fullCalendar(options);
-		$('#cal').fullCalendar('removeEvents', singleEventData.id);
+		currentCalendar.removeEvents(singleEventData.id);
 	}
 
 	describe('when in month view', function() { // for issue 2017
 
-		beforeEach(function() {
-			options.defaultView = 'month';
+		pushOptions({
+			defaultView: 'month'
 		});
 
 		it('gets called with removeEvents method', function(done) {
@@ -42,9 +39,9 @@ describe('eventDestroy', function() {
 
 	describe('when in agendaWeek view', function() { // for issue 2017
 
-		beforeEach(function() {
-			options.defaultView = 'agendaWeek';
-			options.scrollTime = '00:00:00';
+		pushOptions({
+			defaultView: 'agendaWeek',
+			scrollTime: '00:00:00'
 		});
 
 		it('gets called with removeEvents method', function(done) {

+ 27 - 25
tests/legacy/eventMouseover.js

@@ -1,39 +1,41 @@
 describe('eventMouseover', function() {
-	var options;
-
-	beforeEach(function() {
-		affix('#cal');
-		options = {
-			defaultDate: '2014-08-01',
-			scrollTime: '00:00:00'
-		};
+
+	pushOptions({
+		defaultDate: '2014-08-01',
+		scrollTime: '00:00:00'
 	});
 
 	[ 'month', 'agendaWeek' ].forEach(function(viewName) {
 		describe('for ' + viewName + ' view', function() {
-			beforeEach(function() {
-				options.defaultView = viewName;
+
+			pushOptions({
+				defaultView: viewName
 			});
+
 			it('will trigger a eventMouseout with updateEvent', function(done) {
-				options.events = [ {
-					title: 'event',
-					start: '2014-08-02T01:00:00',
-					className: 'event'
-				} ];
-				options.eventMouseover = function(event, ev) {
-					expect(typeof event).toBe('object');
-					expect(typeof ev).toBe('object');
-					event.title = 'YO';
-					$('#cal').fullCalendar('updateEvent', event);
-				};
-				options.eventMouseout = function(event, ev) {
+
+				var eventMouseoutSpy = spyOnCalendarCallback('eventMouseout', function(event, ev) {
 					expect(typeof event).toBe('object');
 					expect(typeof ev).toBe('object');
 					done();
-				};
-				spyOn(options, 'eventMouseout').and.callThrough();
-				$('#cal').fullCalendar(options);
+				});
+
+				initCalendar({
+					events: [ {
+						title: 'event',
+						start: '2014-08-02T01:00:00',
+						className: 'event'
+					} ],
+					eventMouseover: function(event, ev) {
+						expect(typeof event).toBe('object');
+						expect(typeof ev).toBe('object');
+						event.title = 'YO';
+						currentCalendar.updateEvent(event);
+					}
+				});
+
 				$('.event').simulate('mouseover');
+
 			});
 		});
 	});

+ 35 - 35
tests/legacy/events-array.js

@@ -1,57 +1,57 @@
-
 describe('events as an array', function() {
 
-	var options;
-	var eventArray;
+	pushOptions({
+		defaultView: 'month',
+		defaultDate: '2014-05-01'
+	});
 
-	beforeEach(function() {
-		affix('#cal');
-		options = {
-			defaultView: 'month',
-			defaultDate: '2014-05-01'
-		};
-		eventArray = [
+	function getEventArray() {
+		return [
 			{
 				title: 'my event',
 				start: '2014-05-21'
 			}
 		];
-	});
+	}
 
 	it('accepts an event using basic form', function(done) {
-		options.events = eventArray;
-		options.eventRender = function(eventObj, eventElm) {
-			expect(eventObj.title).toEqual('my event');
-			done();
-		};
-		$('#cal').fullCalendar(options);
+		initCalendar({
+			events: getEventArray(),
+			eventRender: function(eventObj, eventElm) {
+				expect(eventObj.title).toEqual('my event');
+				done();
+			}
+		});
 	});
 
 	it('accepts an event using extended form', function(done) {
-		options.eventSources = [
-			{
-				className: 'customeventclass',
-				events: eventArray
+		initCalendar({
+			eventSources: [
+				{
+					className: 'customeventclass',
+					events: getEventArray()
+				}
+			],
+			eventRender: function(eventObj, eventElm) {
+				expect(eventObj.title).toEqual('my event');
+				expect(eventElm).toHaveClass('customeventclass');
+				done();
 			}
-		];
-		options.eventRender = function(eventObj, eventElm) {
-			expect(eventObj.title).toEqual('my event');
-			expect(eventElm).toHaveClass('customeventclass');
-			done();
-		};
-		$('#cal').fullCalendar(options);
+		});
 	});
 
 	it('doesn\'t mutate the original array', function(done) {
+		var eventArray = getEventArray();
 		var origArray = eventArray;
 		var origEvent = eventArray[0];
-		options.events = eventArray;
-		options.eventRender = function(eventObj, eventElm) {
-			expect(origArray).toEqual(eventArray);
-			expect(origEvent).toEqual(eventArray[0]);
-			done();
-		};
-		$('#cal').fullCalendar(options);
+		initCalendar({
+			events: eventArray,
+			eventRender: function(eventObj, eventElm) {
+				expect(origArray).toEqual(eventArray);
+				expect(origEvent).toEqual(eventArray[0]);
+				done();
+			}
+		});
 	});
 
 });

+ 24 - 19
tests/legacy/fixedWeekCount.js

@@ -1,48 +1,53 @@
-
 describe('fixedWeekCount', function() {
-	var options;
-
-	beforeEach(function() {
-		affix('#cal');
-		options = {
-			defaultView: 'month',
-			defaultDate: '2014-07-01' // has 5 weeks
-		};
+
+	pushOptions({
+		defaultView: 'month',
+		defaultDate: '2014-07-01' // has 5 weeks
 	});
 
 	describe('when true', function() {
-		beforeEach(function() {
-			options.fixedWeekCount = true;
+
+		pushOptions({
+			fixedWeekCount: true
 		});
+
 		it('renders a 5-week month with 6 rows', function() {
-			$('#cal').fullCalendar(options);
+			initCalendar();
 			var weeks = $('.fc-week');
 			expect(weeks.length).toBe(6);
 		});
+
 	});
 
 	describe('when false', function() {
-		beforeEach(function() {
-			options.fixedWeekCount = false;
+
+		pushOptions({
+			fixedWeekCount: false
 		});
+
 		it('renders a 5-week month with 5 rows', function() {
-			$('#cal').fullCalendar(options);
+			initCalendar();
 			var weeks = $('.fc-week');
 			expect(weeks.length).toBe(5);
 		});
+
 	});
 
 	[ true, false ].forEach(function(bool) {
 		describe('regardless of value (' + bool + ')', function() {
-			beforeEach(function() {
-				options.fixedWeekCount = bool;
-				options.defaultDate = '2014-08-01'; // has 6 weeks
+
+			pushOptions({
+				fixedWeekCount: bool,
+				defaultDate: '2014-08-01' // has 6 weeks
 			});
+
 			it('should render a 6-week month consistently', function() {
-				$('#cal').fullCalendar(options);
+				initCalendar();
 				var weeks = $('.fc-week');
 				expect(weeks.length).toBe(6);
 			});
+
 		});
 	});
+
 });

+ 12 - 19
tests/legacy/footer-rendering.js

@@ -1,50 +1,43 @@
-
 describe('footer rendering', function() {
 
-	beforeEach(function() {
-		affix('#calendar');
+	pushOptions({
+		defaultDate: '2014-06-04',
+		defaultView: 'agendaWeek'
 	});
 
 	describe('when supplying footer options', function() {
-		beforeEach(function() {
-			var options = {
+		it('should append a .fc-footer-toolbar to the DOM', function() {
+			initCalendar({
 				footer: {
 					left: 'next,prev',
 					center: 'prevYear today nextYear agendaView,dayView',
 					right: 'title'
 				}
-			};
-			$('#calendar').fullCalendar(options);
-		});
-		it('should append a .fc-footer-toolbar to the DOM', function() {
+			});
 			var footer = $('#calendar .fc-footer-toolbar');
 			expect(footer.length).toBe(1);
 		});
 	});
 
 	describe('when setting footer to false', function() {
-		beforeEach(function() {
-			var options = {
-				footer: false
-			};
-			$('#calendar').fullCalendar(options);
-		});
 		it('should not have footer table', function() {
+			initCalendar({
+				footer: false
+			});
 			expect($('.fc-footer-toolbar')).not.toBeInDOM();
 		});
 	});
 
 	it('allow for dynamically changing', function() {
-		var options = {
+		initCalendar({
 			footer: {
 				left: 'next,prev',
 				center: 'prevYear today nextYear agendaView,dayView',
 				right: 'title'
 			}
-		};
-		$('#calendar').fullCalendar(options);
+		});
 		expect($('.fc-footer-toolbar')).toBeInDOM();
-		$('#calendar').fullCalendar('option', 'footer', false);
+		currentCalendar.option('footer', false);
 		expect($('.fc-footer-toolbar')).not.toBeInDOM();
 	});
 

+ 27 - 35
tests/legacy/getEventSourceById.js

@@ -1,48 +1,40 @@
 describe('getEventSource', function() {
-	var options;
-	var calendarEl;
 
-	beforeEach(function() {
-		affix('#cal');
-		calendarEl = $('#cal');
-		options = {
-			now: '2015-08-07',
-			defaultView: 'agendaWeek',
-			eventSources: [
-				{
-					events: [
-						{ id: 1, start: '2015-08-07T02:00:00', end: '2015-08-07T03:00:00', title: 'event A' }
-					],
-					id: 'source1'
-				},
-				{
-					events: [
-						{ id: 2, start: '2015-08-07T03:00:00', end: '2015-08-07T04:00:00', title: 'event B' }
-					],
-					id: 'source2'
-				},
-				{
-					events: [
-						{ id: 3, start: '2015-08-07T04:00:00', end: '2015-08-07T05:00:00', title: 'event C' }
-					],
-					id: 'source3'
-				}
-			]
-		};
+	pushOptions({
+		now: '2015-08-07',
+		defaultView: 'agendaWeek',
+		eventSources: [
+			{
+				events: [
+					{ id: 1, start: '2015-08-07T02:00:00', end: '2015-08-07T03:00:00', title: 'event A' }
+				],
+				id: 'source1'
+			},
+			{
+				events: [
+					{ id: 2, start: '2015-08-07T03:00:00', end: '2015-08-07T04:00:00', title: 'event B' }
+				],
+				id: 'source2'
+			},
+			{
+				events: [
+					{ id: 3, start: '2015-08-07T04:00:00', end: '2015-08-07T05:00:00', title: 'event C' }
+				],
+				id: 'source3'
+			}
+		]
 	});
 
 	it('retreives the queried event source', function(done) {
-		var eventSource1;
-		var eventSource2;
+		initCalendar();
 
-		calendarEl.fullCalendar(options);
-
-		eventSource1 = calendarEl.fullCalendar('getEventSourceById', 'source1');
-		eventSource2 = calendarEl.fullCalendar('getEventSourceById', 'source2');
+		var eventSource1 = currentCalendar.getEventSourceById('source1');
+		var eventSource2 = currentCalendar.getEventSourceById('source2');
 
 		expect(eventSource1.id).toBe('source1');
 		expect(eventSource2.id).toBe('source2');
 
 		done();
 	});
+
 });

+ 25 - 32
tests/legacy/getEventSources.js

@@ -1,45 +1,38 @@
 describe('getEventSources', function() {
-	var options;
-	var calendarEl;
 
-	beforeEach(function() {
-		affix('#cal');
-		calendarEl = $('#cal');
-		options = {
-			now: '2015-08-07',
-			defaultView: 'agendaWeek',
-			eventSources: [
-				{
-					events: [
-						{ id: 1, start: '2015-08-07T02:00:00', end: '2015-08-07T03:00:00', title: 'event A' }
-					]
-				},
-				{
-					events: [
-						{ id: 2, start: '2015-08-07T03:00:00', end: '2015-08-07T04:00:00', title: 'event B' }
-					]
-				},
-				{
-					events: [
-						{ id: 3, start: '2015-08-07T04:00:00', end: '2015-08-07T05:00:00', title: 'event C' }
-					]
-				}
-			]
-		};
+	pushOptions({
+		now: '2015-08-07',
+		defaultView: 'agendaWeek',
+		eventSources: [
+			{
+				events: [
+					{ id: 1, start: '2015-08-07T02:00:00', end: '2015-08-07T03:00:00', title: 'event A' }
+				]
+			},
+			{
+				events: [
+					{ id: 2, start: '2015-08-07T03:00:00', end: '2015-08-07T04:00:00', title: 'event B' }
+				]
+			},
+			{
+				events: [
+					{ id: 3, start: '2015-08-07T04:00:00', end: '2015-08-07T05:00:00', title: 'event C' }
+				]
+			}
+		]
 	});
 
 	it('does not mutate when removeEventSource is called', function(done) {
-		var eventSources;
-
-		calendarEl.fullCalendar(options);
-
-		eventSources = calendarEl.fullCalendar('getEventSources');
+		initCalendar();
+		var eventSources = currentCalendar.getEventSources();
 		expect(eventSources.length).toBe(3);
 
 		// prove that eventSources is a copy, and wasn't mutated
-		calendarEl.fullCalendar('removeEventSource', eventSources[0]);
+		currentCalendar.removeEventSource(eventSources[0]);
 		expect(eventSources.length).toBe(3);
 
 		done();
 	});
+
 });
+

+ 1 - 5
tests/legacy/handleWindowResize.js

@@ -1,16 +1,12 @@
 
 describe('handleWindowResize', function() {
 
-	beforeEach(function() {
-		affix('#cal');
-	});
-
 	// not true
 	/*
 	xdescribe('When default is used, should fire resize event', function() {
 		it('should fire resize', function() {
 			var resized = 0;
-			$('#cal').fullCalendar({
+			initCalendar({
 				windowResize: function(view) {
 					resized++;
 				}

+ 11 - 11
tests/legacy/isRTL.js

@@ -1,28 +1,28 @@
 describe('isRTL', function() {
 
 	it('has it\'s default value computed differently based off of the locale', function() {
-		affix('#cal');
-		$('#cal').fullCalendar({
+		initCalendar({
 			locale: 'ar' // Arabic is RTL
 		});
-		var isRTL = $('#cal').fullCalendar('option', 'isRTL');
-		expect(isRTL).toEqual(true);
+		expect(currentCalendar.option('isRTL')).toEqual(true);
 	});
 
 	// NOTE: don't put tests related to other options in here!
 	// Put them in the test file for the individual option!
 
 	it('adapts to dynamic option change', function() {
-		affix('#cal');
-		$('#cal').fullCalendar({
+		initCalendar({
 			isRTL: false
 		});
-		expect($('#cal')).toHaveClass('fc-ltr');
-		expect($('#cal')).not.toHaveClass('fc-rtl');
+		var $el = $(currentCalendar.el);
 
-		$('#cal').fullCalendar('option', 'isRTL', true);
-		expect($('#cal')).toHaveClass('fc-rtl');
-		expect($('#cal')).not.toHaveClass('fc-ltr');
+		expect($el).toHaveClass('fc-ltr');
+		expect($el).not.toHaveClass('fc-rtl');
+
+		currentCalendar.option('isRTL', true);
+
+		expect($el).toHaveClass('fc-rtl');
+		expect($el).not.toHaveClass('fc-ltr');
 	});
 
 });

+ 13 - 17
tests/legacy/removeEventSources.js

@@ -1,26 +1,22 @@
 describe('removeEventSources', function() {
-	var options;
-
-	beforeEach(function() {
-		affix('#cal');
-		options = {
-			defaultDate: '2014-08-01',
-			defaultView: 'agendaDay',
-			eventSources: [
-				buildEventSource(1),
-				buildEventSource(2),
-				buildEventSource(3)
-			]
-		};
+
+	pushOptions({
+		defaultDate: '2014-08-01',
+		defaultView: 'agendaDay',
+		eventSources: [
+			buildEventSource(1),
+			buildEventSource(2),
+			buildEventSource(3)
+		]
 	});
 
 	describe('when called with no arguments', function() {
 		it('removes all sources', function() {
 
-			$('#cal').fullCalendar(options);
+			initCalendar();
 			expect($('.fc-event').length).toBe(3);
 
-			$('#cal').fullCalendar('removeEventSources');
+			currentCalendar.removeEventSources();
 			expect($('.fc-event').length).toBe(0);
 		});
 	});
@@ -28,10 +24,10 @@ describe('removeEventSources', function() {
 	describe('when called with specific IDs', function() {
 		it('removes only events with matching sources', function() {
 
-			$('#cal').fullCalendar(options);
+			initCalendar();
 			expect($('.fc-event').length).toBe(3);
 
-			$('#cal').fullCalendar('removeEventSources', [ 1, 3 ]);
+			currentCalendar.removeEventSources([ 1, 3 ]);
 			expect($('.fc-event').length).toBe(1);
 			expect($('.event2').length).toBe(1);
 		});

+ 10 - 13
tests/legacy/scrollTime.js

@@ -1,18 +1,14 @@
 describe('scrollTime', function() {
 
-	var options;
-
-	beforeEach(function() {
-		affix('#cal');
-		options = {
-			defaultView: 'agendaWeek'
-		};
+	pushOptions({
+		defaultView: 'agendaWeek'
 	});
 
 	it('accepts a string Duration', function() {
-		options.scrollTime = '02:00:00';
-		options.height = 400; // short enough to make scrolling happen
-		$('#cal').fullCalendar(options);
+		initCalendar({
+			scrollTime: '02:00:00',
+			height: 400 // short enough to make scrolling happen
+		});
 		var slotCell = $('.fc-slats tr:eq(4)'); // 2am slot
 		var slotTop = slotCell.position().top;
 		var scrollContainer = $('.fc-time-grid-container');
@@ -24,9 +20,10 @@ describe('scrollTime', function() {
 	});
 
 	it('accepts a Duration object', function() {
-		options.scrollTime = { hours: 2 };
-		options.height = 400; // short enough to make scrolling happen
-		$('#cal').fullCalendar(options);
+		initCalendar({
+			scrollTime: { hours: 2 },
+			height: 400 // short enough to make scrolling happen
+		});
 		var slotCell = $('.fc-slats tr:eq(4)'); // 2am slot
 		var slotTop = slotCell.position().top;
 		var scrollContainer = $('.fc-time-grid-container');

+ 12 - 14
tests/legacy/slotLabelFormat.js

@@ -1,33 +1,31 @@
 describe('slotLabelFormat', function() {
 
-	var options;
+	pushOptions({
+		defaultDate: '2014-06-04',
+		defaultView: 'agendaWeek'
+	});
 
 	function getAxisText() {
 		return $('.fc-slats tr:first-child .fc-time').text();
 	}
 
-	beforeEach(function() {
-		affix('#cal');
-		options = {
-			defaultDate: '2014-06-04',
-			defaultView: 'agendaWeek'
-		};
-	});
-
 	it('renders correctly when default', function() {
-		$('#cal').fullCalendar(options);
+		initCalendar();
 		expect(getAxisText()).toBe('12am');
 	});
 
 	it('renders correctly when default and the locale is customized', function() {
-		options.locale = 'en-gb';
-		$('#cal').fullCalendar(options);
+		initCalendar({
+			locale: 'en-gb'
+		});
 		expect(getAxisText()).toBe('00');
 	});
 
 	it('renders correctly when customized', function() {
-		options.slotLabelFormat = 'H:mm:mm[!]';
-		$('#cal').fullCalendar(options);
+		initCalendar({
+			slotLabelFormat: 'H:mm:mm[!]'
+		});
 		expect(getAxisText()).toBe('0:00:00!');
 	});
+
 });

+ 16 - 24
tests/legacy/viewRender.js

@@ -1,28 +1,19 @@
-
 describe('viewRender', function() {
-	var options;
 
-	beforeEach(function() {
-		options = {
-			defaultDate: '2015-02-20'
-		};
-		affix('#cal');
+	pushOptions({
+		defaultDate: '2015-02-20'
 	});
 
 	describe('when in month view', function() {
-		beforeEach(function() {
-			options = {
-				defaultView: 'month'
-			};
+		pushOptions({
+			defaultView: 'month'
 		});
 		defineTests();
 	});
 
 	describe('when in agendaWeek view', function() {
-		beforeEach(function() {
-			options = {
-				defaultView: 'agendaWeek'
-			};
+		pushOptions({
+			defaultView: 'agendaWeek'
 		});
 		defineTests();
 	});
@@ -30,16 +21,17 @@ describe('viewRender', function() {
 	function defineTests() {
 
 		it('fires after the view is rendered, with correct arguments', function(done) {
-			options.viewRender = function(givenViewObj, givenViewEl) {
-				var viewObj = $('#cal').fullCalendar('getView');
-				var viewEl = $('#cal .fc-view');
+			initCalendar({
+				viewRender: function(givenViewObj, givenViewEl) {
+					var viewObj = currentCalendar.getView();
+					var viewEl = $('.fc-view', currentCalendar.el);
 
-				expect(viewObj).toBe(givenViewObj);
-				expect(viewEl[0]).toBe(givenViewEl[0]);
-				expect(viewEl.children().length >= 1).toBe(true); // has it rendered content?
-				done();
-			};
-			$('#cal').fullCalendar(options);
+					expect(viewObj).toBe(givenViewObj);
+					expect(viewEl[0]).toBe(givenViewEl[0]);
+					expect(viewEl.children().length >= 1).toBe(true); // has it rendered content?
+					done();
+				}
+			});
 		});
 	}
 });

+ 7 - 11
tests/legacy/weekViewRender.js

@@ -1,23 +1,19 @@
 describe('weekViewRender', function() {
 
-	beforeEach(function() {
-		affix('#cal');
+	var nowStr = $.fullCalendar.moment(new Date()).format('YYYY-MM-DD');
+
+	pushOptions({
+		defaultDate: nowStr,
+		defaultView: 'agendaWeek'
 	});
 
 	describe('verify th class for today', function() {
-		var nowStr = $.fullCalendar.moment(new Date()).format('YYYY-MM-DD');
-
-		beforeEach(function() {
-			$('#cal').fullCalendar({
-				defaultDate: nowStr,
-				defaultView: 'agendaWeek'
-			});
-		});
 
 		it('should have fc-today class only on "today"', function() {
+			initCalendar();
 			var foundToday = false;
 
-			$('#cal th.fc-day-header').each(function(i, headerNode) {
+			$('th.fc-day-header', currentCalendar.el).each(function(i, headerNode) {
 				var headerEl = $(headerNode);
 				var dateMatchesToday = headerEl.data('date') === nowStr;
 				var hasTodayClass = headerEl.hasClass('fc-today');

+ 4 - 10
tests/legacy/weekends.js

@@ -1,15 +1,10 @@
 
 describe('when weekends option is set', function() {
 
-	beforeEach(function() {
-		affix('#calendar');
-	});
-
 	it('should show sat and sun if true', function() {
-		var options = {
+		initCalendar({
 			weekends: true
-		};
-		$('#calendar').fullCalendar(options);
+		});
 		var sun = $('.fc-day-header.fc-sun')[0];
 		var sat = $('.fc-day-header.fc-sun')[0];
 		expect(sun).toBeDefined();
@@ -17,10 +12,9 @@ describe('when weekends option is set', function() {
 	});
 
 	it('should not show sat and sun if false', function() {
-		var options = {
+		initCalendar({
 			weekends: false
-		};
-		$('#calendar').fullCalendar(options);
+		});
 		var sun = $('.fc-day-header.fc-sun')[0];
 		var sat = $('.fc-day-header.fc-sun')[0];
 		expect(sun).not.toBeDefined();