Explorar o código

Merge branch 'jquery-removal' into datelib

Adam Shaw %!s(int64=7) %!d(string=hai) anos
pai
achega
f10167920e
Modificáronse 31 ficheiros con 679 adicións e 761 borrados
  1. 0 4
      karma.config.js
  2. 5 11
      package-lock.json
  3. 0 1
      package.json
  4. 0 1
      tasks/lint.js
  5. 0 7
      tests/automated/hacks.js
  6. 17 23
      tests/automated/legacy/dayNames.js
  7. 10 15
      tests/automated/legacy/dayNamesShort.js
  8. 8 9
      tests/automated/legacy/event-dnd.js
  9. 36 37
      tests/automated/legacy/events-gcal.js
  10. 29 23
      tests/automated/legacy/external-dnd-advanced.js
  11. 14 13
      tests/automated/legacy/external-dnd.js
  12. 33 58
      tests/automated/legacy/firstDay.js
  13. 18 22
      tests/automated/legacy/footer-navigation.js
  14. 19 20
      tests/automated/legacy/header-navigation.js
  15. 0 1
      tests/automated/legacy/height-and-contentHeight.js
  16. 7 13
      tests/automated/legacy/hiddenDays.js
  17. 0 4
      tests/automated/legacy/overlap.js
  18. 49 52
      tests/automated/legacy/refetchEventSources.js
  19. 65 61
      tests/automated/legacy/removeEventSource.js
  20. 12 13
      tests/automated/legacy/select-callback.js
  21. 30 35
      tests/automated/legacy/select-method.js
  22. 14 23
      tests/automated/legacy/template.js.txt
  23. 8 10
      tests/automated/legacy/theme.js
  24. 34 34
      tests/automated/legacy/timeFormat.js
  25. 74 77
      tests/automated/legacy/timezone.js
  26. 14 22
      tests/automated/legacy/titleFormat.js
  27. 30 32
      tests/automated/legacy/unselectAuto.js
  28. 52 33
      tests/automated/legacy/views-specific-options.js
  29. 16 18
      tests/automated/legacy/weekNumberTitle.js
  30. 85 44
      tests/automated/legacy/weekNumbers.js
  31. 0 45
      tests/automated/lib/fullcalendar-jquery-plugin.js

+ 0 - 4
karma.config.js

