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

Merge remote-tracking branch 'acerix/jquery-removal' into jquery-removal

Adam Shaw 7 лет назад
Родитель
Сommit
9b8aa0d8e0

+ 17 - 23
tests/automated/legacy/dayNames.js

@@ -1,5 +1,4 @@
 describe('day names', function() {
-  var settings = {}
   var testableClasses = [
     'basicDay',
     'agendaDay'
@@ -16,11 +15,8 @@ describe('day names', function() {
   var referenceDate = '2014-05-25 06:00' // A sunday
   var locales = [ 'es', 'fr', 'de', 'zh-cn', 'nl' ]
 
-  beforeEach(function() {
-    affix('#cal')
-    settings = {
-      now: moment(referenceDate).toISOString()
-    }
+  pushOptions({
+    now: moment(referenceDate).toISOString()
   })
 
   afterEach(function() {
@@ -29,21 +25,19 @@ describe('day names', function() {
 
   testableClasses.forEach(function(viewClass, index, viewClasses) {
     describe('when view is basicDay', function() {
-      beforeEach(function() {
-        settings.defaultView = 'basicDay'
+      pushOptions({
+        defaultView: 'basicDay'
       })
-
       describe('when locale is default', function() {
-        beforeEach(function() {
-          settings.locale = 'en'
+        pushOptions({
+          locale: 'en'
         })
-
         dayClasses.forEach(function(cls, index, classes) {
           var weekdays = moment.weekdays()
           it('should be ' + weekdays[index], function() {
-            settings.now = moment(referenceDate).add(index, 'days')
-            $('#cal').fullCalendar(settings)
-
+            initCalendar({
+              now: moment(referenceDate).add(index, 'days')
+            })
             expect($('.fc-view thead ' + dayClasses[index])).toHaveText(weekdays[index])
           })
         })
@@ -57,9 +51,10 @@ describe('day names', function() {
 
           dayClasses.forEach(function(cls, index, classes) {
             it('should be the translation for ' + moment.weekdays()[index], function() {
-              settings.locale = locale
-              settings.now = moment(referenceDate).add(index, 'days')
-              $('#cal').fullCalendar(settings)
+              initCalendar({
+                locale: locale,
+                now: moment(referenceDate).add(index, 'days')
+              })
 
               expect($('.fc-view thead ' + dayClasses[index])).toHaveText(moment.weekdays()[index])
             })
@@ -80,11 +75,10 @@ describe('day names', function() {
 
         dayClasses.forEach(function(cls, idx, classes) {
           it('should be ' + weekdays[idx], function() {
-            settings.dayNames = [].slice.call(weekdays) // copy. in case there is a mutation
-            settings.now = moment(referenceDate).add(idx, 'days')
-
-            $('#cal').fullCalendar(settings)
-
+            initCalendar({
+              dayNames: [].slice.call(weekdays), // copy. in case there is a mutation
+              now: moment(referenceDate).add(idx, 'days')
+            })
             expect($('.fc-view thead ' + cls)).toHaveText(weekdays[idx])
           })
         })

+ 10 - 15
tests/automated/legacy/dayNamesShort.js

@@ -1,5 +1,4 @@
 describe('short day names', function() {
-  var settings = {}
   var testableClasses = [
     'month',
     'agendaWeek',
@@ -16,27 +15,21 @@ describe('short day names', function() {
   ]
   var locales = [ 'es', 'fr', 'de', 'zh-cn', 'es' ]
 
-  beforeEach(function() {
-    affix('#cal')
-    settings = { }
-  })
-
   afterEach(function() {
     moment.locale('en') // reset moment's global locale
   })
 
   testableClasses.forEach(function(viewClass, index, viewClasses) {
     describe('when view is ' + viewClass, function() {
-      beforeEach(function() {
-        settings.defaultView = viewClass
+      pushOptions({
+        defaultView: viewClass
       })
-
       describe('when locale is default', function() {
         it('should be in English', function() {
           moment.locale('en')
-          $('#cal').fullCalendar(settings)
-          var weekdays = moment.weekdaysShort()
+          initCalendar()
 
+          var weekdays = moment.weekdaysShort()
           dayClasses.forEach(function(cls, index, classes) {
             expect($('.fc-view thead ' + cls)[0]).toContainText(weekdays[index])
           })
@@ -46,8 +39,9 @@ describe('short day names', function() {
       describe('when locale is not default', function() {
         locales.forEach(function(locale, index, locales) {
           it('should be in the selected locale', function() {
-            settings.locale = locale
-            $('#cal').fullCalendar(settings)
+            initCalendar({
+              locale: locale
+            })
 
             moment.locale(locale)
             var weekdays = moment.weekdaysShort()
@@ -64,8 +58,9 @@ describe('short day names', function() {
           var days = [
             'Hov.', 'maS.', 'veS.', 'mech.', 'parmaq.', 'HoS.'
           ]
-          settings.dayNamesShort = days
-          $('#cal').fullCalendar(settings)
+          initCalendar({
+            dayNamesShort: days
+          })
 
           dayClasses.forEach(function(cls, index, classes) {
             expect($('.fc-view thead ' + cls)[0]).toContainText(days[index])

+ 8 - 9
tests/automated/legacy/event-dnd.js

@@ -8,11 +8,10 @@ describe('eventDrop', function() {
       dragScroll: false,
       longPressDelay: 100
     }
-    affix('#cal')
   })
 
   afterEach(function() {
-    $('#cal').fullCalendar('destroy')
+    currentCalendar.destroy()
   })
 
   describe('when in month view', function() {
@@ -54,7 +53,7 @@ describe('eventDrop', function() {
                 expect(event.end).toBeNull()
 
                 revertFunc()
-                event = $('#cal').fullCalendar('clientEvents')[0]
+                event = currentCalendar.clientEvents()[0]
 
                 expect(event.start).toEqualMoment('2014-06-11')
                 expect(event.end).toBeNull()
@@ -93,7 +92,7 @@ describe('eventDrop', function() {
             expect(event.end).toBeNull()
 
             revertFunc()
-            event = $('#cal').fullCalendar('clientEvents')[0]
+            event = currentCalendar.clientEvents()[0]
 
             expect(event.start).toEqualMoment('2014-06-11T06:00:00')
             expect(event.end).toBeNull()
@@ -189,7 +188,7 @@ describe('eventDrop', function() {
                 expect(event.end).toBeNull()
 
                 revertFunc()
-                event = $('#cal').fullCalendar('clientEvents')[0]
+                event = currentCalendar.clientEvents()[0]
 
                 expect(event.start).toEqualMoment('2014-06-11T06:00:00')
                 expect(event.end).toBeNull()
@@ -227,7 +226,7 @@ describe('eventDrop', function() {
             expect(event.end).toBeNull()
 
             revertFunc()
-            event = $('#cal').fullCalendar('clientEvents')[0]
+            event = currentCalendar.clientEvents()[0]
 
             expect(event.start).toEqualMoment('2014-06-11')
             expect(event.end).toBeNull()
@@ -269,7 +268,7 @@ describe('eventDrop', function() {
             expect(event.allDay).toBe(false)
 
             revertFunc()
-            event = $('#cal').fullCalendar('clientEvents')[0]
+            event = currentCalendar.clientEvents()[0]
 
             expect(event.start).toEqualMoment('2014-06-11')
             expect(event.end).toBeNull()
@@ -325,7 +324,7 @@ describe('eventDrop', function() {
             expect(event.allDay).toBe(true)
 
             revertFunc()
-            event = $('#cal').fullCalendar('clientEvents')[0]
+            event = currentCalendar.clientEvents()[0]
 
             expect(event.start).toEqualMoment('2014-06-11T01:00:00')
             expect(event.end).toBeNull()
@@ -447,7 +446,7 @@ describe('eventDrop', function() {
     spyOn(options, 'eventDragStop').and.callThrough()
 
     setTimeout(function() { // hack. agenda view scroll state would get messed up between tests
-      $('#cal').fullCalendar(options)
+      initCalendar(options)
     }, 0)
   }
 })

+ 36 - 37
tests/automated/legacy/events-gcal.js

@@ -24,7 +24,6 @@ describe('Google Calendar plugin', function() {
   var oldConsoleWarn
 
   beforeEach(function() {
-    affix('#cal')
 
     options = {
       defaultView: 'month',
@@ -48,7 +47,7 @@ describe('Google Calendar plugin', function() {
     options.events = { googleCalendarId: HOLIDAY_CALENDAR_ID }
     options.timezone = 'local'
     options.eventAfterAllRender = function() {
-      var events = $('#cal').fullCalendar('clientEvents')
+      var events = currentCalendar.clientEvents()
       var i
 
       expect(events.length).toBe(NUM_EVENTS)
@@ -58,7 +57,7 @@ describe('Google Calendar plugin', function() {
 
       done()
     }
-    $('#cal').fullCalendar(options)
+    initCalendar(options)
   })
 
   it('request/receives correctly when UTC timezone', function(done) {
@@ -66,7 +65,7 @@ describe('Google Calendar plugin', function() {
     options.events = { googleCalendarId: HOLIDAY_CALENDAR_ID }
     options.timezone = 'UTC'
     options.eventAfterAllRender = function() {
-      var events = $('#cal').fullCalendar('clientEvents')
+      var events = currentCalendar.clientEvents()
       var i
 
       expect(events.length).toBe(NUM_EVENTS)
@@ -76,7 +75,7 @@ describe('Google Calendar plugin', function() {
 
       done()
     }
-    $('#cal').fullCalendar(options)
+    initCalendar(options)
   })
 
   it('request/receives correctly when custom timezone', function(done) {
@@ -84,7 +83,7 @@ describe('Google Calendar plugin', function() {
     options.events = { googleCalendarId: HOLIDAY_CALENDAR_ID }
     options.timezone = 'America/New York'
     options.eventAfterAllRender = function() {
-      var events = $('#cal').fullCalendar('clientEvents')
+      var events = currentCalendar.clientEvents()
       var i
 
       expect(events.length).toBe(NUM_EVENTS)
@@ -94,14 +93,14 @@ describe('Google Calendar plugin', function() {
 
       done()
     }
-    $('#cal').fullCalendar(options)
+    initCalendar(options)
   })
 
   it('requests/receives correctly when no timezone, defaults to not editable', function(done) {
     options.googleCalendarApiKey = API_KEY
     options.events = { googleCalendarId: HOLIDAY_CALENDAR_ID }
     options.eventAfterAllRender = function() {
-      var events = $('#cal').fullCalendar('clientEvents')
+      var events = currentCalendar.clientEvents()
       var eventEls = $('.fc-event')
       var i
 
@@ -115,7 +114,7 @@ describe('Google Calendar plugin', function() {
 
       done()
     }
-    $('#cal').fullCalendar(options)
+    initCalendar(options)
   })
 
   it('allows editable to explicitly be set to true', function(done) {
@@ -130,7 +129,7 @@ describe('Google Calendar plugin', function() {
       expect(eventEls.find('.fc-resizer').length).toBeGreaterThan(0) // editable!
       done()
     }
-    $('#cal').fullCalendar(options)
+    initCalendar(options)
   })
 
   it('fetches events correctly when API key is in the event source', function(done) {
@@ -139,11 +138,11 @@ describe('Google Calendar plugin', function() {
       googleCalendarApiKey: API_KEY
     }
     options.eventAfterAllRender = function() {
-      var events = $('#cal').fullCalendar('clientEvents')
+      var events = currentCalendar.clientEvents()
       expect(events.length).toBe(NUM_EVENTS) // 5 holidays in November 2016 (and end of Oct)
       done()
     }
-    $('#cal').fullCalendar(options)
+    initCalendar(options)
   })
 
   describe('when not given an API key', function() {
@@ -158,7 +157,7 @@ describe('Google Calendar plugin', function() {
         googleCalendarId: HOLIDAY_CALENDAR_ID
       }
       options.eventAfterAllRender = function() {
-        var events = $('#cal').fullCalendar('clientEvents')
+        var events = currentCalendar.clientEvents()
 
         expect(events.length).toBe(0)
         expect(currentWarnArgs.length).toBeGreaterThan(0)
@@ -169,7 +168,7 @@ describe('Google Calendar plugin', function() {
       }
       spyOn(options, 'googleCalendarError').and.callThrough()
       spyOn(options.events, 'googleCalendarError').and.callThrough()
-      $('#cal').fullCalendar(options)
+      initCalendar(options)
     })
   })
 
@@ -186,7 +185,7 @@ describe('Google Calendar plugin', function() {
         googleCalendarId: HOLIDAY_CALENDAR_ID
       }
       options.eventAfterAllRender = function() {
-        var events = $('#cal').fullCalendar('clientEvents')
+        var events = currentCalendar.clientEvents()
 
         expect(events.length).toBe(0)
         expect(currentWarnArgs.length).toBeGreaterThan(0)
@@ -197,7 +196,7 @@ describe('Google Calendar plugin', function() {
       }
       spyOn(options, 'googleCalendarError').and.callThrough()
       spyOn(options.events, 'googleCalendarError').and.callThrough()
-      $('#cal').fullCalendar(options)
+      initCalendar(options)
     })
   })
 
@@ -205,11 +204,11 @@ describe('Google Calendar plugin', function() {
     options.googleCalendarApiKey = API_KEY
     options.events = HOLIDAY_CALENDAR_ID
     options.eventAfterAllRender = function() {
-      var events = $('#cal').fullCalendar('clientEvents')
+      var events = currentCalendar.clientEvents()
       expect(events.length).toBe(NUM_EVENTS) // 5 holidays in November 2016 (and end of Oct)
       done()
     }
-    $('#cal').fullCalendar(options)
+    initCalendar(options)
   })
 
   it('detects a gcal when `events` is the actual calendar ID, with complicated characters (1)', function(done) {
@@ -220,7 +219,7 @@ describe('Google Calendar plugin', function() {
       expect(typeof currentWarnArgs[1]).toBe('object') // sent the request to google, but not-found warning
       done()
     }
-    $('#cal').fullCalendar(options)
+    initCalendar(options)
   })
 
   it('detects a gcal when `events` is the actual calendar ID, with complicated characters (2)', function(done) {
@@ -231,7 +230,7 @@ describe('Google Calendar plugin', function() {
       expect(typeof currentWarnArgs[1]).toBe('object') // sent the request to google, but not-found warning
       done()
     }
-    $('#cal').fullCalendar(options)
+    initCalendar(options)
   })
 
   it('detects a gcal when `events` is the actual calendar ID, person gmail', function(done) {
@@ -242,7 +241,7 @@ describe('Google Calendar plugin', function() {
       expect(typeof currentWarnArgs[1]).toBe('object') // sent the request to google, but not-found warning
       done()
     }
-    $('#cal').fullCalendar(options)
+    initCalendar(options)
   })
 
   it('detects a gcal when `events` is the actual calendar ID, person googlemail', function(done) {
@@ -253,29 +252,29 @@ describe('Google Calendar plugin', function() {
       expect(typeof currentWarnArgs[1]).toBe('object') // sent the request to google, but not-found warning
       done()
     }
-    $('#cal').fullCalendar(options)
+    initCalendar(options)
   })
 
   it('works with requesting an HTTP V1 API feed URL', function(done) {
     options.googleCalendarApiKey = API_KEY
     options.events = 'http://www.google.com/calendar/feeds/usa__en%40holiday.calendar.google.com/public/basic'
     options.eventAfterAllRender = function() {
-      var events = $('#cal').fullCalendar('clientEvents')
+      var events = currentCalendar.clientEvents()
       expect(events.length).toBe(NUM_EVENTS) // 5 holidays in November 2016 (and end of Oct)
       done()
     }
-    $('#cal').fullCalendar(options)
+    initCalendar(options)
   })
 
   it('works with requesting an HTTPS V1 API feed URL', function(done) {
     options.googleCalendarApiKey = API_KEY
     options.events = 'https://www.google.com/calendar/feeds/usa__en%40holiday.calendar.google.com/public/basic'
     options.eventAfterAllRender = function() {
-      var events = $('#cal').fullCalendar('clientEvents')
+      var events = currentCalendar.clientEvents()
       expect(events.length).toBe(NUM_EVENTS) // 5 holidays in November 2016 (and end of Oct)
       done()
     }
-    $('#cal').fullCalendar(options)
+    initCalendar(options)
   })
 
   it('works with requesting an V3 API feed URL', function(done) {
@@ -283,11 +282,11 @@ describe('Google Calendar plugin', function() {
     options.events =
       'https://www.googleapis.com/calendar/v3/calendars/usa__en%40holiday.calendar.google.com/events'
     options.eventAfterAllRender = function() {
-      var events = $('#cal').fullCalendar('clientEvents')
+      var events = currentCalendar.clientEvents()
       expect(events.length).toBe(NUM_EVENTS) // 5 holidays in November 2016 (and end of Oct)
       done()
     }
-    $('#cal').fullCalendar(options)
+    initCalendar(options)
   })
 
   it('calls loading with true then false', function(done) {
@@ -307,7 +306,7 @@ describe('Google Calendar plugin', function() {
         done()
       }
     }
-    $('#cal').fullCalendar(options)
+    initCalendar(options)
   })
 
   describe('removeEventSource', function() {
@@ -323,18 +322,18 @@ describe('Google Calendar plugin', function() {
         if (called) { return } // only the first time
         called = true
 
-        events = $('#cal').fullCalendar('clientEvents')
+        events = currentCalendar.clientEvents()
         expect(events.length).toBe(NUM_EVENTS) // 5 holidays in November 2016 (and end of Oct)
 
         setTimeout(function() {
-          $('#cal').fullCalendar('removeEventSource', HOLIDAY_CALENDAR_ID)
-          events = $('#cal').fullCalendar('clientEvents')
+          currentCalendar.removeEventSource(HOLIDAY_CALENDAR_ID)
+          events = currentCalendar.clientEvents()
           expect(events.length).toBe(0)
           done()
         }, 0)
       }
 
-      $('#cal').fullCalendar(options)
+      initCalendar(options)
     })
 
     it('works when specifying a raw Google Calendar source object', function(done) {
@@ -349,18 +348,18 @@ describe('Google Calendar plugin', function() {
         if (called) { return } // only the first time
         called = true
 
-        events = $('#cal').fullCalendar('clientEvents')
+        events = currentCalendar.clientEvents()
         expect(events.length).toBe(NUM_EVENTS) // 5 holidays in November 2016 (and end of Oct)
 
         setTimeout(function() {
-          $('#cal').fullCalendar('removeEventSource', googleSource)
-          events = $('#cal').fullCalendar('clientEvents')
+          currentCalendar.removeEventSource(googleSource)
+          events = currentCalendar.clientEvents()
           expect(events.length).toBe(0)
           done()
         }, 0)
       }
 
-      $('#cal').fullCalendar(options)
+      initCalendar(options)
     })
   })
 

+ 14 - 13
tests/automated/legacy/external-dnd.js

@@ -25,8 +25,9 @@ describe('external drag and drop', function() {
   })
 
   afterEach(function() {
-    $('#cal').fullCalendar('destroy')
-    $('#cal').remove()
+    var el = currentCalendar.el
+    currentCalendar.destroy()
+    $(el).remove()
     $('#sidebar').remove()
   })
 
@@ -36,8 +37,7 @@ describe('external drag and drop', function() {
     } else {
       $('#sidebar a').draggable()
     }
-
-    $('#cal').fullCalendar(options)
+    initCalendar(options)
   }
 
   function getMonthCell(row, col) {
@@ -63,8 +63,8 @@ describe('external drag and drop', function() {
             if (callCnt === 0) {
               expect(date).toEqualMoment('2014-08-06')
 
-              $('#cal').fullCalendar('next')
-              $('#cal').fullCalendar('prev')
+              currentCalendar.next()
+              currentCalendar.prev()
 
               setTimeout(function() {
                 $('#sidebar .event1').remove()
@@ -186,8 +186,8 @@ describe('external drag and drop', function() {
             if (callCnt === 0) {
               expect(date).toEqualMoment('2014-08-20T01:00:00')
 
-              $('#cal').fullCalendar('next')
-              $('#cal').fullCalendar('prev')
+              currentCalendar.next()
+              currentCalendar.prev()
 
               setTimeout(function() { // needed for IE8, for firing the second time, for some reason
                 $('#sidebar .event1').remove()
@@ -329,17 +329,18 @@ describe('external drag and drop', function() {
       // Issue 2433
       it('should not have drag handlers cleared when other calendar navigates', function() {
         init()
-        var el1 = $('#cal')
-        var el2 = $('<div id="cal2"/>').insertAfter(el1)
-        el2.fullCalendar(options)
+        var el1 = currentCalendar.el
+        var el2 = $('<div id="calendar2">').insertAfter(el1)
+        var currentCalendar2 = new FullCalendar.Calendar(el2[0], options)
+        currentCalendar2.render()
 
         var docListenerCounter = new ListenerCounter(document)
         docListenerCounter.startWatching()
 
-        el1.fullCalendar('next')
+        currentCalendar.next()
         expect(docListenerCounter.stopWatching()).toBe(0)
 
-        el2.fullCalendar('destroy')
+        currentCalendar2.destroy()
         el2.remove()
       })
     })

+ 33 - 58
tests/automated/legacy/firstDay.js

@@ -1,28 +1,19 @@
-
 describe('First Day', function() {
 
-  beforeEach(function() {
-    affix('#cal')
-  })
-
   describe('when using default settings', function() {
-    beforeEach(function() {
-      $('#cal').fullCalendar()
-    })
     it('should make Sunday the first day of the week', function() {
+      initCalendar()
       var dayFirst = $('.fc-day-header')[0]
       expect(dayFirst).toHaveClass('fc-sun')
     })
   })
 
   describe('when setting firstDay to 0', function() {
-    beforeEach(function() {
-      var options = {
-        firstDay: 0
-      }
-      $('#cal').fullCalendar(options)
+    pushOptions({
+      firstDay: 0
     })
     it('should make Sunday the first day of the week', function() {
+      initCalendar()
       var daysOfWeek = $('.fc-day-header')
       expect(daysOfWeek[0]).toHaveClass('fc-sun')
       expect(daysOfWeek[1]).toHaveClass('fc-mon')
@@ -35,13 +26,11 @@ describe('First Day', function() {
   })
 
   describe('when setting firstDay to 1', function() {
-    beforeEach(function() {
-      var options = {
-        firstDay: 1
-      }
-      $('#cal').fullCalendar(options)
+    pushOptions({
+      firstDay: 1
     })
     it('should make Monday the first day of the week', function() {
+      initCalendar()
       var daysOfWeek = $('.fc-day-header')
       expect(daysOfWeek[0]).toHaveClass('fc-mon')
       expect(daysOfWeek[1]).toHaveClass('fc-tue')
@@ -54,13 +43,11 @@ describe('First Day', function() {
   })
 
   describe('when setting weekNumberCalculation to ISO', function() {
-    beforeEach(function() {
-      var options = {
-        weekNumberCalculation: 'ISO'
-      }
-      $('#cal').fullCalendar(options)
+    pushOptions({
+      weekNumberCalculation: 'ISO'
     })
     it('should make Monday the first day of the week', function() {
+      initCalendar()
       var daysOfWeek = $('.fc-day-header')
       expect(daysOfWeek[0]).toHaveClass('fc-mon')
       expect(daysOfWeek[1]).toHaveClass('fc-tue')
@@ -73,13 +60,11 @@ describe('First Day', function() {
   })
 
   describe('when setting firstDay to 2', function() {
-    beforeEach(function() {
-      var options = {
-        firstDay: 2
-      }
-      $('#cal').fullCalendar(options)
+    pushOptions({
+      firstDay: 2
     })
     it('should make Tuesday the first day of the week', function() {
+      initCalendar()
       var daysOfWeek = $('.fc-day-header')
       expect(daysOfWeek[0]).toHaveClass('fc-tue')
       expect(daysOfWeek[1]).toHaveClass('fc-wed')
@@ -92,13 +77,11 @@ describe('First Day', function() {
   })
 
   describe('when setting firstDay to 3', function() {
-    beforeEach(function() {
-      var options = {
-        firstDay: 3
-      }
-      $('#cal').fullCalendar(options)
+    pushOptions({
+      firstDay: 3
     })
     it('should make Wednesday the first day of the week', function() {
+      initCalendar()
       var daysOfWeek = $('.fc-day-header')
       expect(daysOfWeek[0]).toHaveClass('fc-wed')
       expect(daysOfWeek[1]).toHaveClass('fc-thu')
@@ -111,13 +94,11 @@ describe('First Day', function() {
   })
 
   describe('when setting firstDay to 4', function() {
-    beforeEach(function() {
-      var options = {
-        firstDay: 4
-      }
-      $('#cal').fullCalendar(options)
+    pushOptions({
+      firstDay: 4
     })
     it('should make Thursday the first day of the week', function() {
+      initCalendar()
       var daysOfWeek = $('.fc-day-header')
       expect(daysOfWeek[0]).toHaveClass('fc-thu')
       expect(daysOfWeek[1]).toHaveClass('fc-fri')
@@ -130,13 +111,11 @@ describe('First Day', function() {
   })
 
   describe('when setting firstDay to 5', function() {
-    beforeEach(function() {
-      var options = {
-        firstDay: 5
-      }
-      $('#cal').fullCalendar(options)
+    pushOptions({
+      firstDay: 5
     })
     it('should make Friday the first day of the week', function() {
+      initCalendar()
       var daysOfWeek = $('.fc-day-header')
       expect(daysOfWeek[0]).toHaveClass('fc-fri')
       expect(daysOfWeek[1]).toHaveClass('fc-sat')
@@ -149,13 +128,11 @@ describe('First Day', function() {
   })
 
   describe('when setting firstDay to 6', function() {
-    beforeEach(function() {
-      var options = {
-        firstDay: 6
-      }
-      $('#cal').fullCalendar(options)
+    pushOptions({
+      firstDay: 6
     })
     it('should make Saturday the first day of the week', function() {
+      initCalendar()
       var daysOfWeek = $('.fc-day-header')
       expect(daysOfWeek[0]).toHaveClass('fc-sat')
       expect(daysOfWeek[1]).toHaveClass('fc-sun')
@@ -169,13 +146,13 @@ describe('First Day', function() {
 
   describe('when new firstDay options are set', function() {
     it('should change the first day of week to Monday', function() {
-      $('#cal').fullCalendar({
+      initCalendar({
         firstDay: 1
       })
       expect($('.fc-day-header')[0]).toHaveClass('fc-mon')
     })
-    it('shoule change the first day of week to Thursday', function() {
-      $('#cal').fullCalendar({
+    it('should change the first day of week to Thursday', function() {
+      initCalendar({
         firstDay: 4
       })
       expect($('.fc-day-header')[0]).toHaveClass('fc-thu')
@@ -183,14 +160,12 @@ describe('First Day', function() {
   })
 
   describe('when first day is set to Tuesday and isRTL is true', function() {
-    beforeEach(function() {
-      var options = {
-        firstDay: 2,
-        isRTL: true
-      }
-      $('#cal').fullCalendar(options)
+    pushOptions({
+      firstDay: 2,
+      isRTL: true
     })
     it('should put days mon, sun, sat ...', function() {
+      initCalendar()
       var daysOfWeek = $('.fc-day-header')
       expect(daysOfWeek[0]).toHaveClass('fc-mon')
       expect(daysOfWeek[1]).toHaveClass('fc-sun')
@@ -203,7 +178,7 @@ describe('First Day', function() {
   })
 
   it('should have a different default value based on the locale', function() {
-    $('#cal').fullCalendar({
+    initCalendar({
       locale: 'en-gb'
     })
     // firstDay will be 1 (Monday) in Great Britain

+ 18 - 22
tests/automated/legacy/footer-navigation.js

@@ -1,61 +1,57 @@
-
 describe('footer navigation', function() {
-  var options
 
-  beforeEach(function() {
-    affix('#calendar')
-    options = {
-      now: '2010-02-01',
-      footer: {
-        left: 'next,prev,prevYear,nextYear today',
-        center: '',
-        right: 'title'
-      }
+  pushOptions({
+    now: '2010-02-01',
+    footer: {
+      left: 'next,prev,prevYear,nextYear today',
+      center: '',
+      right: 'title'
     }
   })
 
   describe('and click next', function() {
     it('should change view to next month', function() {
-      $('#calendar').fullCalendar(options)
+      initCalendar()
       $('.fc-footer-toolbar .fc-next-button').simulate('click')
-      var newDate = $('#calendar').fullCalendar('getDate')
+      var newDate = currentCalendar.getDate()
       expect(newDate).toEqualMoment('2010-03-01')
     })
   })
 
   describe('and click prev', function() {
     it('should change view to prev month', function() {
-      $('#calendar').fullCalendar(options)
+      initCalendar()
       $('.fc-footer-toolbar .fc-prev-button').simulate('click')
-      var newDate = $('#calendar').fullCalendar('getDate')
+      var newDate = currentCalendar.getDate()
       expect(newDate).toEqualMoment('2010-01-01')
     })
   })
 
   describe('and click prevYear', function() {
     it('should change view to prev month', function() {
-      $('#calendar').fullCalendar(options)
+      initCalendar()
       $('.fc-footer-toolbar .fc-prevYear-button').simulate('click')
-      var newDate = $('#calendar').fullCalendar('getDate')
+      var newDate = currentCalendar.getDate()
       expect(newDate).toEqualMoment('2009-02-01')
     })
   })
 
   describe('and click nextYear', function() {
     it('should change view to prev month', function() {
-      $('#calendar').fullCalendar(options)
+      initCalendar()
       $('.fc-footer-toolbar .fc-nextYear-button').simulate('click')
-      var newDate = $('#calendar').fullCalendar('getDate')
+      var newDate = currentCalendar.getDate()
       expect(newDate).toEqualMoment('2011-02-01')
     })
   })
 
   describe('and click today', function() {
     it('should change view to prev month', function() {
-      options.defaultDate = '2010-03-15' // something other than the `now` date
-      $('#calendar').fullCalendar(options)
+      initCalendar({
+        defaultDate: '2010-03-15' // something other than the `now` date
+      })
       $('.fc-footer-toolbar .fc-today-button').simulate('click')
-      var newDate = $('#calendar').fullCalendar('getDate') // will be ambig zone
+      var newDate = currentCalendar.getDate() // will be ambig zone
       expect(newDate).toEqualMoment('2010-02-01')
     })
   })

+ 19 - 20
tests/automated/legacy/header-navigation.js

@@ -1,59 +1,58 @@
-
 describe('header navigation', function() {
 
-  beforeEach(function() {
-    affix('#calendar')
-    var options = {
-      header: {
-        left: 'next,prev,prevYear,nextYear today',
-        center: '',
-        right: 'title'
-      }
+  pushOptions({
+    header: {
+      left: 'next,prev,prevYear,nextYear today',
+      center: '',
+      right: 'title'
     }
-    $('#calendar').fullCalendar(options)
+  })
+
+  beforeEach(function() {
+    initCalendar()
   })
 
   describe('and click next', function() {
     it('should change view to next month', function() {
-      $('#calendar').fullCalendar('gotoDate', '2010-02-01')
+      currentCalendar.gotoDate('2010-02-01')
       $('.fc-next-button').simulate('click')
-      var newDate = $('#calendar').fullCalendar('getDate')
+      var newDate = currentCalendar.getDate()
       expect(newDate).toEqualMoment('2010-03-01')
     })
   })
 
   describe('and click prev', function() {
     it('should change view to prev month', function() {
-      $('#calendar').fullCalendar('gotoDate', '2010-02-01')
+      currentCalendar.gotoDate('2010-02-01')
       $('.fc-prev-button').simulate('click')
-      var newDate = $('#calendar').fullCalendar('getDate')
+      var newDate = currentCalendar.getDate()
       expect(newDate).toEqualMoment('2010-01-01')
     })
   })
 
   describe('and click prevYear', function() {
     it('should change view to prev month', function() {
-      $('#calendar').fullCalendar('gotoDate', '2010-02-01')
+      currentCalendar.gotoDate('2010-02-01')
       $('.fc-prevYear-button').simulate('click')
-      var newDate = $('#calendar').fullCalendar('getDate')
+      var newDate = currentCalendar.getDate()
       expect(newDate).toEqualMoment('2009-02-01')
     })
   })
 
   describe('and click nextYear', function() {
     it('should change view to prev month', function() {
-      $('#calendar').fullCalendar('gotoDate', '2010-02-01')
+      currentCalendar.gotoDate('2010-02-01')
       $('.fc-nextYear-button').simulate('click')
-      var newDate = $('#calendar').fullCalendar('getDate')
+      var newDate = currentCalendar.getDate()
       expect(newDate).toEqualMoment('2011-02-01')
     })
   })
 
   describe('and click today', function() {
     it('should change view to prev month', function() {
-      $('#calendar').fullCalendar('gotoDate', '2010-02-01')
+      currentCalendar.gotoDate('2010-02-01')
       $('.fc-today-button').simulate('click')
-      var newDate = $('#calendar').fullCalendar('getDate') // will be ambig zone
+      var newDate = currentCalendar.getDate() // will be ambig zone
       newDate.local() // assign the local timezone
       expect(newDate).toEqualNow()
     })

+ 7 - 13
tests/automated/legacy/hiddenDays.js

@@ -1,13 +1,8 @@
-
 describe('hiddenDays', function() {
 
-  beforeEach(function() {
-    affix('#cal')
-  })
-
   describe('when using default', function() {
     beforeEach(function() {
-      $('#cal').fullCalendar()
+      initCalendar()
     })
     it('should show 7 days of the week', function() {
       var daysCount = $('.fc-day-header').length
@@ -17,7 +12,7 @@ describe('hiddenDays', function() {
 
   describe('when setting an empty hiddenDays', function() {
     beforeEach(function() {
-      $('#cal').fullCalendar({
+      initCalendar({
         hiddenDays: []
       })
     })
@@ -29,7 +24,7 @@ describe('hiddenDays', function() {
 
   describe('when setting hiddenDays with 1', function() {
     beforeEach(function() {
-      $('#cal').fullCalendar({
+      initCalendar({
         hiddenDays: [ 1 ]
       })
     })
@@ -51,7 +46,7 @@ describe('hiddenDays', function() {
 
   describe('when setting hiddenDays with 3,5', function() {
     beforeEach(function() {
-      $('#cal').fullCalendar({
+      initCalendar({
         hiddenDays: [ 3, 5 ]
       })
     })
@@ -77,11 +72,10 @@ describe('hiddenDays', function() {
 
   describe('when setting all hiddenDays', function() {
     it('should expect to throw an exception', function() {
-      var options = {
-        hiddenDays: [ 0, 1, 2, 3, 4, 5, 6 ]
-      }
       expect(function() {
-        $('#cal').fullCalendar(options)
+        initCalendar({
+          hiddenDays: [ 0, 1, 2, 3, 4, 5, 6 ]
+        })
       }).toThrow(new Error('invalid hiddenDays'))
     })
   })

+ 12 - 13
tests/automated/legacy/select-callback.js

@@ -3,7 +3,6 @@ describe('select callback', function() {
   var options
 
   beforeEach(function() {
-    affix('#cal')
     options = {
       defaultDate: '2014-05-25',
       selectable: true,
@@ -12,7 +11,7 @@ describe('select callback', function() {
   })
 
   afterEach(function() {
-    $('#cal').fullCalendar('destroy')
+    currentCalendar.destroy()
   });
 
   [ false, true ].forEach(function(isRTL) {
@@ -36,7 +35,7 @@ describe('select callback', function() {
             expect(end).toEqualMoment('2014-05-07')
           }
           spyOn(options, 'select').and.callThrough()
-          $('#cal').fullCalendar(options)
+          initCalendar(options)
           $('.fc-day[data-date="2014-04-28"]').simulate('drag', {
             end: '.fc-day[data-date="2014-05-06"]',
             callback: function() {
@@ -57,7 +56,7 @@ describe('select callback', function() {
             expect(end).toEqualMoment('2014-05-07')
           }
           spyOn(options, 'select').and.callThrough()
-          $('#cal').fullCalendar(options)
+          initCalendar(options)
           $('.fc-day[data-date="2014-04-28"]').simulate('drag', {
             isTouch: true,
             delay: 200,
@@ -80,7 +79,7 @@ describe('select callback', function() {
             expect(end).toEqualMoment('2014-04-29')
           }
           spyOn(options, 'select').and.callThrough()
-          $('#cal').fullCalendar(options)
+          initCalendar(options)
           $('.fc-day[data-date="2014-04-28"]').simulate('drag', {
             end: '.fc-day[data-date="2014-04-28"]',
             callback: function() {
@@ -108,7 +107,7 @@ describe('select callback', function() {
               expect(end).toEqualMoment('2014-05-30')
             }
             spyOn(options, 'select').and.callThrough()
-            $('#cal').fullCalendar(options)
+            initCalendar(options)
             $('.fc-agenda-view .fc-day-grid .fc-day:eq(3)').simulate('drag', { // will be 2014-05-28 for LTR and RTL
               dx: $('.fc-sun').outerWidth() * (isRTL ? -1 : 1), // the width of one column
               callback: function() {
@@ -129,7 +128,7 @@ describe('select callback', function() {
               expect(end).toEqualMoment('2014-05-29')
             }
             spyOn(options, 'select').and.callThrough()
-            $('#cal').fullCalendar(options)
+            initCalendar(options)
             $('.fc-agenda-view .fc-day-grid .fc-day:eq(3)').simulate('drag', { // will be 2014-05-28 for LTR and RTL
               callback: function() {
                 expect(options.select).toHaveBeenCalled()
@@ -151,7 +150,7 @@ describe('select callback', function() {
               expect(end).toEqualMoment('2014-05-28T10:30:00')
             }
             spyOn(options, 'select').and.callThrough()
-            $('#cal').fullCalendar(options)
+            initCalendar(options)
             $('.fc-slats tr:eq(18) td:not(.fc-time)').simulate('drag', { // middle will be 2014-05-28T09:00:00
               dy: $('.fc-slats tr:eq(18)').outerHeight() * 2, // move down two slots
               callback: function() {
@@ -172,7 +171,7 @@ describe('select callback', function() {
               expect(end).toEqualMoment('2014-05-28T10:30:00')
             }
             spyOn(options, 'select').and.callThrough()
-            $('#cal').fullCalendar(options)
+            initCalendar(options)
             setTimeout(function() { // prevent scroll from being triggered, killing the select interaction
               $('.fc-slats tr:eq(18) td:not(.fc-time)').simulate('drag', { // middle will be 2014-05-28T09:00:00
                 isTouch: true,
@@ -197,7 +196,7 @@ describe('select callback', function() {
               expect(end).toEqualMoment('2014-05-29T10:30:00')
             }
             spyOn(options, 'select').and.callThrough()
-            $('#cal').fullCalendar(options)
+            initCalendar(options)
             $('.fc-slats tr:eq(18) td:not(.fc-time)').simulate('drag', { // middle will be 2014-05-28T09:00:00
               dx: $('.fc-day-header:first').outerWidth() * 0.9 * (isRTL ? -1 : 1), // one day ahead
               dy: $('.fc-slats tr:eq(18)').outerHeight() * 2, // move down two slots
@@ -219,7 +218,7 @@ describe('select callback', function() {
               expect(end).toEqualMoment('2014-05-28T09:30:00')
             }
             spyOn(options, 'select').and.callThrough()
-            $('#cal').fullCalendar(options)
+            initCalendar(options)
             $('.fc-slats tr:eq(18) td:not(.fc-time)').simulate('drag', { // middle will be 2014-05-28T09:00:00
               callback: function() {
                 expect(options.select).toHaveBeenCalled()
@@ -241,7 +240,7 @@ describe('select callback', function() {
       options.select = function() {}
       spyOn(options, 'select').and.callThrough()
 
-      $('#cal').fullCalendar(options)
+      initCalendar(options)
 
       $('.fc-day[data-date="2014-04-28"]').simulate('drag', {
         dx: 12,
@@ -257,7 +256,7 @@ describe('select callback', function() {
       options.select = function() {}
       spyOn(options, 'select').and.callThrough()
 
-      $('#cal').fullCalendar(options)
+      initCalendar(options)
 
       $('.fc-day[data-date="2014-04-28"]').simulate('drag', {
         dx: 8,

+ 31 - 32
tests/automated/legacy/select-method.js

@@ -3,7 +3,6 @@ describe('select method', function() {
   var options
 
   beforeEach(function() {
-    affix('#cal')
     options = {
       defaultDate: '2014-05-25',
       selectable: true
@@ -11,7 +10,7 @@ describe('select method', function() {
   })
 
   afterEach(function() {
-    $('#cal').fullCalendar('destroy')
+    currentCalendar.destroy()
   });
 
   /*
@@ -34,13 +33,13 @@ describe('select method', function() {
         describe('when called with all-day moments', function() {
           describe('when in bounds', function() {
             it('renders a selection', function() {
-              $('#cal').fullCalendar(options)
-              $('#cal').fullCalendar('select', '2014-05-07', '2014-05-09')
+              initCalendar(options)
+              currentCalendar.select('2014-05-07', '2014-05-09')
               expect($('.fc-highlight')).toBeVisible()
             })
             it('renders a selection when called with one argument', function() {
-              $('#cal').fullCalendar(options)
-              $('#cal').fullCalendar('select', '2014-05-07')
+              initCalendar(options)
+              currentCalendar.select('2014-05-07')
               expect($('.fc-highlight')).toBeVisible()
             })
             it('fires a selection event', function() {
@@ -51,15 +50,15 @@ describe('select method', function() {
                 expect(end).toEqualMoment('2014-05-09')
               }
               spyOn(options, 'select').and.callThrough()
-              $('#cal').fullCalendar(options)
-              $('#cal').fullCalendar('select', '2014-05-07', '2014-05-09')
+              initCalendar(options)
+              currentCalendar.select('2014-05-07', '2014-05-09')
               expect(options.select).toHaveBeenCalled()
             })
           })
           describe('when out of bounds', function() {
             it('doesn\'t render a selection', function() {
-              $('#cal').fullCalendar(options)
-              $('#cal').fullCalendar('select', '2015-05-07', '2015-05-09')
+              initCalendar(options)
+              currentCalendar.select('2015-05-07', '2015-05-09')
               expect($('.fc-highlight')).not.toBeVisible()
             })
             /*
@@ -70,8 +69,8 @@ describe('select method', function() {
                 expect(end).toEqualMoment('2014-05-09');
               };
               spyOn(options, 'select').and.callThrough();
-              $('#cal').fullCalendar(options);
-              $('#cal').fullCalendar('select', '2015-05-07', '2015-05-09');
+              initCalendar(options);
+              currentCalendar.select('2015-05-07', '2015-05-09');
               expect(options.select).not.toHaveBeenCalled();
             });
             */
@@ -79,8 +78,8 @@ describe('select method', function() {
         })
         describe('when called with timed moments', function() {
           it('renders a selection', function() {
-            $('#cal').fullCalendar(options)
-            $('#cal').fullCalendar('select', '2014-05-07T06:00:00', '2014-05-09T07:00:00')
+            initCalendar(options)
+            currentCalendar.select('2014-05-07T06:00:00', '2014-05-09T07:00:00')
             expect($('.fc-highlight')).toBeVisible()
           })
           it('fires a selection event', function() {
@@ -91,8 +90,8 @@ describe('select method', function() {
               expect(end).toEqualMoment('2014-05-09T06:00:00')
             }
             spyOn(options, 'select').and.callThrough()
-            $('#cal').fullCalendar(options)
-            $('#cal').fullCalendar('select', '2014-05-07T06:00:00', '2014-05-09T06:00:00')
+            initCalendar(options)
+            currentCalendar.select('2014-05-07T06:00:00', '2014-05-09T06:00:00')
             expect(options.select).toHaveBeenCalled()
           })
         })
@@ -106,13 +105,13 @@ describe('select method', function() {
         describe('when called with timed moments', function() {
           describe('when in bounds', function() {
             it('renders a selection when called with one argument', function() {
-              $('#cal').fullCalendar(options)
-              $('#cal').fullCalendar('select', '2014-05-26T06:00:00')
+              initCalendar(options)
+              currentCalendar.select('2014-05-26T06:00:00')
               expect($('.fc-highlight')).toBeVisible()
             })
             it('renders a selection over the slot area', function() {
-              $('#cal').fullCalendar(options)
-              $('#cal').fullCalendar('select', '2014-05-26T06:00:00', '2014-05-26T08:00:00')
+              initCalendar(options)
+              currentCalendar.select('2014-05-26T06:00:00', '2014-05-26T08:00:00')
               expect($('.fc-highlight')).toBeVisible()
               var slotAreaTop = $('.fc-time-grid-container').offset().top
               var overlayTop = $('.fc-highlight').offset().top
@@ -121,8 +120,8 @@ describe('select method', function() {
           })
           describe('when out of bounds', function() {
             it('doesn\'t render a selection', function() {
-              $('#cal').fullCalendar(options)
-              $('#cal').fullCalendar('select', '2015-05-26T06:00:00', '2015-05-26T07:00:00')
+              initCalendar(options)
+              currentCalendar.select('2015-05-26T06:00:00', '2015-05-26T07:00:00')
               expect($('.fc-highlight')).not.toBeVisible()
             })
             /*
@@ -133,8 +132,8 @@ describe('select method', function() {
                 expect(end).toEqualMoment('2015-05-09T07:00:00');
               };
               spyOn(options, 'select').and.callThrough();
-              $('#cal').fullCalendar(options);
-              $('#cal').fullCalendar('select', '2015-05-07T06:00:00', '2015-05-09T07:00:00');
+              initCalendar(options);
+              currentCalendar.select('2015-05-07T06:00:00', '2015-05-09T07:00:00');
               expect(options.select).not.toHaveBeenCalled();
             });
             */
@@ -146,8 +145,8 @@ describe('select method', function() {
               options.allDaySlot = true
             })
             it('renders a selection over the day area', function() {
-              $('#cal').fullCalendar(options)
-              $('#cal').fullCalendar('select', '2014-05-26', '2014-05-28')
+              initCalendar(options)
+              currentCalendar.select('2014-05-26', '2014-05-28')
               expect($('.fc-highlight')).toBeVisible()
               var slotAreaTop = $('.fc-time-grid-container').offset().top
               var overlayTop = $('.fc-highlight').offset().top
@@ -161,8 +160,8 @@ describe('select method', function() {
                 expect(end).toEqualMoment('2014-05-28')
               }
               spyOn(options, 'select').and.callThrough()
-              $('#cal').fullCalendar(options)
-              $('#cal').fullCalendar('select', '2014-05-26', '2014-05-28')
+              initCalendar(options)
+              currentCalendar.select('2014-05-26', '2014-05-28')
               expect(options.select).toHaveBeenCalled()
             })
           })
@@ -171,8 +170,8 @@ describe('select method', function() {
               options.allDaySlot = false
             })
             it('doesn\'t render', function() {
-              $('#cal').fullCalendar(options)
-              $('#cal').fullCalendar('select', '2014-05-26', '2014-05-28')
+              initCalendar(options)
+              currentCalendar.select('2014-05-26', '2014-05-28')
               expect($('.fc-highlight')).not.toBeVisible()
             })
             /*
@@ -185,8 +184,8 @@ describe('select method', function() {
                 expect(end).toEqualMoment('2014-05-28');
               };
               spyOn(options, 'select').and.callThrough();
-              $('#cal').fullCalendar(options);
-              $('#cal').fullCalendar('select', '2014-05-26', '2014-05-28');
+              initCalendar(options);
+              currentCalendar.select('2014-05-26', '2014-05-28');
               expect(options.select).not.toHaveBeenCalled();
             });
             */

+ 8 - 10
tests/automated/legacy/theme.js

@@ -1,10 +1,11 @@
 describe('theme', function() {
 
+  pushOptions({
+    defaultView: 'agendaWeek'
+  })
+
   it('can be changed dynamically', function() {
-    affix('#cal')
-    $('#cal').fullCalendar({
-      defaultView: 'agendaWeek'
-    })
+    initCalendar()
 
     expect($('.fc')).toHaveClass('fc-unthemed')
     expect($('.fc')).not.toHaveClass('ui-widget')
@@ -16,7 +17,7 @@ describe('theme', function() {
     var scrollTop = $('.fc-scroller').scrollTop()
 
     // change option!
-    $('#cal').fullCalendar('option', 'theme', true)
+    currentCalendar.option('theme', true)
 
     expect($('.fc')).toHaveClass('ui-widget')
     expect($('.fc')).not.toHaveClass('fc-unthemed')
@@ -32,17 +33,14 @@ describe('theme', function() {
   // this tests the options setter with a single hash argument.
   // TODO: not best place for this.
   it('can be change with other options', function() {
-    affix('#cal')
-    $('#cal').fullCalendar({
-      defaultView: 'agendaWeek'
-    })
+    initCalendar()
 
     expect($('.fc')).toHaveClass('fc-unthemed')
     expect($('.fc')).not.toHaveClass('ui-widget')
     expect($('.fc-nonbusiness').length).toBe(0)
 
     // change option!
-    $('#cal').fullCalendar('option', {
+    currentCalendar.option({
       theme: true,
       businessHours: true
     })

+ 34 - 34
tests/automated/legacy/timeFormat.js

@@ -1,17 +1,12 @@
 describe('timeFormat', function() {
 
-  var options
-
-  beforeEach(function() {
-    affix('#cal')
-    options = {
-      defaultDate: '2014-06-04',
-      events: [ {
-        title: 'my event',
-        start: '2014-06-04T15:00:00',
-        end: '2014-06-04T17:00:00'
-      } ]
-    }
+  pushOptions({
+    defaultDate: '2014-06-04',
+    events: [ {
+      title: 'my event',
+      start: '2014-06-04T15:00:00',
+      end: '2014-06-04T17:00:00'
+    } ]
   })
 
   function getRenderedEventTime() {
@@ -20,78 +15,83 @@ describe('timeFormat', function() {
 
   describe('when in month view', function() {
 
-    beforeEach(function() {
-      options.defaultView = 'month'
+    pushOptions({
+      defaultView: 'month'
     })
 
     it('renders correctly when default', function() {
-      $('#cal').fullCalendar(options)
+      initCalendar()
       expect(getRenderedEventTime()).toBe('3p')
     })
 
     it('renders correctly when default and the locale is customized', function() {
-      options.locale = 'en-gb'
-      $('#cal').fullCalendar(options)
+      initCalendar({
+        locale: 'en-gb'
+      })
       expect(getRenderedEventTime()).toBe('15')
     })
 
     it('renders correctly when customized', function() {
-      options.timeFormat = 'Hh:mm:mm'
-      $('#cal').fullCalendar(options)
+      initCalendar({
+        timeFormat: 'Hh:mm:mm'
+      })
       expect(getRenderedEventTime()).toBe('153:00:00')
     })
   })
 
   describe('when in agendaWeek view', function() {
 
-    beforeEach(function() {
-      options.defaultView = 'agendaWeek'
+    pushOptions({
+      defaultView: 'agendaWeek'
     })
 
     it('renders correctly when default', function() {
-      $('#cal').fullCalendar(options)
+      initCalendar()
       expect(getRenderedEventTime()).toBe('3:00 - 5:00')
     })
 
     it('renders correctly when default and the locale is customized', function() {
-      options.locale = 'en-gb'
-      $('#cal').fullCalendar(options)
+      initCalendar({
+        locale: 'en-gb'
+      })
       expect(getRenderedEventTime()).toBe('15:00 - 17:00')
     })
 
     it('renders correctly when customized', function() {
-      options.timeFormat = 'Hh:mm:mm'
-      $('#cal').fullCalendar(options)
+      initCalendar({
+        timeFormat: 'Hh:mm:mm'
+      })
       expect(getRenderedEventTime()).toBe('153:00:00 - 175:00:00')
     })
   })
 
   describe('when in multi-day custom basic view', function() {
 
-    beforeEach(function() {
-      options.views = {
+    pushOptions({
+      views: {
         basicTwoDay: {
           type: 'basic',
           duration: { days: 2 }
         }
-      }
-      options.defaultView = 'basicTwoDay'
+      },
+      defaultView: 'basicTwoDay'
     })
 
     it('defaults to no end time', function() {
-      $('#cal').fullCalendar(options)
+      initCalendar()
       expect(getRenderedEventTime()).toBe('3p')
     })
   })
 
   describe('when in basicDay view', function() {
 
-    beforeEach(function() {
-      options.defaultView = 'basicDay'
+    pushOptions({
+      defaultView: 'basicDay'
     })
 
+
     it('defaults to showing the end time', function() {
-      $('#cal').fullCalendar(options)
+      initCalendar()
       expect(getRenderedEventTime()).toBe('3p - 5p')
     })
   })

+ 74 - 77
tests/automated/legacy/timezone.js

@@ -1,49 +1,43 @@
-
 describe('timezone', function() {
 
   // NOTE: Only deals with the processing of *received* events.
   // Verification of a correct AJAX *request* is done in events-json-feed.js
 
-  var options
-
-  beforeEach(function() {
-    affix('#cal')
-    options = {
-      defaultView: 'month',
-      defaultDate: '2014-05-01',
-      events: [
-        {
-          id: '1',
-          title: 'all day event',
-          start: '2014-05-02'
-        },
-        {
-          id: '2',
-          title: 'timed event',
-          start: '2014-05-10T12:00:00'
-        },
-        {
-          id: '3',
-          title: 'timed and zoned event',
-          start: '2014-05-10T14:00:00+11:00'
-        }
-      ]
-    }
+  pushOptions({
+    defaultView: 'month',
+    defaultDate: '2014-05-01',
+    events: [
+      {
+        id: '1',
+        title: 'all day event',
+        start: '2014-05-02'
+      },
+      {
+        id: '2',
+        title: 'timed event',
+        start: '2014-05-10T12:00:00'
+      },
+      {
+        id: '3',
+        title: 'timed and zoned event',
+        start: '2014-05-10T14:00:00+11:00'
+      }
+    ]
   })
 
-
   it('receives events correctly when no timezone', function(done) {
-    options.eventAfterAllRender = function() {
-      expectNoTimezone()
-      done()
-    }
-    $('#cal').fullCalendar(options)
+    initCalendar({
+      eventAfterAllRender: function() {
+        expectNoTimezone()
+        done()
+      }
+    })
   })
 
   function expectNoTimezone() {
-    var allDayEvent = $('#cal').fullCalendar('clientEvents', '1')[0]
-    var timedEvent = $('#cal').fullCalendar('clientEvents', '2')[0]
-    var zonedEvent = $('#cal').fullCalendar('clientEvents', '3')[0]
+    var allDayEvent = currentCalendar.clientEvents('1')[0]
+    var timedEvent = currentCalendar.clientEvents('2')[0]
+    var zonedEvent = currentCalendar.clientEvents('3')[0]
     expect(allDayEvent.start.hasZone()).toEqual(false)
     expect(allDayEvent.start.hasTime()).toEqual(false)
     expect(allDayEvent.start.format()).toEqual('2014-05-02')
@@ -57,18 +51,19 @@ describe('timezone', function() {
 
 
   it('receives events correctly when local timezone', function(done) {
-    options.timezone = 'local'
-    options.eventAfterAllRender = function() {
-      expectLocalTimezone()
-      done()
-    }
-    $('#cal').fullCalendar(options)
+    initCalendar({
+      timezone: 'local',
+      eventAfterAllRender: function() {
+        expectLocalTimezone()
+        done()
+      }
+    })
   })
 
   function expectLocalTimezone() {
-    var allDayEvent = $('#cal').fullCalendar('clientEvents', '1')[0]
-    var timedEvent = $('#cal').fullCalendar('clientEvents', '2')[0]
-    var zonedEvent = $('#cal').fullCalendar('clientEvents', '3')[0]
+    var allDayEvent = currentCalendar.clientEvents('1')[0]
+    var timedEvent = currentCalendar.clientEvents('2')[0]
+    var zonedEvent = currentCalendar.clientEvents('3')[0]
     expect(allDayEvent.start.hasZone()).toEqual(false)
     expect(allDayEvent.start.hasTime()).toEqual(false)
     expect(allDayEvent.start.format()).toEqual('2014-05-02')
@@ -82,18 +77,19 @@ describe('timezone', function() {
 
 
   it('receives events correctly when UTC timezone', function(done) {
-    options.timezone = 'UTC'
-    options.eventAfterAllRender = function() {
-      expectUtcTimezone()
-      done()
-    }
-    $('#cal').fullCalendar(options)
+    initCalendar({
+      timezone: 'UTC',
+      eventAfterAllRender: function() {
+        expectUtcTimezone()
+        done()
+      }
+    })
   })
 
   function expectUtcTimezone() {
-    var allDayEvent = $('#cal').fullCalendar('clientEvents', '1')[0]
-    var timedEvent = $('#cal').fullCalendar('clientEvents', '2')[0]
-    var zonedEvent = $('#cal').fullCalendar('clientEvents', '3')[0]
+    var allDayEvent = currentCalendar.clientEvents('1')[0]
+    var timedEvent = currentCalendar.clientEvents('2')[0]
+    var zonedEvent = currentCalendar.clientEvents('3')[0]
     expect(allDayEvent.start.hasZone()).toEqual(false)
     expect(allDayEvent.start.hasTime()).toEqual(false)
     expect(allDayEvent.start.format()).toEqual('2014-05-02')
@@ -107,18 +103,19 @@ describe('timezone', function() {
 
 
   it('receives events correctly when custom timezone', function(done) {
-    options.timezone = 'America/Chicago'
-    options.eventAfterAllRender = function() {
-      expectCustomTimezone()
-      done()
-    }
-    $('#cal').fullCalendar(options)
+    initCalendar({
+      timezone: 'America/Chicago',
+      eventAfterAllRender: function() {
+        expectCustomTimezone()
+        done()
+      }
+    })
   })
 
   function expectCustomTimezone() {
-    var allDayEvent = $('#cal').fullCalendar('clientEvents', '1')[0]
-    var timedEvent = $('#cal').fullCalendar('clientEvents', '2')[0]
-    var zonedEvent = $('#cal').fullCalendar('clientEvents', '3')[0]
+    var allDayEvent = currentCalendar.clientEvents('1')[0]
+    var timedEvent = currentCalendar.clientEvents('2')[0]
+    var zonedEvent = currentCalendar.clientEvents('3')[0]
     expect(allDayEvent.start.hasZone()).toEqual(false)
     expect(allDayEvent.start.hasTime()).toEqual(false)
     expect(allDayEvent.start.format()).toEqual('2014-05-02')
@@ -135,22 +132,22 @@ describe('timezone', function() {
     var callCnt = 0
     var rootEl
 
-    options.timezone = false
-    options.eventAfterAllRender = function() {
-      callCnt++
-      if (callCnt === 1) {
-        expectNoTimezone()
-        rootEl = $('.fc-view > *:first')
-        expect(rootEl.length).toBe(1)
-        $('#cal').fullCalendar('option', 'timezone', 'UTC') // will cause second call...
-      } else if (callCnt === 2) {
-        expectUtcTimezone()
-        expect($('.fc-view > *:first')[0]).toBe(rootEl[0]) // ensure didn't rerender whole calendar
-        done()
+    initCalendar({
+      timezone: false,
+      eventAfterAllRender: function() {
+        callCnt++
+        if (callCnt === 1) {
+          expectNoTimezone()
+          rootEl = $('.fc-view > *:first')
+          expect(rootEl.length).toBe(1)
+          currentCalendar.option('timezone', 'UTC') // will cause second call...
+        } else if (callCnt === 2) {
+          expectUtcTimezone()
+          expect($('.fc-view > *:first')[0]).toBe(rootEl[0]) // ensure didn't rerender whole calendar
+          done()
+        }
       }
-    }
-
-    $('#cal').fullCalendar(options)
+    })
   })
 
 })

+ 14 - 18
tests/automated/legacy/titleFormat.js

@@ -2,10 +2,6 @@ describe('titleFormat', function() {
 
   var SELECTOR = '.fc-toolbar h2'
 
-  beforeEach(function() {
-    affix('#cal')
-  })
-
   describe('when default', function() {
 
     var viewWithFormat = [
@@ -17,18 +13,18 @@ describe('titleFormat', function() {
     ]
 
     beforeEach(function() {
-      $('#cal').fullCalendar({
+      initCalendar({
         defaultDate: '2014-06-12',
         titleRangeSeparator: ' - '
       })
     })
 
     it('should have default values', function() {
-      var cal = $('#cal')
+      var cal = $(currentCalendar.el)
 
       for (var i = 0; i < viewWithFormat.length; i++) {
         var crtView = viewWithFormat[i]
-        cal.fullCalendar('changeView', crtView.view)
+        currentCalendar.changeView(crtView.view)
         expect(cal.find(SELECTOR).text()).toMatch(crtView.expected)
       };
     })
@@ -45,7 +41,7 @@ describe('titleFormat', function() {
     ]
 
     beforeEach(function() {
-      $('#cal').fullCalendar({
+      initCalendar({
         defaultDate: '2014-06-12',
         titleRangeSeparator: ' - ',
         views: {
@@ -59,11 +55,11 @@ describe('titleFormat', function() {
     })
 
     it('should have the correct values', function() {
-      var cal = $('#cal')
+      var cal = $(currentCalendar.el)
 
       for (var i = 0; i < viewWithFormat.length; i++) {
         var crtView = viewWithFormat[i]
-        cal.fullCalendar('changeView', crtView.view)
+        currentCalendar.changeView(crtView.view)
         expect(cal.find(SELECTOR).text()).toBe(crtView.expected)
       };
     })
@@ -80,7 +76,7 @@ describe('titleFormat', function() {
     ]
 
     beforeEach(function() {
-      $('#cal').fullCalendar({
+      initCalendar({
         defaultDate: '2014-06-12',
         titleRangeSeparator: ' - ',
         locale: 'fr'
@@ -88,11 +84,11 @@ describe('titleFormat', function() {
     })
 
     it('should have the translated dates', function() {
-      var cal = $('#cal')
+      var cal = $(currentCalendar.el)
 
       for (var i = 0; i < viewWithFormat.length; i++) {
         var crtView = viewWithFormat[i]
-        cal.fullCalendar('changeView', crtView.view)
+        currentCalendar.changeView(crtView.view)
         expect(cal.find(SELECTOR).text()).toBe(crtView.expected)
       };
     })
@@ -101,7 +97,7 @@ describe('titleFormat', function() {
   describe('using custom views', function() {
 
     it('multi-year default only displays year', function() {
-      $('#cal').fullCalendar({
+      initCalendar({
         views: {
           multiYear: {
             type: 'basic',
@@ -116,7 +112,7 @@ describe('titleFormat', function() {
     })
 
     it('multi-month default only displays month/year', function() {
-      $('#cal').fullCalendar({
+      initCalendar({
         views: {
           multiMonth: {
             type: 'basic',
@@ -131,7 +127,7 @@ describe('titleFormat', function() {
     })
 
     it('multi-week default displays short full date', function() {
-      $('#cal').fullCalendar({
+      initCalendar({
         views: {
           multiWeek: {
             type: 'basic',
@@ -146,7 +142,7 @@ describe('titleFormat', function() {
     })
 
     it('multi-day default displays short full date', function() {
-      $('#cal').fullCalendar({
+      initCalendar({
         views: {
           multiDay: {
             type: 'basic',
@@ -164,7 +160,7 @@ describe('titleFormat', function() {
   describe('when not all days are shown', function() {
 
     it('doesn\'t include hidden days in the title', function() {
-      $('#cal').fullCalendar({
+      initCalendar({
         defaultView: 'agendaWeek',
         defaultDate: '2017-02-13',
         weekends: false,

+ 30 - 32
tests/automated/legacy/unselectAuto.js

@@ -1,43 +1,40 @@
-
 describe('unselectAuto', function() {
   var View = FullCalendar.View
-  var options
+
+  pushOptions({
+    selectable: true,
+    defaultDate: '2014-12-25',
+    defaultView: 'month'
+  })
 
   beforeEach(function() {
-    options = {
-      selectable: true,
-      defaultDate: '2014-12-25',
-      defaultView: 'month'
-    }
-    $('<div id="cal" />').appendTo('body')
     $('<div id="otherthing" />').appendTo('body')
   })
 
   afterEach(function() {
-    $('#cal').fullCalendar('destroy')
-    $('#cal').remove()
     $('#otherthing').remove()
   })
 
   describe('when enabled', function() {
 
-    beforeEach(function() {
-      options.unselectAuto = true
+    pushOptions({
+      unselectAuto: true
     })
 
     describe('when clicking away', function() {
       it('unselects the current selection when clicking elsewhere in DOM', function(done) {
-        options.unselect = function(ev, view) {
-          expect($('.fc-highlight').length).toBe(0)
 
-          expect('currentTarget' in ev).toBe(true) // a JS event
-          expect(view instanceof View).toBe(true)
+        initCalendar({
+          unselect: function(ev, view) {
+            expect($('.fc-highlight').length).toBe(0)
 
-          done()
-        }
+            expect('currentTarget' in ev).toBe(true) // a JS event
+            expect(view instanceof View).toBe(true)
 
-        $('#cal').fullCalendar(options)
-        $('#cal').fullCalendar('select', '2014-12-01', '2014-12-03')
+            done()
+          }
+        })
+        currentCalendar.select('2014-12-01', '2014-12-03')
 
         expect($('.fc-highlight').length).toBeGreaterThan(0)
 
@@ -50,17 +47,18 @@ describe('unselectAuto', function() {
 
     describe('when clicking another date', function() {
       it('unselects the current selection when clicking elsewhere in DOM', function(done) {
-        options.unselect = function(ev, view) {
-          expect($('.fc-highlight').length).toBe(0)
 
-          expect('currentTarget' in ev).toBe(true) // a JS event
-          expect(view instanceof View).toBe(true)
+        initCalendar({
+          unselect: function(ev, view) {
+            expect($('.fc-highlight').length).toBe(0)
 
-          done()
-        }
+            expect('currentTarget' in ev).toBe(true) // a JS event
+            expect(view instanceof View).toBe(true)
 
-        $('#cal').fullCalendar(options)
-        $('#cal').fullCalendar('select', '2014-12-01', '2014-12-03')
+            done()
+          }
+        })
+        currentCalendar.select('2014-12-01', '2014-12-03')
 
         expect($('.fc-highlight').length).toBeGreaterThan(0)
 
@@ -71,13 +69,13 @@ describe('unselectAuto', function() {
 
   describe('when disabled', function() {
 
-    beforeEach(function() {
-      options.unselectAuto = false
+    pushOptions({
+      unselectAuto: false
     })
 
     it('keeps current selection when clicking elsewhere in DOM', function() {
-      $('#cal').fullCalendar(options)
-      $('#cal').fullCalendar('select', '2014-12-01', '2014-12-03')
+      initCalendar()
+      currentCalendar.select('2014-12-01', '2014-12-03')
 
       expect($('.fc-highlight').length).toBeGreaterThan(0)
 

+ 52 - 33
tests/automated/legacy/views-specific-options.js

@@ -1,32 +1,31 @@
 describe('view-specific options', function() {
-  var options
 
-  beforeEach(function() {
-    options = {
-      header: {
-        left: 'prev,next',
-        center: 'title',
-        right: 'month,basicWeek,basicDay,agendaWeek,agendaDay'
-      },
-      defaultView: 'month',
-      titleFormat: '[default]',
-      views: { }
-    }
-    affix('#cal')
+  pushOptions({
+    header: {
+      left: 'prev,next',
+      center: 'title',
+      right: 'month,basicWeek,basicDay,agendaWeek,agendaDay'
+    },
+    defaultView: 'month',
+    titleFormat: '[default]',
+    views: { }
   })
 
   function testEachView(viewsAndVals) {
-    $('#cal').fullCalendar(options)
     $.each(viewsAndVals, function(view, val) {
-      $('#cal').fullCalendar('changeView', view)
+      currentCalendar.changeView(view)
       expect($('h2')).toHaveText(val)
     })
   }
 
   it('can target a specific view (month)', function() {
-    options.views.month = {
-      titleFormat: '[special!!!]'
-    }
+    initCalendar({
+      views: {
+        month: {
+          titleFormat: '[special!!!]'
+        }
+      }
+    })
     testEachView({
       month: 'special!!!',
       basicWeek: 'default',
@@ -37,9 +36,13 @@ describe('view-specific options', function() {
   })
 
   it('can target a specific view (agendaWeek)', function() {
-    options.views.agendaWeek = {
-      titleFormat: '[special!!!]'
-    }
+    initCalendar({
+      views: {
+        agendaWeek: {
+          titleFormat: '[special!!!]'
+        }
+      }
+    })
     testEachView({
       month: 'default',
       basicWeek: 'default',
@@ -50,9 +53,13 @@ describe('view-specific options', function() {
   })
 
   it('can target basic views', function() {
-    options.views.basic = {
-      titleFormat: '[special!!!]'
-    }
+    initCalendar({
+      views: {
+        basic: {
+          titleFormat: '[special!!!]'
+        }
+      }
+    })
     testEachView({
       month: 'default', // will NOT target month view
       basicWeek: 'special!!!',
@@ -63,9 +70,13 @@ describe('view-specific options', function() {
   })
 
   it('can target agenda views', function() {
-    options.views.agenda = {
-      titleFormat: '[special!!!]'
-    }
+    initCalendar({
+      views: {
+        agenda: {
+          titleFormat: '[special!!!]'
+        }
+      }
+    })
     testEachView({
       month: 'default',
       basicWeek: 'default',
@@ -76,9 +87,13 @@ describe('view-specific options', function() {
   })
 
   it('can target week views', function() {
-    options.views.week = {
-      titleFormat: '[special!!!]'
-    }
+    initCalendar({
+      views: {
+        week: {
+          titleFormat: '[special!!!]'
+        }
+      }
+    })
     testEachView({
       month: 'default',
       basicWeek: 'special!!!',
@@ -89,9 +104,13 @@ describe('view-specific options', function() {
   })
 
   it('can target day views', function() {
-    options.views.day = {
-      titleFormat: '[special!!!]'
-    }
+    initCalendar({
+      views: {
+        day: {
+          titleFormat: '[special!!!]'
+        }
+      }
+    })
     testEachView({
       month: 'default',
       basicWeek: 'default',

+ 16 - 18
tests/automated/legacy/weekNumberTitle.js

@@ -1,12 +1,7 @@
 describe('weekNumberTitle', function() {
 
-  var options
-
-  beforeEach(function() {
-    affix('#cal')
-    options = {
-      weekNumbers: true
-    }
+  pushOptions({
+    weekNumbers: true
   })
 
   function getRenderedWeekNumberTitle() {
@@ -18,32 +13,35 @@ describe('weekNumberTitle', function() {
   [ 'basicWeek', 'agendaWeek' ].forEach(function(viewName) {
     describe('when views is ' + viewName, function() {
 
-      beforeEach(function() {
-        options.defaultView = viewName
+      pushOptions({
+        defaultView: viewName
       })
 
       it('renders correctly by default', function() {
-        $('#cal').fullCalendar(options)
+        initCalendar()
         expect(getRenderedWeekNumberTitle()).toBe('W')
       })
 
       it('renders correctly when unspecified and when locale is customized', function() {
-        options.locale = 'es'
-        $('#cal').fullCalendar(options)
+        initCalendar({
+          locale: 'es'
+        })
         expect(getRenderedWeekNumberTitle()).toBe('Sm')
       })
 
       it('renders correctly when customized and LTR', function() {
-        options.isRTL = false
-        options.weekNumberTitle = 'YO'
-        $('#cal').fullCalendar(options)
+        initCalendar({
+          isRTL: false,
+          weekNumberTitle: 'YO'
+        })
         expect(getRenderedWeekNumberTitle()).toBe('YO')
       })
 
       it('renders correctly when customized and RTL', function() {
-        options.isRTL = true
-        options.weekNumberTitle = 'YO'
-        $('#cal').fullCalendar(options)
+        initCalendar({
+          isRTL: true,
+          weekNumberTitle: 'YO'
+        })
         expect(getRenderedWeekNumberTitle()).toBe('YO')
       })
     })

+ 85 - 44
tests/automated/legacy/weekNumbers.js

@@ -1,30 +1,27 @@
-
 describe('weekNumbers', function() {
 
-  var options
   var counts
 
   beforeEach(function() {
-    affix('#cal')
     counts = {}
-    options = {}
   })
 
   afterEach(function() {
-    $('#cal').fullCalendar('destroy')
+    currentCalendar.destroy()
   })
 
   describe('when using month view', function() {
 
-    beforeEach(function() {
-      options.defaultView = 'month'
-      options.fixedWeekCount = true // will make 6 rows
+    pushOptions({
+      defaultView: 'month',
+      fixedWeekCount: true // will make 6 rows
     })
 
     describe('with default weekNumbers', function() { // which is false!
 
       describe('and default weekNumbersWithinDays', function() {
         it('should not display week numbers at all', function() {
+          initCalendar()
           counts = getCounts()
           expect(counts.allWeekNumbers).toEqual(0)
         })
@@ -32,7 +29,9 @@ describe('weekNumbers', function() {
 
       describe('and weekNumbersWithinDays set to false', function() {
         it('should not display week numbers at all', function() {
-          options.weekNumbersWithinDays = false
+          initCalendar({
+            weekNumbersWithinDays: false
+          })
           counts = getCounts()
           expect(counts.allWeekNumbers).toEqual(0)
         })
@@ -40,7 +39,9 @@ describe('weekNumbers', function() {
 
       describe('and weekNumbersWithinDays set to true', function() {
         it('should not display week numbers at all', function() {
-          options.weekNumbersWithinDays = true
+          initCalendar({
+            weekNumbersWithinDays: true
+          })
           counts = getCounts()
           expect(counts.allWeekNumbers).toEqual(0)
         })
@@ -50,12 +51,15 @@ describe('weekNumbers', function() {
 
     describe('with weekNumbers to false', function() {
 
-      beforeEach(function() {
-        options.weekNumbers = false
+      pushOptions({
+        weekNumbers: false
       })
 
       describe('and default weekNumbersWithinDays', function() {
         it('should not display week numbers at all', function() {
+          initCalendar({
+            weekNumbersWithinDays: true
+          })
           counts = getCounts()
           expect(counts.allWeekNumbers).toEqual(0)
         })
@@ -63,7 +67,9 @@ describe('weekNumbers', function() {
 
       describe('and weekNumbersWithinDays set to false', function() {
         it('should not display week numbers at all', function() {
-          options.weekNumbersWithinDays = false
+          initCalendar({
+            weekNumbersWithinDays: false
+          })
           counts = getCounts()
           expect(counts.allWeekNumbers).toEqual(0)
         })
@@ -71,7 +77,9 @@ describe('weekNumbers', function() {
 
       describe('and weekNumbersWithinDays set to true', function() {
         it('should not display week numbers at all', function() {
-          options.weekNumbersWithinDays = true
+          initCalendar({
+            weekNumbersWithinDays: true
+          })
           counts = getCounts()
           expect(counts.allWeekNumbers).toEqual(0)
         })
@@ -81,12 +89,13 @@ describe('weekNumbers', function() {
 
     describe('with weekNumbers to true', function() {
 
-      beforeEach(function() {
-        options.weekNumbers = true
+      pushOptions({
+        weekNumbers: true
       })
 
       describe('and default weekNumbersWithinDays', function() {
         it('should display week numbers along the side only', function() {
+          initCalendar()
           counts = getCounts()
           // TODO: Is it possible to remove class fc-week-number from
           // headers and fillers, bringing allWeekNumbers down to 6?
@@ -98,7 +107,9 @@ describe('weekNumbers', function() {
 
       describe('and weekNumbersWithinDays set to false', function() {
         it('should display week numbers along the side only', function() {
-          options.weekNumbersWithinDays = false
+          initCalendar({
+            weekNumbersWithinDays: false
+          })
           counts = getCounts()
           // TODO: Is it possible to remove class fc-week-number from
           // headers and fillers, bringing allWeekNumbers down to 6?
@@ -110,7 +121,9 @@ describe('weekNumbers', function() {
 
       describe('and weekNumbersWithinDays set to true', function() {
         it('should display week numbers in the day cells only', function() {
-          options.weekNumbersWithinDays = true
+          initCalendar({
+            weekNumbersWithinDays: true
+          })
           counts = getCounts()
           expect(counts.colWeekNumbers).toEqual(0)
           expect(counts.cellWeekNumbers).toEqual(6)
@@ -124,14 +137,15 @@ describe('weekNumbers', function() {
 
   describe('when using basicWeek view', function() {
 
-    beforeEach(function() {
-      options.defaultView = 'basicWeek'
+    pushOptions({
+      defaultView: 'basicWeek'
     })
 
     describe('with default weekNumbers', function() {
 
       describe('and default weekNumbersWithinDays', function() {
         it('should not display week numbers at all', function() {
+          initCalendar()
           counts = getCounts()
           expect(counts.allWeekNumbers).toEqual(0)
         })
@@ -139,7 +153,9 @@ describe('weekNumbers', function() {
 
       describe('and weekNumbersWithinDays set to false', function() {
         it('should not display week numbers at all', function() {
-          options.weekNumbersWithinDays = false
+          initCalendar({
+            weekNumbersWithinDays: false
+          })
           counts = getCounts()
           expect(counts.allWeekNumbers).toEqual(0)
         })
@@ -147,7 +163,9 @@ describe('weekNumbers', function() {
 
       describe('and weekNumbersWithinDays set to true', function() {
         it('should not display week numbers at all', function() {
-          options.weekNumbersWithinDays = true
+          initCalendar({
+            weekNumbersWithinDays: true
+          })
           counts = getCounts()
           expect(counts.allWeekNumbers).toEqual(0)
         })
@@ -157,12 +175,13 @@ describe('weekNumbers', function() {
 
     describe('with weekNumbers to false', function() {
 
-      beforeEach(function() {
-        options.weekNumbers = false
+      pushOptions({
+        weekNumbers: false
       })
 
       describe('and default weekNumbersWithinDays', function() {
         it('should not display week numbers at all', function() {
+          initCalendar()
           counts = getCounts()
           expect(counts.allWeekNumbers).toEqual(0)
         })
@@ -170,7 +189,9 @@ describe('weekNumbers', function() {
 
       describe('and weekNumbersWithinDays set to false', function() {
         it('should not display week numbers at all', function() {
-          options.weekNumbersWithinDays = false
+          initCalendar({
+            weekNumbersWithinDays: false
+          })
           counts = getCounts()
           expect(counts.allWeekNumbers).toEqual(0)
         })
@@ -178,7 +199,9 @@ describe('weekNumbers', function() {
 
       describe('and weekNumbersWithinDays set to true', function() {
         it('should not display week numbers at all', function() {
-          options.weekNumbersWithinDays = true
+          initCalendar({
+            weekNumbersWithinDays: true
+          })
           counts = getCounts()
           expect(counts.allWeekNumbers).toEqual(0)
         })
@@ -188,12 +211,13 @@ describe('weekNumbers', function() {
 
     describe('with weekNumbers to true', function() {
 
-      beforeEach(function() {
-        options.weekNumbers = true
+      pushOptions({
+        weekNumbers: true
       })
 
       describe('and default weekNumbersWithinDays', function() {
         it('should display week numbers along the side only', function() {
+          initCalendar()
           counts = getCounts()
           // TODO: Is it possible to remove class fc-week-number from
           // headers and fillers, bringing allWeekNumbers down to 1?
@@ -205,7 +229,9 @@ describe('weekNumbers', function() {
 
       describe('and weekNumbersWithinDays set to false', function() {
         it('should display week numbers along the side only', function() {
-          options.weekNumbersWithinDays = false
+          initCalendar({
+            weekNumbersWithinDays: false
+          })
           counts = getCounts()
           // TODO: Is it possible to remove class fc-week-number from
           // headers and fillers, bringing allWeekNumbers down to 1?
@@ -217,7 +243,9 @@ describe('weekNumbers', function() {
 
       describe('and weekNumbersWithinDays set to true', function() {
         it('should display week numbers in the day cells only', function() {
-          options.weekNumbersWithinDays = true
+          initCalendar({
+            weekNumbersWithinDays: true
+          })
           counts = getCounts()
           expect(counts.colWeekNumbers).toEqual(0)
           expect(counts.cellWeekNumbers).toEqual(1)
@@ -231,14 +259,15 @@ describe('weekNumbers', function() {
 
   describe('when using an agenda view', function() {
 
-    beforeEach(function() {
-      options.defaultView = 'agendaWeek'
+    pushOptions({
+      defaultView: 'agendaWeek'
     })
 
     describe('with default weekNumbers', function() {
 
       describe('and default weekNumbersWithinDays', function() {
         it('should not display week numbers at all', function() {
+          initCalendar()
           counts = getCounts()
           expect(counts.allWeekNumbers).toEqual(0)
         })
@@ -246,7 +275,9 @@ describe('weekNumbers', function() {
 
       describe('and weekNumbersWithinDays set to false', function() {
         it('should not display week numbers at all', function() {
-          options.weekNumbersWithinDays = false
+          initCalendar({
+            weekNumbersWithinDays: false
+          })
           counts = getCounts()
           expect(counts.allWeekNumbers).toEqual(0)
         })
@@ -254,7 +285,9 @@ describe('weekNumbers', function() {
 
       describe('and weekNumbersWithinDays set to true', function() {
         it('should not display week numbers at all', function() {
-          options.weekNumbersWithinDays = true
+          initCalendar({
+            weekNumbersWithinDays: true
+          })
           counts = getCounts()
           expect(counts.allWeekNumbers).toEqual(0)
         })
@@ -264,12 +297,13 @@ describe('weekNumbers', function() {
 
     describe('with weekNumbers to false', function() {
 
-      beforeEach(function() {
-        options.weekNumbers = false
+      pushOptions({
+        weekNumbers: false
       })
 
       describe('and default weekNumbersWithinDays', function() {
         it('should not display week numbers at all', function() {
+          initCalendar()
           counts = getCounts()
           expect(counts.allWeekNumbers).toEqual(0)
         })
@@ -277,7 +311,9 @@ describe('weekNumbers', function() {
 
       describe('and weekNumbersWithinDays set to false', function() {
         it('should not display week numbers at all', function() {
-          options.weekNumbersWithinDays = false
+          initCalendar({
+            weekNumbersWithinDays: false
+          })
           counts = getCounts()
           expect(counts.allWeekNumbers).toEqual(0)
         })
@@ -285,7 +321,9 @@ describe('weekNumbers', function() {
 
       describe('and weekNumbersWithinDays set to true', function() {
         it('should not display week numbers at all', function() {
-          options.weekNumbersWithinDays = true
+          initCalendar({
+            weekNumbersWithinDays: true
+          })
           counts = getCounts()
           expect(counts.allWeekNumbers).toEqual(0)
         })
@@ -295,12 +333,13 @@ describe('weekNumbers', function() {
 
     describe('with weekNumbers to true', function() {
 
-      beforeEach(function() {
-        options.weekNumbers = true
+      pushOptions({
+        weekNumbers: true
       })
 
       describe('and default weekNumbersWithinDays', function() {
         it('should display week numbers in the top left corner only', function() {
+          initCalendar()
           counts = getCounts()
           expect(counts.allWeekNumbers).toEqual(1)
           expect(counts.colWeekNumbers).toEqual(0)
@@ -311,7 +350,9 @@ describe('weekNumbers', function() {
 
       describe('and weekNumbersWithinDays set to false', function() {
         it('should display week numbers in the top left corner only', function() {
-          options.weekNumbersWithinDays = false
+          initCalendar({
+            weekNumbersWithinDays: false
+          })
           counts = getCounts()
           expect(counts.allWeekNumbers).toEqual(1)
           expect(counts.colWeekNumbers).toEqual(0)
@@ -322,7 +363,9 @@ describe('weekNumbers', function() {
 
       describe('and weekNumbersWithinDays set to true', function() {
         it('should display week numbers in the top left corner only', function() {
-          options.weekNumbersWithinDays = true
+          initCalendar({
+            weekNumbersWithinDays: true
+          })
           counts = getCounts()
           expect(counts.allWeekNumbers).toEqual(1)
           expect(counts.colWeekNumbers).toEqual(0)
@@ -338,8 +381,6 @@ describe('weekNumbers', function() {
   function getCounts() {
     var t = {}
 
-    $('#cal').fullCalendar(options)
-
     t.allWeekNumbers = $('.fc-week-number').length
     t.colWeekNumbers = $('.fc-content-skeleton thead td.fc-week-number').length
     t.cellWeekNumbers = $('.fc-content-skeleton thead .fc-day-top span.fc-week-number').length