@@ -29,9 +29,6 @@ module.exports = function(config) {
       'dist/jquery-ui-draggable.js',
       'dist/jquery-ui-draggable.js',
       'dist/locale-all.js',
       'dist/locale-all.js',
 
 
-      // temporary. needs to go first.
-      'tests/automated/lib/fullcalendar-jquery-plugin.js',
-
       // a way to dump variables into the test environment
       // a way to dump variables into the test environment
       'tmp/automated-test-config.js',
       'tmp/automated-test-config.js',
 
 
@@ -42,7 +39,6 @@ module.exports = function(config) {
       'node_modules/xhr-mock/dist/xhr-mock.js', // TODO: should include this via require(), but .d.ts problems
       'node_modules/xhr-mock/dist/xhr-mock.js', // TODO: should include this via require(), but .d.ts problems
       'node_modules/native-promise-only/lib/npo.src.js',
       'node_modules/native-promise-only/lib/npo.src.js',
       'node_modules/jasmine-jquery/lib/jasmine-jquery.js',
       'node_modules/jasmine-jquery/lib/jasmine-jquery.js',
-      'node_modules/jasmine-fixture/dist/jasmine-fixture.js',
       'node_modules/jquery-simulate/jquery.simulate.js',
       'node_modules/jquery-simulate/jquery.simulate.js',
 
 
       'tests/automated/base.css',
       'tests/automated/base.css',

+ 5 - 11
package-lock.json

@@ -13,7 +13,7 @@
     "abbrev": {
     "abbrev": {
       "version": "1.1.1",
       "version": "1.1.1",
       "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
       "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
-      "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==",
+      "integrity": "sha1-+PLIh60Qv2f2NPAFtph/7TF5qsg=",
       "dev": true
       "dev": true
     },
     },
     "accepts": {
     "accepts": {
@@ -288,7 +288,7 @@
     "aproba": {
     "aproba": {
       "version": "1.2.0",
       "version": "1.2.0",
       "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz",
       "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz",
-      "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==",
+      "integrity": "sha1-aALmJk79GMeQobDVF/DyYnvyyUo=",
       "dev": true
       "dev": true
     },
     },
     "archy": {
     "archy": {
@@ -5824,12 +5824,6 @@
       "integrity": "sha1-b2G9eQYeJ/Q+b5NV5Es8bKtv8pc=",
       "integrity": "sha1-b2G9eQYeJ/Q+b5NV5Es8bKtv8pc=",
       "dev": true
       "dev": true
     },
     },
-    "jasmine-fixture": {
-      "version": "2.0.0",
-      "resolved": "https://registry.npmjs.org/jasmine-fixture/-/jasmine-fixture-2.0.0.tgz",
-      "integrity": "sha1-ttDFo7tINNI90TdGTvlvBPk7vWA=",
-      "dev": true
-    },
     "jasmine-jquery": {
     "jasmine-jquery": {
       "version": "2.1.1",
       "version": "2.1.1",
       "resolved": "https://registry.npmjs.org/jasmine-jquery/-/jasmine-jquery-2.1.1.tgz",
       "resolved": "https://registry.npmjs.org/jasmine-jquery/-/jasmine-jquery-2.1.1.tgz",
@@ -5849,7 +5843,7 @@
     "js-base64": {
     "js-base64": {
       "version": "2.4.3",
       "version": "2.4.3",
       "resolved": "https://registry.npmjs.org/js-base64/-/js-base64-2.4.3.tgz",
       "resolved": "https://registry.npmjs.org/js-base64/-/js-base64-2.4.3.tgz",
-      "integrity": "sha512-H7ErYLM34CvDMto3GbD6xD0JLUGYXR3QTcH6B/tr4Hi/QpSThnCsIp+Sy5FRTw3B0d6py4HcNkW7nO/wdtGWEw==",
+      "integrity": "sha1-LlRewrDylX9BNWUQIFIU6Y+tZYI=",
       "dev": true
       "dev": true
     },
     },
     "js-tokens": {
     "js-tokens": {
@@ -7131,7 +7125,7 @@
     "npmlog": {
     "npmlog": {
       "version": "4.1.2",
       "version": "4.1.2",
       "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz",
       "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz",
-      "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==",
+      "integrity": "sha1-CKfyqL9zRgR3mp76StXMcXq7lUs=",
       "dev": true,
       "dev": true,
       "requires": {
       "requires": {
         "are-we-there-yet": "1.1.4",
         "are-we-there-yet": "1.1.4",
@@ -11134,7 +11128,7 @@
     "wide-align": {
     "wide-align": {
       "version": "1.1.2",
       "version": "1.1.2",
       "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.2.tgz",
       "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.2.tgz",
-      "integrity": "sha512-ijDLlyQ7s6x1JgCLur53osjm/UXUYD9+0PbYKrBsYisYXzCxN+HC3mYDNy/dWdmf3AwqwU3CXwDCvsNgGK1S0w==",
+      "integrity": "sha1-Vx4PGwYEY268DfwhsDObvjE0FxA=",
       "dev": true,
       "dev": true,
       "requires": {
       "requires": {
         "string-width": "1.0.2"
         "string-width": "1.0.2"

+ 0 - 1
package.json

@@ -56,7 +56,6 @@
     "gulp-watch": "^4.3.11",
     "gulp-watch": "^4.3.11",
     "gulp-zip": "^3.2.0",
     "gulp-zip": "^3.2.0",
     "jasmine-core": "2.5.2",
     "jasmine-core": "2.5.2",
-    "jasmine-fixture": "^2.0.0",
     "jasmine-jquery": "^2.1.1",
     "jasmine-jquery": "^2.1.1",
     "jquery": "^3.3.1",
     "jquery": "^3.3.1",
     "jquery-simulate": "github:jquery/jquery-simulate",
     "jquery-simulate": "github:jquery/jquery-simulate",

+ 0 - 1
tasks/lint.js

@@ -77,7 +77,6 @@ gulp.task('lint:js:tests', function() {
           'describeTimezones',
           'describeTimezones',
           'describeValues',
           'describeValues',
           'pit',
           'pit',
-          'affix',
           'getCurrentOptions',
           'getCurrentOptions',
           'initCalendar',
           'initCalendar',
           'currentCalendar',
           'currentCalendar',

+ 0 - 7
tests/automated/hacks.js

@@ -13,10 +13,3 @@ beforeEach(function() {
   jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000
   jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000
 
 
 })
 })
-
-
-// Destroy all calendars afterwards, to prevent memory leaks
-// (not the best place for this)
-afterEach(function() {
-  $('.fc').fullCalendar('destroy')
-})

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

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

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

@@ -1,5 +1,4 @@
 describe('short day names', function() {
 describe('short day names', function() {
-  var settings = {}
   var testableClasses = [
   var testableClasses = [
     'month',
     'month',
     'agendaWeek',
     'agendaWeek',
@@ -16,27 +15,21 @@ describe('short day names', function() {
   ]
   ]
   var locales = [ 'es', 'fr', 'de', 'zh-cn', 'es' ]
   var locales = [ 'es', 'fr', 'de', 'zh-cn', 'es' ]
 
 
-  beforeEach(function() {
-    affix('#cal')
-    settings = { }
-  })
-
   afterEach(function() {
   afterEach(function() {
     moment.locale('en') // reset moment's global locale
     moment.locale('en') // reset moment's global locale
   })
   })
 
 
   testableClasses.forEach(function(viewClass, index, viewClasses) {
   testableClasses.forEach(function(viewClass, index, viewClasses) {
     describe('when view is ' + viewClass, function() {
     describe('when view is ' + viewClass, function() {
-      beforeEach(function() {
-        settings.defaultView = viewClass
+      pushOptions({
+        defaultView: viewClass
       })
       })
-
       describe('when locale is default', function() {
       describe('when locale is default', function() {
         it('should be in English', function() {
         it('should be in English', function() {
           moment.locale('en')
           moment.locale('en')
-          $('#cal').fullCalendar(settings)
-          var weekdays = moment.weekdaysShort()
+          initCalendar()
 
 
+          var weekdays = moment.weekdaysShort()
           dayClasses.forEach(function(cls, index, classes) {
           dayClasses.forEach(function(cls, index, classes) {
             expect($('.fc-view thead ' + cls)[0]).toContainText(weekdays[index])
             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() {
       describe('when locale is not default', function() {
         locales.forEach(function(locale, index, locales) {
         locales.forEach(function(locale, index, locales) {
           it('should be in the selected locale', function() {
           it('should be in the selected locale', function() {
-            settings.locale = locale
-            $('#cal').fullCalendar(settings)
+            initCalendar({
+              locale: locale
+            })
 
 
             moment.locale(locale)
             moment.locale(locale)
             var weekdays = moment.weekdaysShort()
             var weekdays = moment.weekdaysShort()
@@ -64,8 +58,9 @@ describe('short day names', function() {
           var days = [
           var days = [
             'Hov.', 'maS.', 'veS.', 'mech.', 'parmaq.', 'HoS.'
             'Hov.', 'maS.', 'veS.', 'mech.', 'parmaq.', 'HoS.'
           ]
           ]
-          settings.dayNamesShort = days
-          $('#cal').fullCalendar(settings)
+          initCalendar({
+            dayNamesShort: days
+          })
 
 
           dayClasses.forEach(function(cls, index, classes) {
           dayClasses.forEach(function(cls, index, classes) {
             expect($('.fc-view thead ' + cls)[0]).toContainText(days[index])
             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,
       dragScroll: false,
       longPressDelay: 100
       longPressDelay: 100
     }
     }
-    affix('#cal')
   })
   })
 
 
   afterEach(function() {
   afterEach(function() {
-    $('#cal').fullCalendar('destroy')
+    currentCalendar.destroy()
   })
   })
 
 
   describe('when in month view', function() {
   describe('when in month view', function() {
@@ -54,7 +53,7 @@ describe('eventDrop', function() {
                 expect(event.end).toBeNull()
                 expect(event.end).toBeNull()
 
 
                 revertFunc()
                 revertFunc()
-                event = $('#cal').fullCalendar('clientEvents')[0]
+                event = currentCalendar.clientEvents()[0]
 
 
                 expect(event.start).toEqualMoment('2014-06-11')
                 expect(event.start).toEqualMoment('2014-06-11')
                 expect(event.end).toBeNull()
                 expect(event.end).toBeNull()
@@ -93,7 +92,7 @@ describe('eventDrop', function() {
             expect(event.end).toBeNull()
             expect(event.end).toBeNull()
 
 
             revertFunc()
             revertFunc()
-            event = $('#cal').fullCalendar('clientEvents')[0]
+            event = currentCalendar.clientEvents()[0]
 
 
             expect(event.start).toEqualMoment('2014-06-11T06:00:00')
             expect(event.start).toEqualMoment('2014-06-11T06:00:00')
             expect(event.end).toBeNull()
             expect(event.end).toBeNull()
@@ -189,7 +188,7 @@ describe('eventDrop', function() {
                 expect(event.end).toBeNull()
                 expect(event.end).toBeNull()
 
 
                 revertFunc()
                 revertFunc()
-                event = $('#cal').fullCalendar('clientEvents')[0]
+                event = currentCalendar.clientEvents()[0]
 
 
                 expect(event.start).toEqualMoment('2014-06-11T06:00:00')
                 expect(event.start).toEqualMoment('2014-06-11T06:00:00')
                 expect(event.end).toBeNull()
                 expect(event.end).toBeNull()
@@ -227,7 +226,7 @@ describe('eventDrop', function() {
             expect(event.end).toBeNull()
             expect(event.end).toBeNull()
 
 
             revertFunc()
             revertFunc()
-            event = $('#cal').fullCalendar('clientEvents')[0]
+            event = currentCalendar.clientEvents()[0]
 
 
             expect(event.start).toEqualMoment('2014-06-11')
             expect(event.start).toEqualMoment('2014-06-11')
             expect(event.end).toBeNull()
             expect(event.end).toBeNull()
@@ -269,7 +268,7 @@ describe('eventDrop', function() {
             expect(event.allDay).toBe(false)
             expect(event.allDay).toBe(false)
 
 
             revertFunc()
             revertFunc()
-            event = $('#cal').fullCalendar('clientEvents')[0]
+            event = currentCalendar.clientEvents()[0]
 
 
             expect(event.start).toEqualMoment('2014-06-11')
             expect(event.start).toEqualMoment('2014-06-11')
             expect(event.end).toBeNull()
             expect(event.end).toBeNull()
@@ -325,7 +324,7 @@ describe('eventDrop', function() {
             expect(event.allDay).toBe(true)
             expect(event.allDay).toBe(true)
 
 
             revertFunc()
             revertFunc()
-            event = $('#cal').fullCalendar('clientEvents')[0]
+            event = currentCalendar.clientEvents()[0]
 
 
             expect(event.start).toEqualMoment('2014-06-11T01:00:00')
             expect(event.start).toEqualMoment('2014-06-11T01:00:00')
             expect(event.end).toBeNull()
             expect(event.end).toBeNull()
@@ -447,7 +446,7 @@ describe('eventDrop', function() {
     spyOn(options, 'eventDragStop').and.callThrough()
     spyOn(options, 'eventDragStop').and.callThrough()
 
 
     setTimeout(function() { // hack. agenda view scroll state would get messed up between tests
     setTimeout(function() { // hack. agenda view scroll state would get messed up between tests
-      $('#cal').fullCalendar(options)
+      initCalendar(options)
     }, 0)
     }, 0)
   }
   }
 })
 })

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

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

+ 29 - 23
tests/automated/legacy/external-dnd-advanced.js

@@ -1,18 +1,24 @@
 import { testEventDrag } from '../lib/dnd-resize-utils'
 import { testEventDrag } from '../lib/dnd-resize-utils'
 
 
 describe('advanced external dnd', function() {
 describe('advanced external dnd', function() {
+  var dragEl
 
 
   beforeEach(function() {
   beforeEach(function() {
-    affix('.drag')
-    $('.drag')
-      .text('yo')
+    dragEl = $('<div class="drag">yo</div>')
       .css({
       .css({
         width: 200,
         width: 200,
         background: 'blue',
         background: 'blue',
         color: 'white'
         color: 'white'
       })
       })
+      .appendTo('body')
       .draggable()
       .draggable()
   })
   })
+
+  afterEach(function() {
+    dragEl.remove()
+    dragEl = null
+  })
+
   pushOptions({
   pushOptions({
     defaultDate: '2014-11-13',
     defaultDate: '2014-11-13',
     scrollTime: '00:00:00',
     scrollTime: '00:00:00',
@@ -28,7 +34,7 @@ describe('advanced external dnd', function() {
       })
       })
       describe('when given duration through data-duration', function() {
       describe('when given duration through data-duration', function() {
         beforeEach(function() {
         beforeEach(function() {
-          $('.drag').data('duration', '2:30')
+          dragEl.data('duration', '2:30')
         })
         })
         defineTests()
         defineTests()
       })
       })
@@ -104,26 +110,26 @@ describe('advanced external dnd', function() {
       it('fires correctly', function(done) {
       it('fires correctly', function(done) {
         var options = {}
         var options = {}
 
 
-        $('.drag').data('event', { title: 'hey' })
+        dragEl.data('event', { title: 'hey' })
         testExternalEventDrag(options, '2014-11-13T02:00:00', true, done)
         testExternalEventDrag(options, '2014-11-13T02:00:00', true, done)
       })
       })
 
 
       describe('when given a start time', function() {
       describe('when given a start time', function() {
         describe('through the event object\'s start property', function() {
         describe('through the event object\'s start property', function() {
           beforeEach(function() {
           beforeEach(function() {
-            $('.drag').data('event', { start: '05:00' })
+            dragEl.data('event', { start: '05:00' })
           })
           })
           defineTests()
           defineTests()
         })
         })
         describe('through the event object\'s time property', function() {
         describe('through the event object\'s time property', function() {
           beforeEach(function() {
           beforeEach(function() {
-            $('.drag').data('event', { time: '05:00' })
+            dragEl.data('event', { time: '05:00' })
           })
           })
           defineTests()
           defineTests()
         })
         })
         describe('through the `start` data attribute', function() {
         describe('through the `start` data attribute', function() {
           beforeEach(function() {
           beforeEach(function() {
-            $('.drag')
+            dragEl
               .data('event', true)
               .data('event', true)
               .data('start', '05:00')
               .data('start', '05:00')
           })
           })
@@ -131,7 +137,7 @@ describe('advanced external dnd', function() {
         })
         })
         describe('through the `time` data attribute', function() {
         describe('through the `time` data attribute', function() {
           beforeEach(function() {
           beforeEach(function() {
-            $('.drag').data('event', true)
+            dragEl.data('event', true)
               .data('time', '05:00')
               .data('time', '05:00')
           })
           })
           defineTests()
           defineTests()
@@ -149,13 +155,13 @@ describe('advanced external dnd', function() {
       describe('when given a duration', function() {
       describe('when given a duration', function() {
         describe('through the event object\'s duration property', function() {
         describe('through the event object\'s duration property', function() {
           beforeEach(function() {
           beforeEach(function() {
-            $('.drag').data('event', { duration: '05:00' })
+            dragEl.data('event', { duration: '05:00' })
           })
           })
           defineTests()
           defineTests()
         })
         })
         describe('through the `duration` data attribute', function() {
         describe('through the `duration` data attribute', function() {
           beforeEach(function() {
           beforeEach(function() {
-            $('.drag').data('event', true)
+            dragEl.data('event', true)
               .data('duration', '05:00')
               .data('duration', '05:00')
           })
           })
           defineTests()
           defineTests()
@@ -177,13 +183,13 @@ describe('advanced external dnd', function() {
       describe('when given stick:true', function() {
       describe('when given stick:true', function() {
         describe('through the event object', function() {
         describe('through the event object', function() {
           beforeEach(function() {
           beforeEach(function() {
-            $('.drag').data('event', { stick: true })
+            dragEl.data('event', { stick: true })
           })
           })
           defineTests()
           defineTests()
         })
         })
         describe('through the data attribute', function() {
         describe('through the data attribute', function() {
           beforeEach(function() {
           beforeEach(function() {
-            $('.drag').data('event', true)
+            dragEl.data('event', true)
               .data('stick', true)
               .data('stick', true)
           })
           })
           defineTests()
           defineTests()
@@ -216,7 +222,7 @@ describe('advanced external dnd', function() {
             } ]
             } ]
           })
           })
           beforeEach(function() {
           beforeEach(function() {
-            $('.drag').data('event', true)
+            dragEl.data('event', true)
           })
           })
           defineTests()
           defineTests()
         })
         })
@@ -228,7 +234,7 @@ describe('advanced external dnd', function() {
             }]
             }]
           })
           })
           beforeEach(function() {
           beforeEach(function() {
-            $('.drag').data('event', {
+            dragEl.data('event', {
               overlap: false
               overlap: false
             })
             })
           })
           })
@@ -243,7 +249,7 @@ describe('advanced external dnd', function() {
             }]
             }]
           })
           })
           beforeEach(function() {
           beforeEach(function() {
-            $('.drag').data('event', true)
+            dragEl.data('event', true)
           })
           })
           defineTests()
           defineTests()
         })
         })
@@ -268,13 +274,13 @@ describe('advanced external dnd', function() {
             }
             }
           })
           })
           beforeEach(function() {
           beforeEach(function() {
-            $('.drag').data('event', { duration: '02:00' })
+            dragEl.data('event', { duration: '02:00' })
           })
           })
           defineTests()
           defineTests()
         })
         })
         describe('via the event object\'s constraint property', function() {
         describe('via the event object\'s constraint property', function() {
           beforeEach(function() {
           beforeEach(function() {
-            $('.drag').data('event', {
+            dragEl.data('event', {
               duration: '02:00',
               duration: '02:00',
               constraint: {
               constraint: {
                 start: '04:00',
                 start: '04:00',
@@ -310,33 +316,33 @@ describe('advanced external dnd', function() {
       it('fires correctly', function(done) {
       it('fires correctly', function(done) {
         var options = {}
         var options = {}
 
 
-        $('.drag').data('event', { title: 'hey' })
+        dragEl.data('event', { title: 'hey' })
         testExternalEventDrag(options, '2014-11-13', true, done)
         testExternalEventDrag(options, '2014-11-13', true, done)
       })
       })
 
 
       describe('when given a start time', function() {
       describe('when given a start time', function() {
         describe('through the event object\'s start property', function() {
         describe('through the event object\'s start property', function() {
           beforeEach(function() {
           beforeEach(function() {
-            $('.drag').data('event', { start: '05:00' })
+            dragEl.data('event', { start: '05:00' })
           })
           })
           defineTests()
           defineTests()
         })
         })
         describe('through the event object\'s time property', function() {
         describe('through the event object\'s time property', function() {
           beforeEach(function() {
           beforeEach(function() {
-            $('.drag').data('event', { time: '05:00' })
+            dragEl.data('event', { time: '05:00' })
           })
           })
           defineTests()
           defineTests()
         })
         })
         describe('through the `start` data attribute', function() {
         describe('through the `start` data attribute', function() {
           beforeEach(function() {
           beforeEach(function() {
-            $('.drag').data('event', true)
+            dragEl.data('event', true)
               .data('start', '05:00')
               .data('start', '05:00')
           })
           })
           defineTests()
           defineTests()
         })
         })
         describe('through the `time` data attribute', function() {
         describe('through the `time` data attribute', function() {
           beforeEach(function() {
           beforeEach(function() {
-            $('.drag').data('event', true)
+            dragEl.data('event', true)
               .data('time', '05:00')
               .data('time', '05:00')
           })
           })
           defineTests()
           defineTests()

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

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

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

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

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

@@ -1,61 +1,57 @@
-
 describe('footer navigation', function() {
 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() {
   describe('and click next', function() {
     it('should change view to next month', function() {
     it('should change view to next month', function() {
-      $('#calendar').fullCalendar(options)
+      initCalendar()
       $('.fc-footer-toolbar .fc-next-button').simulate('click')
       $('.fc-footer-toolbar .fc-next-button').simulate('click')
-      var newDate = $('#calendar').fullCalendar('getDate')
+      var newDate = currentCalendar.getDate()
       expect(newDate).toEqualMoment('2010-03-01')
       expect(newDate).toEqualMoment('2010-03-01')
     })
     })
   })
   })
 
 
   describe('and click prev', function() {
   describe('and click prev', function() {
     it('should change view to prev month', function() {
     it('should change view to prev month', function() {
-      $('#calendar').fullCalendar(options)
+      initCalendar()
       $('.fc-footer-toolbar .fc-prev-button').simulate('click')
       $('.fc-footer-toolbar .fc-prev-button').simulate('click')
-      var newDate = $('#calendar').fullCalendar('getDate')
+      var newDate = currentCalendar.getDate()
       expect(newDate).toEqualMoment('2010-01-01')
       expect(newDate).toEqualMoment('2010-01-01')
     })
     })
   })
   })
 
 
   describe('and click prevYear', function() {
   describe('and click prevYear', function() {
     it('should change view to prev month', function() {
     it('should change view to prev month', function() {
-      $('#calendar').fullCalendar(options)
+      initCalendar()
       $('.fc-footer-toolbar .fc-prevYear-button').simulate('click')
       $('.fc-footer-toolbar .fc-prevYear-button').simulate('click')
-      var newDate = $('#calendar').fullCalendar('getDate')
+      var newDate = currentCalendar.getDate()
       expect(newDate).toEqualMoment('2009-02-01')
       expect(newDate).toEqualMoment('2009-02-01')
     })
     })
   })
   })
 
 
   describe('and click nextYear', function() {
   describe('and click nextYear', function() {
     it('should change view to prev month', function() {
     it('should change view to prev month', function() {
-      $('#calendar').fullCalendar(options)
+      initCalendar()
       $('.fc-footer-toolbar .fc-nextYear-button').simulate('click')
       $('.fc-footer-toolbar .fc-nextYear-button').simulate('click')
-      var newDate = $('#calendar').fullCalendar('getDate')
+      var newDate = currentCalendar.getDate()
       expect(newDate).toEqualMoment('2011-02-01')
       expect(newDate).toEqualMoment('2011-02-01')
     })
     })
   })
   })
 
 
   describe('and click today', function() {
   describe('and click today', function() {
     it('should change view to prev month', 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')
       $('.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')
       expect(newDate).toEqualMoment('2010-02-01')
     })
     })
   })
   })

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

@@ -1,59 +1,58 @@
-
 describe('header navigation', function() {
 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() {
   describe('and click next', function() {
     it('should change view to next month', 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')
       $('.fc-next-button').simulate('click')
-      var newDate = $('#calendar').fullCalendar('getDate')
+      var newDate = currentCalendar.getDate()
       expect(newDate).toEqualMoment('2010-03-01')
       expect(newDate).toEqualMoment('2010-03-01')
     })
     })
   })
   })
 
 
   describe('and click prev', function() {
   describe('and click prev', function() {
     it('should change view to prev month', 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')
       $('.fc-prev-button').simulate('click')
-      var newDate = $('#calendar').fullCalendar('getDate')
+      var newDate = currentCalendar.getDate()
       expect(newDate).toEqualMoment('2010-01-01')
       expect(newDate).toEqualMoment('2010-01-01')
     })
     })
   })
   })
 
 
   describe('and click prevYear', function() {
   describe('and click prevYear', function() {
     it('should change view to prev month', 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')
       $('.fc-prevYear-button').simulate('click')
-      var newDate = $('#calendar').fullCalendar('getDate')
+      var newDate = currentCalendar.getDate()
       expect(newDate).toEqualMoment('2009-02-01')
       expect(newDate).toEqualMoment('2009-02-01')
     })
     })
   })
   })
 
 
   describe('and click nextYear', function() {
   describe('and click nextYear', function() {
     it('should change view to prev month', 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')
       $('.fc-nextYear-button').simulate('click')
-      var newDate = $('#calendar').fullCalendar('getDate')
+      var newDate = currentCalendar.getDate()
       expect(newDate).toEqualMoment('2011-02-01')
       expect(newDate).toEqualMoment('2011-02-01')
     })
     })
   })
   })
 
 
   describe('and click today', function() {
   describe('and click today', function() {
     it('should change view to prev month', 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')
       $('.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
       newDate.local() // assign the local timezone
       expect(newDate).toEqualNow()
       expect(newDate).toEqualNow()
     })
     })

+ 0 - 1
tests/automated/legacy/height-and-contentHeight.js

@@ -23,7 +23,6 @@
       })
       })
 
 
       afterEach(function() {
       afterEach(function() {
-        calendarEl.fullCalendar('destroy') // best to destroy before removing element
         calendarEl.remove()
         calendarEl.remove()
       })
       })
 
 

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

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

+ 0 - 4
tests/automated/legacy/overlap.js

@@ -9,8 +9,6 @@ describe('event overlap', function() {
       defaultView: 'agendaWeek',
       defaultView: 'agendaWeek',
       scrollTime: '00:00'
       scrollTime: '00:00'
     }
     }
-    affix('#cal')
-    $('#cal').width(1100)
   })
   })
 
 
   describe('when other event overlap is false', function() {
   describe('when other event overlap is false', function() {
@@ -827,8 +825,6 @@ describe('selectOverlap', function() {
       defaultView: 'agendaWeek',
       defaultView: 'agendaWeek',
       scrollTime: '00:00'
       scrollTime: '00:00'
     }
     }
-    affix('#cal')
-    $('#cal').width(1100)
   })
   })
 
 
   describe('as false', function() {
   describe('as false', function() {

+ 49 - 52
tests/automated/legacy/refetchEventSources.js

@@ -1,6 +1,4 @@
 describe('refetchEventSources', function() {
 describe('refetchEventSources', function() {
-  var calendarEl
-  var options
 
 
   // used by createEventGenerator
   // used by createEventGenerator
   var eventCount
   var eventCount
@@ -8,43 +6,42 @@ describe('refetchEventSources', function() {
   var fetchDelay
   var fetchDelay
 
 
   beforeEach(function() {
   beforeEach(function() {
-    affix('#cal')
-    calendarEl = $('#cal')
     eventCount = 1
     eventCount = 1
     fetchId = 7
     fetchId = 7
-    options = {
-      now: '2015-08-07',
-      defaultView: 'agendaDay',
-      scrollTime: '00:00',
-      eventSources: [
-        {
-          id: 1,
-          events: createEventGenerator('source1-'),
-          color: 'green'
-        },
-        {
-          id: 2,
-          events: createEventGenerator('source2-'),
-          color: 'blue'
-        },
-        {
-          id: 3,
-          events: createEventGenerator('source3-'),
-          color: 'green'
-        }
-      ]
-    }
+  })
+
+  pushOptions({
+    now: '2015-08-07',
+    defaultView: 'agendaDay',
+    scrollTime: '00:00',
+    eventSources: [
+      {
+        id: 1,
+        events: createEventGenerator('source1-'),
+        color: 'green'
+      },
+      {
+        id: 2,
+        events: createEventGenerator('source2-'),
+        color: 'blue'
+      },
+      {
+        id: 3,
+        events: createEventGenerator('source3-'),
+        color: 'green'
+      }
+    ]
   })
   })
 
 
   describe('with a single event source passed in', function() {
   describe('with a single event source passed in', function() {
     it('only refetches events for the specified event source', function(done) {
     it('only refetches events for the specified event source', function(done) {
-      calendarEl.fullCalendar(options)
+      initCalendar()
 
 
       expect($('.source1-7').length).toEqual(1)
       expect($('.source1-7').length).toEqual(1)
       expect($('.source2-7').length).toEqual(1)
       expect($('.source2-7').length).toEqual(1)
       expect($('.source3-7').length).toEqual(1)
       expect($('.source3-7').length).toEqual(1)
 
 
-      var allEventSources = calendarEl.fullCalendar('getEventSources')
+      var allEventSources = currentCalendar.getEventSources()
       var blueEventSource = $.grep(allEventSources, function(eventSource) {
       var blueEventSource = $.grep(allEventSources, function(eventSource) {
         return eventSource.color === 'blue'
         return eventSource.color === 'blue'
       })[0]
       })[0]
@@ -53,7 +50,7 @@ describe('refetchEventSources', function() {
       eventCount = 2
       eventCount = 2
       fetchId = 8
       fetchId = 8
 
 
-      calendarEl.fullCalendar('refetchEventSources', blueEventSource)
+      currentCalendar.refetchEventSources(blueEventSource)
 
 
       // events from unaffected sources remain
       // events from unaffected sources remain
       expect($('.source1-7').length).toEqual(1)
       expect($('.source1-7').length).toEqual(1)
@@ -70,7 +67,7 @@ describe('refetchEventSources', function() {
   })
   })
   describe('with a single event source ID passed in', function() {
   describe('with a single event source ID passed in', function() {
     it('only refetches events for the specified event source', function(done) {
     it('only refetches events for the specified event source', function(done) {
-      calendarEl.fullCalendar(options)
+      initCalendar()
 
 
       expect($('.source1-7').length).toEqual(1)
       expect($('.source1-7').length).toEqual(1)
       expect($('.source2-7').length).toEqual(1)
       expect($('.source2-7').length).toEqual(1)
@@ -80,7 +77,7 @@ describe('refetchEventSources', function() {
       eventCount = 2
       eventCount = 2
       fetchId = 8
       fetchId = 8
 
 
-      calendarEl.fullCalendar('refetchEventSources', 2)
+      currentCalendar.refetchEventSources(2)
 
 
       // events from unaffected sources remain
       // events from unaffected sources remain
       expect($('.source1-7').length).toEqual(1)
       expect($('.source1-7').length).toEqual(1)
@@ -98,13 +95,13 @@ describe('refetchEventSources', function() {
 
 
   describe('with an array of multiple event sources passed in', function() {
   describe('with an array of multiple event sources passed in', function() {
     it('only refetches events for the specified event sources', function(done) {
     it('only refetches events for the specified event sources', function(done) {
-      calendarEl.fullCalendar(options)
+      initCalendar()
 
 
       expect($('.source1-7').length).toEqual(1)
       expect($('.source1-7').length).toEqual(1)
       expect($('.source2-7').length).toEqual(1)
       expect($('.source2-7').length).toEqual(1)
       expect($('.source3-7').length).toEqual(1)
       expect($('.source3-7').length).toEqual(1)
 
 
-      var allEventSources = calendarEl.fullCalendar('getEventSources')
+      var allEventSources = currentCalendar.getEventSources()
       var greenEventSources = $.grep(allEventSources, function(eventSource) {
       var greenEventSources = $.grep(allEventSources, function(eventSource) {
         return eventSource.color === 'green'
         return eventSource.color === 'green'
       })
       })
@@ -113,7 +110,7 @@ describe('refetchEventSources', function() {
       eventCount = 2
       eventCount = 2
       fetchId = 8
       fetchId = 8
 
 
-      calendarEl.fullCalendar('refetchEventSources', greenEventSources)
+      currentCalendar.refetchEventSources(greenEventSources)
 
 
       // events from unaffected sources remain
       // events from unaffected sources remain
       expect($('.source2-7').length).toEqual(1)
       expect($('.source2-7').length).toEqual(1)
@@ -132,7 +129,7 @@ describe('refetchEventSources', function() {
 
 
   describe('with an array of multiple event source IDs passed in', function() {
   describe('with an array of multiple event source IDs passed in', function() {
     it('only refetches events for the specified event sources', function(done) {
     it('only refetches events for the specified event sources', function(done) {
-      calendarEl.fullCalendar(options)
+      initCalendar()
 
 
       expect($('.source1-7').length).toEqual(1)
       expect($('.source1-7').length).toEqual(1)
       expect($('.source2-7').length).toEqual(1)
       expect($('.source2-7').length).toEqual(1)
@@ -142,7 +139,7 @@ describe('refetchEventSources', function() {
       eventCount = 2
       eventCount = 2
       fetchId = 8
       fetchId = 8
 
 
-      calendarEl.fullCalendar('refetchEventSources', [ 1, 3 ])
+      currentCalendar.refetchEventSources([ 1, 3 ])
 
 
       // events from unaffected sources remain
       // events from unaffected sources remain
       expect($('.source2-7').length).toEqual(1)
       expect($('.source2-7').length).toEqual(1)
@@ -161,27 +158,27 @@ describe('refetchEventSources', function() {
 
 
   describe('when called while initial fetch is still pending', function() {
   describe('when called while initial fetch is still pending', function() {
     it('keeps old events and rerenders new', function(done) {
     it('keeps old events and rerenders new', function(done) {
+      fetchDelay = 100
 
 
-      options.eventAfterAllRender = function() {
-
-        // events from unaffected sources remain
-        expect($('.source2-7').length).toEqual(1)
+      initCalendar({
+        eventAfterAllRender() {
 
 
-        // events from old fetch were cleared
-        expect($('.source1-7').length).toEqual(0)
-        expect($('.source3-7').length).toEqual(0)
+          // events from unaffected sources remain
+          expect($('.source2-7').length).toEqual(1)
 
 
-        // events from new fetch were rendered
-        expect($('.source1-8').length).toEqual(2)
-        expect($('.source3-8').length).toEqual(2)
+          // events from old fetch were cleared
+          expect($('.source1-7').length).toEqual(0)
+          expect($('.source3-7').length).toEqual(0)
 
 
-        done()
-      }
+          // events from new fetch were rendered
+          expect($('.source1-8').length).toEqual(2)
+          expect($('.source3-8').length).toEqual(2)
 
 
-      fetchDelay = 100
-      calendarEl.fullCalendar(options)
+          done()
+        }
+      })
 
 
-      var allEventSources = calendarEl.fullCalendar('getEventSources')
+      var allEventSources = currentCalendar.getEventSources()
       var greenEventSources = $.grep(allEventSources, function(eventSource) { // source 1 and 3
       var greenEventSources = $.grep(allEventSources, function(eventSource) { // source 1 and 3
         return eventSource.color === 'green'
         return eventSource.color === 'green'
       })
       })
@@ -190,7 +187,7 @@ describe('refetchEventSources', function() {
       eventCount = 2
       eventCount = 2
       fetchId = 8
       fetchId = 8
 
 
-      calendarEl.fullCalendar('refetchEventSources', greenEventSources)
+      currentCalendar.refetchEventSources(greenEventSources)
     })
     })
   })
   })
 
 

+ 65 - 61
tests/automated/legacy/removeEventSource.js

@@ -1,12 +1,9 @@
 describe('removeEventSource', function() {
 describe('removeEventSource', function() {
-  var options
+  pushOptions({
+    defaultDate: '2014-08-01'
+  })
 
 
   beforeEach(function() {
   beforeEach(function() {
-    affix('#cal')
-    options = {
-      defaultDate: '2014-08-01'
-    }
-
     XHRMock.setup()
     XHRMock.setup()
     XHRMock.get(/.*/, {
     XHRMock.get(/.*/, {
       status: 200,
       status: 200,
@@ -75,21 +72,21 @@ describe('removeEventSource', function() {
       }, 100)
       }, 100)
     }
     }
 
 
-    options.eventSources = [ source1 ]
-
-    options.eventAfterAllRender = function() {
-      if (!$('.fc-event').length) {
-        ; // might have rendered no events after removeEventSource call
-      } else {
-        expect($('.event1').length).toBe(0)
-        expect($('.event2').length).toBe(1)
-        done()
+    initCalendar({
+      eventSources: [ source1 ],
+      eventAfterAllRender() {
+        if (!$('.fc-event').length) {
+          ; // might have rendered no events after removeEventSource call
+        } else {
+          expect($('.event1').length).toBe(0)
+          expect($('.event2').length).toBe(1)
+          done()
+        }
       }
       }
-    }
+    })
 
 
-    $('#cal').fullCalendar(options)
-    $('#cal').fullCalendar('removeEventSource', source1)
-    $('#cal').fullCalendar('addEventSource', source2)
+    currentCalendar.removeEventSource(source1)
+    currentCalendar.addEventSource(source2)
   })
   })
 
 
   describe('when multiple sources share the same fetching function', function() {
   describe('when multiple sources share the same fetching function', function() {
@@ -99,8 +96,9 @@ describe('removeEventSource', function() {
         start: '2014-08-01T02:00:00'
         start: '2014-08-01T02:00:00'
       } ])
       } ])
     }
     }
-    beforeEach(function() {
-      options.eventSources = [
+
+    pushOptions({
+      eventSources: [
         { events: fetchFunc, className: 'event1', id: 'source1' },
         { events: fetchFunc, className: 'event1', id: 'source1' },
         { events: fetchFunc, className: 'event2', id: 'source2' }
         { events: fetchFunc, className: 'event2', id: 'source2' }
       ]
       ]
@@ -109,12 +107,12 @@ describe('removeEventSource', function() {
     describe('when called with the raw function', function() {
     describe('when called with the raw function', function() {
       it('removes events from all matching sources', function() {
       it('removes events from all matching sources', function() {
 
 
-        $('#cal').fullCalendar(options)
+        initCalendar()
         expect($('.fc-event').length).toBe(2)
         expect($('.fc-event').length).toBe(2)
         expect($('.event1').length).toBe(1)
         expect($('.event1').length).toBe(1)
         expect($('.event2').length).toBe(1)
         expect($('.event2').length).toBe(1)
 
 
-        $('#cal').fullCalendar('removeEventSource', fetchFunc)
+        currentCalendar.removeEventSource(fetchFunc)
         expect($('.fc-event').length).toBe(0)
         expect($('.fc-event').length).toBe(0)
       })
       })
     })
     })
@@ -122,13 +120,13 @@ describe('removeEventSource', function() {
     describe('when called with proper source object', function() {
     describe('when called with proper source object', function() {
       it('removes events only from the specific source', function() {
       it('removes events only from the specific source', function() {
 
 
-        $('#cal').fullCalendar(options)
+        initCalendar()
         expect($('.fc-event').length).toBe(2)
         expect($('.fc-event').length).toBe(2)
         expect($('.event1').length).toBe(1)
         expect($('.event1').length).toBe(1)
         expect($('.event2').length).toBe(1)
         expect($('.event2').length).toBe(1)
 
 
-        var source = $('#cal').fullCalendar('getEventSourceById', 'source2')
-        $('#cal').fullCalendar('removeEventSource', source)
+        var source = currentCalendar.getEventSourceById('source2')
+        currentCalendar.removeEventSource(source)
         expect($('.fc-event').length).toBe(1)
         expect($('.fc-event').length).toBe(1)
         expect($('.event1').length).toBe(1)
         expect($('.event1').length).toBe(1)
         expect($('.event2').length).toBe(0)
         expect($('.event2').length).toBe(0)
@@ -140,51 +138,57 @@ describe('removeEventSource', function() {
 
 
     it('correctly removes events provided via `events` at initialization', function(done) {
     it('correctly removes events provided via `events` at initialization', function(done) {
       var callCnt = 0
       var callCnt = 0
-      options.eventAfterAllRender = function() {
-        callCnt++
-        if (callCnt === 1) {
-          expectEventCnt(2)
-          $('#cal').fullCalendar('removeEventSource', eventInput)
-        } else if (callCnt === 2) {
-          expectEventCnt(0)
-          done()
+
+      initCalendar({
+        events: eventInput,
+        eventAfterAllRender() {
+          callCnt++
+          if (callCnt === 1) {
+            expectEventCnt(2)
+            currentCalendar.removeEventSource(eventInput)
+          } else if (callCnt === 2) {
+            expectEventCnt(0)
+            done()
+          }
         }
         }
-      }
-      options.events = eventInput
-      $('#cal').fullCalendar(options)
+      })
     })
     })
 
 
     it('correctly removes events provided via `eventSources` at initialization', function(done) {
     it('correctly removes events provided via `eventSources` at initialization', function(done) {
       var callCnt = 0
       var callCnt = 0
-      options.eventAfterAllRender = function() {
-        callCnt++
-        if (callCnt === 1) {
-          expectEventCnt(2)
-          $('#cal').fullCalendar('removeEventSource', eventInput)
-        } else if (callCnt === 2) {
-          expectEventCnt(0)
-          done()
+
+      initCalendar({
+        eventSources: [ eventInput ],
+        eventAfterAllRender() {
+          callCnt++
+          if (callCnt === 1) {
+            expectEventCnt(2)
+            currentCalendar.removeEventSource(eventInput)
+          } else if (callCnt === 2) {
+            expectEventCnt(0)
+            done()
+          }
         }
         }
-      }
-      options.eventSources = [ eventInput ]
-      $('#cal').fullCalendar(options)
+      })
     })
     })
 
 
     it('correctly removes events provided via `addEventSource` method', function(done) {
     it('correctly removes events provided via `addEventSource` method', function(done) {
       var callCnt = 0
       var callCnt = 0
-      options.eventAfterAllRender = function() {
-        callCnt++
-        if (callCnt === 1) {
-          $('#cal').fullCalendar('addEventSource', eventInput)
-        } else if (callCnt === 2) {
-          expectEventCnt(2)
-          $('#cal').fullCalendar('removeEventSource', eventInput)
-        } else if (callCnt === 3) {
-          expectEventCnt(0)
-          done()
+
+      initCalendar({
+        eventAfterAllRender() {
+          callCnt++
+          if (callCnt === 1) {
+            currentCalendar.addEventSource(eventInput)
+          } else if (callCnt === 2) {
+            expectEventCnt(2)
+            currentCalendar.removeEventSource(eventInput)
+          } else if (callCnt === 3) {
+            expectEventCnt(0)
+            done()
+          }
         }
         }
-      }
-      $('#cal').fullCalendar(options)
+      })
     })
     })
   }
   }
 
 
@@ -197,6 +201,6 @@ describe('removeEventSource', function() {
 
 
   function expectEventCnt(cnt) {
   function expectEventCnt(cnt) {
     expect($('.fc-event').length).toBe(cnt)
     expect($('.fc-event').length).toBe(cnt)
-    expect($('#cal').fullCalendar('clientEvents').length).toBe(cnt)
+    expect(currentCalendar.clientEvents().length).toBe(cnt)
   }
   }
 })
 })

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

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

+ 30 - 35
tests/automated/legacy/select-method.js

@@ -3,15 +3,10 @@ describe('select method', function() {
   var options
   var options
 
 
   beforeEach(function() {
   beforeEach(function() {
-    affix('#cal')
     options = {
     options = {
       defaultDate: '2014-05-25',
       defaultDate: '2014-05-25',
       selectable: true
       selectable: true
     }
     }
-  })
-
-  afterEach(function() {
-    $('#cal').fullCalendar('destroy')
   });
   });
 
 
   /*
   /*
@@ -34,13 +29,13 @@ describe('select method', function() {
         describe('when called with all-day moments', function() {
         describe('when called with all-day moments', function() {
           describe('when in bounds', function() {
           describe('when in bounds', function() {
             it('renders a selection', 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()
               expect($('.fc-highlight')).toBeVisible()
             })
             })
             it('renders a selection when called with one argument', function() {
             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()
               expect($('.fc-highlight')).toBeVisible()
             })
             })
             it('fires a selection event', function() {
             it('fires a selection event', function() {
@@ -51,15 +46,15 @@ describe('select method', function() {
                 expect(end).toEqualMoment('2014-05-09')
                 expect(end).toEqualMoment('2014-05-09')
               }
               }
               spyOn(options, 'select').and.callThrough()
               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()
               expect(options.select).toHaveBeenCalled()
             })
             })
           })
           })
           describe('when out of bounds', function() {
           describe('when out of bounds', function() {
             it('doesn\'t render a selection', 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()
               expect($('.fc-highlight')).not.toBeVisible()
             })
             })
             /*
             /*
@@ -70,8 +65,8 @@ describe('select method', function() {
                 expect(end).toEqualMoment('2014-05-09');
                 expect(end).toEqualMoment('2014-05-09');
               };
               };
               spyOn(options, 'select').and.callThrough();
               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();
               expect(options.select).not.toHaveBeenCalled();
             });
             });
             */
             */
@@ -79,8 +74,8 @@ describe('select method', function() {
         })
         })
         describe('when called with timed moments', function() {
         describe('when called with timed moments', function() {
           it('renders a selection', 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()
             expect($('.fc-highlight')).toBeVisible()
           })
           })
           it('fires a selection event', function() {
           it('fires a selection event', function() {
@@ -91,8 +86,8 @@ describe('select method', function() {
               expect(end).toEqualMoment('2014-05-09T06:00:00')
               expect(end).toEqualMoment('2014-05-09T06:00:00')
             }
             }
             spyOn(options, 'select').and.callThrough()
             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()
             expect(options.select).toHaveBeenCalled()
           })
           })
         })
         })
@@ -106,13 +101,13 @@ describe('select method', function() {
         describe('when called with timed moments', function() {
         describe('when called with timed moments', function() {
           describe('when in bounds', function() {
           describe('when in bounds', function() {
             it('renders a selection when called with one argument', 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()
               expect($('.fc-highlight')).toBeVisible()
             })
             })
             it('renders a selection over the slot area', function() {
             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()
               expect($('.fc-highlight')).toBeVisible()
               var slotAreaTop = $('.fc-time-grid-container').offset().top
               var slotAreaTop = $('.fc-time-grid-container').offset().top
               var overlayTop = $('.fc-highlight').offset().top
               var overlayTop = $('.fc-highlight').offset().top
@@ -121,8 +116,8 @@ describe('select method', function() {
           })
           })
           describe('when out of bounds', function() {
           describe('when out of bounds', function() {
             it('doesn\'t render a selection', 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()
               expect($('.fc-highlight')).not.toBeVisible()
             })
             })
             /*
             /*
@@ -133,8 +128,8 @@ describe('select method', function() {
                 expect(end).toEqualMoment('2015-05-09T07:00:00');
                 expect(end).toEqualMoment('2015-05-09T07:00:00');
               };
               };
               spyOn(options, 'select').and.callThrough();
               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();
               expect(options.select).not.toHaveBeenCalled();
             });
             });
             */
             */
@@ -146,8 +141,8 @@ describe('select method', function() {
               options.allDaySlot = true
               options.allDaySlot = true
             })
             })
             it('renders a selection over the day area', function() {
             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()
               expect($('.fc-highlight')).toBeVisible()
               var slotAreaTop = $('.fc-time-grid-container').offset().top
               var slotAreaTop = $('.fc-time-grid-container').offset().top
               var overlayTop = $('.fc-highlight').offset().top
               var overlayTop = $('.fc-highlight').offset().top
@@ -161,8 +156,8 @@ describe('select method', function() {
                 expect(end).toEqualMoment('2014-05-28')
                 expect(end).toEqualMoment('2014-05-28')
               }
               }
               spyOn(options, 'select').and.callThrough()
               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()
               expect(options.select).toHaveBeenCalled()
             })
             })
           })
           })
@@ -171,8 +166,8 @@ describe('select method', function() {
               options.allDaySlot = false
               options.allDaySlot = false
             })
             })
             it('doesn\'t render', function() {
             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()
               expect($('.fc-highlight')).not.toBeVisible()
             })
             })
             /*
             /*
@@ -185,8 +180,8 @@ describe('select method', function() {
                 expect(end).toEqualMoment('2014-05-28');
                 expect(end).toEqualMoment('2014-05-28');
               };
               };
               spyOn(options, 'select').and.callThrough();
               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();
               expect(options.select).not.toHaveBeenCalled();
             });
             });
             */
             */

+ 14 - 23
tests/automated/legacy/template.js.txt

@@ -1,27 +1,18 @@
-ddescribe('', function() {
-
-  var options;
-
-  beforeEach(function() {
-    //affix('#cal');
-    $('body').append('<div id="cal"></div>');
-    options = {
-      defaultDate: ''
-    };
-  });
-
-  afterEach(function() {
-    //$('#cal').fullCalendar('destroy');
-  });
+fdescribe('', function() {
+  pushOptions({
+    defaultDate: ''
+  })
 
 
   describe('', function() {
   describe('', function() {
-    beforeEach(function() {
-      options.defaultView = '';
-    });
+    pushOptions({
+      defaultView: ''
+    })
 
 
-    iit('', function() {
-      $('#cal').fullCalendar(options);
-    });
-  });
+    fit('', function() {
+      initCalendar({
+        // other options
+      })
+    })
+  })
 
 
-});
+})

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

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

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

@@ -1,17 +1,12 @@
 describe('timeFormat', function() {
 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() {
   function getRenderedEventTime() {
@@ -20,78 +15,83 @@ describe('timeFormat', function() {
 
 
   describe('when in month view', function() {
   describe('when in month view', function() {
 
 
-    beforeEach(function() {
-      options.defaultView = 'month'
+    pushOptions({
+      defaultView: 'month'
     })
     })
 
 
     it('renders correctly when default', function() {
     it('renders correctly when default', function() {
-      $('#cal').fullCalendar(options)
+      initCalendar()
       expect(getRenderedEventTime()).toBe('3p')
       expect(getRenderedEventTime()).toBe('3p')
     })
     })
 
 
     it('renders correctly when default and the locale is customized', function() {
     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')
       expect(getRenderedEventTime()).toBe('15')
     })
     })
 
 
     it('renders correctly when customized', function() {
     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')
       expect(getRenderedEventTime()).toBe('153:00:00')
     })
     })
   })
   })
 
 
   describe('when in agendaWeek view', function() {
   describe('when in agendaWeek view', function() {
 
 
-    beforeEach(function() {
-      options.defaultView = 'agendaWeek'
+    pushOptions({
+      defaultView: 'agendaWeek'
     })
     })
 
 
     it('renders correctly when default', function() {
     it('renders correctly when default', function() {
-      $('#cal').fullCalendar(options)
+      initCalendar()
       expect(getRenderedEventTime()).toBe('3:00 - 5:00')
       expect(getRenderedEventTime()).toBe('3:00 - 5:00')
     })
     })
 
 
     it('renders correctly when default and the locale is customized', function() {
     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')
       expect(getRenderedEventTime()).toBe('15:00 - 17:00')
     })
     })
 
 
     it('renders correctly when customized', function() {
     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')
       expect(getRenderedEventTime()).toBe('153:00:00 - 175:00:00')
     })
     })
   })
   })
 
 
   describe('when in multi-day custom basic view', function() {
   describe('when in multi-day custom basic view', function() {
 
 
-    beforeEach(function() {
-      options.views = {
+    pushOptions({
+      views: {
         basicTwoDay: {
         basicTwoDay: {
           type: 'basic',
           type: 'basic',
           duration: { days: 2 }
           duration: { days: 2 }
         }
         }
-      }
-      options.defaultView = 'basicTwoDay'
+      },
+      defaultView: 'basicTwoDay'
     })
     })
 
 
     it('defaults to no end time', function() {
     it('defaults to no end time', function() {
-      $('#cal').fullCalendar(options)
+      initCalendar()
       expect(getRenderedEventTime()).toBe('3p')
       expect(getRenderedEventTime()).toBe('3p')
     })
     })
   })
   })
 
 
   describe('when in basicDay view', function() {
   describe('when in basicDay view', function() {
 
 
-    beforeEach(function() {
-      options.defaultView = 'basicDay'
+    pushOptions({
+      defaultView: 'basicDay'
     })
     })
 
 
+
     it('defaults to showing the end time', function() {
     it('defaults to showing the end time', function() {
-      $('#cal').fullCalendar(options)
+      initCalendar()
       expect(getRenderedEventTime()).toBe('3p - 5p')
       expect(getRenderedEventTime()).toBe('3p - 5p')
     })
     })
   })
   })

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

@@ -1,49 +1,43 @@
-
 describe('timezone', function() {
 describe('timezone', function() {
 
 
   // NOTE: Only deals with the processing of *received* events.
   // NOTE: Only deals with the processing of *received* events.
   // Verification of a correct AJAX *request* is done in events-json-feed.js
   // 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) {
   it('receives events correctly when no timezone', function(done) {
-    options.eventAfterAllRender = function() {
-      expectNoTimezone()
-      done()
-    }
-    $('#cal').fullCalendar(options)
+    initCalendar({
+      eventAfterAllRender: function() {
+        expectNoTimezone()
+        done()
+      }
+    })
   })
   })
 
 
   function expectNoTimezone() {
   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.hasZone()).toEqual(false)
     expect(allDayEvent.start.hasTime()).toEqual(false)
     expect(allDayEvent.start.hasTime()).toEqual(false)
     expect(allDayEvent.start.format()).toEqual('2014-05-02')
     expect(allDayEvent.start.format()).toEqual('2014-05-02')
@@ -57,18 +51,19 @@ describe('timezone', function() {
 
 
 
 
   it('receives events correctly when local timezone', function(done) {
   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() {
   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.hasZone()).toEqual(false)
     expect(allDayEvent.start.hasTime()).toEqual(false)
     expect(allDayEvent.start.hasTime()).toEqual(false)
     expect(allDayEvent.start.format()).toEqual('2014-05-02')
     expect(allDayEvent.start.format()).toEqual('2014-05-02')
@@ -82,18 +77,19 @@ describe('timezone', function() {
 
 
 
 
   it('receives events correctly when UTC timezone', function(done) {
   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() {
   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.hasZone()).toEqual(false)
     expect(allDayEvent.start.hasTime()).toEqual(false)
     expect(allDayEvent.start.hasTime()).toEqual(false)
     expect(allDayEvent.start.format()).toEqual('2014-05-02')
     expect(allDayEvent.start.format()).toEqual('2014-05-02')
@@ -107,18 +103,19 @@ describe('timezone', function() {
 
 
 
 
   it('receives events correctly when custom timezone', function(done) {
   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() {
   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.hasZone()).toEqual(false)
     expect(allDayEvent.start.hasTime()).toEqual(false)
     expect(allDayEvent.start.hasTime()).toEqual(false)
     expect(allDayEvent.start.format()).toEqual('2014-05-02')
     expect(allDayEvent.start.format()).toEqual('2014-05-02')
@@ -135,22 +132,22 @@ describe('timezone', function() {
     var callCnt = 0
     var callCnt = 0
     var rootEl
     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 - 22
tests/automated/legacy/titleFormat.js

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

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

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

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

@@ -1,32 +1,31 @@
 describe('view-specific options', function() {
 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) {
   function testEachView(viewsAndVals) {
-    $('#cal').fullCalendar(options)
     $.each(viewsAndVals, function(view, val) {
     $.each(viewsAndVals, function(view, val) {
-      $('#cal').fullCalendar('changeView', view)
+      currentCalendar.changeView(view)
       expect($('h2')).toHaveText(val)
       expect($('h2')).toHaveText(val)
     })
     })
   }
   }
 
 
   it('can target a specific view (month)', function() {
   it('can target a specific view (month)', function() {
-    options.views.month = {
-      titleFormat: '[special!!!]'
-    }
+    initCalendar({
+      views: {
+        month: {
+          titleFormat: '[special!!!]'
+        }
+      }
+    })
     testEachView({
     testEachView({
       month: 'special!!!',
       month: 'special!!!',
       basicWeek: 'default',
       basicWeek: 'default',
@@ -37,9 +36,13 @@ describe('view-specific options', function() {
   })
   })
 
 
   it('can target a specific view (agendaWeek)', function() {
   it('can target a specific view (agendaWeek)', function() {
-    options.views.agendaWeek = {
-      titleFormat: '[special!!!]'
-    }
+    initCalendar({
+      views: {
+        agendaWeek: {
+          titleFormat: '[special!!!]'
+        }
+      }
+    })
     testEachView({
     testEachView({
       month: 'default',
       month: 'default',
       basicWeek: 'default',
       basicWeek: 'default',
@@ -50,9 +53,13 @@ describe('view-specific options', function() {
   })
   })
 
 
   it('can target basic views', function() {
   it('can target basic views', function() {
-    options.views.basic = {
-      titleFormat: '[special!!!]'
-    }
+    initCalendar({
+      views: {
+        basic: {
+          titleFormat: '[special!!!]'
+        }
+      }
+    })
     testEachView({
     testEachView({
       month: 'default', // will NOT target month view
       month: 'default', // will NOT target month view
       basicWeek: 'special!!!',
       basicWeek: 'special!!!',
@@ -63,9 +70,13 @@ describe('view-specific options', function() {
   })
   })
 
 
   it('can target agenda views', function() {
   it('can target agenda views', function() {
-    options.views.agenda = {
-      titleFormat: '[special!!!]'
-    }
+    initCalendar({
+      views: {
+        agenda: {
+          titleFormat: '[special!!!]'
+        }
+      }
+    })
     testEachView({
     testEachView({
       month: 'default',
       month: 'default',
       basicWeek: 'default',
       basicWeek: 'default',
@@ -76,9 +87,13 @@ describe('view-specific options', function() {
   })
   })
 
 
   it('can target week views', function() {
   it('can target week views', function() {
-    options.views.week = {
-      titleFormat: '[special!!!]'
-    }
+    initCalendar({
+      views: {
+        week: {
+          titleFormat: '[special!!!]'
+        }
+      }
+    })
     testEachView({
     testEachView({
       month: 'default',
       month: 'default',
       basicWeek: 'special!!!',
       basicWeek: 'special!!!',
@@ -89,9 +104,13 @@ describe('view-specific options', function() {
   })
   })
 
 
   it('can target day views', function() {
   it('can target day views', function() {
-    options.views.day = {
-      titleFormat: '[special!!!]'
-    }
+    initCalendar({
+      views: {
+        day: {
+          titleFormat: '[special!!!]'
+        }
+      }
+    })
     testEachView({
     testEachView({
       month: 'default',
       month: 'default',
       basicWeek: 'default',
       basicWeek: 'default',

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

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

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

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

+ 0 - 45
tests/automated/lib/fullcalendar-jquery-plugin.js

@@ -1,45 +0,0 @@
-
-$.fn.fullCalendar = function(options) {
-  let args = Array.prototype.slice.call(arguments, 1) // for a possible method call
-  let res = this // what this function will return (this jQuery object by default)
-
-  this.each(function(i, el) { // loop each DOM element involved
-    let $el = $(el)
-    let calendar = $el.data('fullCalendar') // get the existing calendar object (if any)
-    let singleRes // the returned value of this single method call
-
-    // a method call
-    if (typeof options === 'string') {
-
-      if (options === 'getCalendar') {
-        if (!i) { // first element only
-          res = calendar
-        }
-      } else if (options === 'destroy') { // don't warn if no calendar object
-        if (calendar) {
-          calendar.destroy()
-          $el.removeData('fullCalendar')
-        }
-      } else if (!calendar) {
-        FullCalendar.warn('Attempting to call a FullCalendar method on an element with no calendar.')
-      } else if (typeof calendar[options] === 'function') {
-        singleRes = calendar[options].apply(calendar, args)
-
-        if (!i) {
-          res = singleRes // record the first method call result
-        }
-        if (options === 'destroy') { // for the destroy method, must remove Calendar object data
-          $el.removeData('fullCalendar')
-        }
-      } else {
-        FullCalendar.warn("'" + options + "' is an unknown FullCalendar method.")
-      }
-    } else if (!calendar) { // don't initialize twice
-      calendar = new FullCalendar.Calendar(el, options)
-      $el.data('fullCalendar', calendar)
-      calendar.render()
-    }
-  })
-
-  return res
-}