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

Merge branch 'updated_tests/ListView/allDayDefault/background-events' of https://github.com/jstacoder/fullcalendar

Adam Shaw 8 лет назад
Родитель
Сommit
0c06261576
3 измененных файлов с 159 добавлено и 139 удалено
  1. 41 34
      tests/legacy/ListView.js
  2. 25 33
      tests/legacy/allDayDefault.js
  3. 93 72
      tests/legacy/background-events.js

+ 41 - 34
tests/legacy/ListView.js

@@ -1,19 +1,14 @@
 describe('ListView rendering', function() {
-  var options
-
-  beforeEach(function() {
-    affix('#cal')
-    options = {
-      defaultView: 'listWeek',
-      now: '2016-08-20'
-    }
+  pushOptions({
+    defaultView: 'listWeek',
+    now: '2016-08-20'
   })
 
   describe('with all-day events', function() {
 
     describe('when single-day', function() {
-      beforeEach(function() {
-        options.events = [
+      pushOptions({
+        events: [
           {
             title: 'event 1',
             start: '2016-08-15'
@@ -26,7 +21,7 @@ describe('ListView rendering', function() {
       })
 
       it('renders only days with events', function() {
-        $('#cal').fullCalendar(options)
+        initCalendar()
 
         var days = getDayInfo()
         var events = getEventInfo()
@@ -43,19 +38,20 @@ describe('ListView rendering', function() {
       })
 
       it('filters events through eventRender', function() {
+        var options = {}
         options.eventRender = function(event, el) {
           el.find('.fc-event-dot').replaceWith('<span class="custom-icon" />')
         }
 
-        $('#cal').fullCalendar(options)
+        initCalendar(options)
 
         expect($('.custom-icon').length).toBe(2)
       })
     })
 
     describe('when multi-day', function() {
-      beforeEach(function() {
-        options.events = [
+      pushOptions({
+        events: [
           {
             title: 'event 1',
             start: '2016-08-15',
@@ -65,7 +61,7 @@ describe('ListView rendering', function() {
       })
 
       it('renders all-day for every day', function() {
-        $('#cal').fullCalendar(options)
+        initCalendar()
 
         var events = getEventInfo()
 
@@ -83,8 +79,8 @@ describe('ListView rendering', function() {
   describe('with timed events', function() {
 
     describe('when single-day', function() {
-      beforeEach(function() {
-        options.events = [
+      pushOptions({
+        events: [
           {
             title: 'event 1',
             start: '2016-08-15T07:00'
@@ -98,7 +94,7 @@ describe('ListView rendering', function() {
       })
 
       it('renders times', function() {
-        $('#cal').fullCalendar(options)
+        initCalendar()
 
         var events = getEventInfo()
 
@@ -110,8 +106,9 @@ describe('ListView rendering', function() {
       })
 
       it('doesn\'t render times when displayEventTime is false', function() {
+        var options = {}
         options.displayEventTime = false
-        $('#cal').fullCalendar(options)
+        initCalendar(options)
 
         var events = getEventInfo()
 
@@ -123,8 +120,9 @@ describe('ListView rendering', function() {
       })
 
       it('doesn\'t render end times when displayEventEnd is false', function() {
+        var options = {}
         options.displayEventEnd = false
-        $('#cal').fullCalendar(options)
+        initCalendar(options)
 
         var events = getEventInfo()
 
@@ -137,8 +135,9 @@ describe('ListView rendering', function() {
 
       // regression test for when localized event dates get unlocalized and leak into view rendering
       it('renders dates and times in locale', function() {
+        var options = {}
         options.locale = 'fr'
-        $('#cal').fullCalendar(options)
+        initCalendar(options)
 
         var days = getDayInfo()
         var events = getEventInfo()
@@ -160,11 +159,12 @@ describe('ListView rendering', function() {
     })
 
     describe('when multi-day', function() {
-      beforeEach(function() {
-        options.nextDayThreshold = '00:00'
+      pushOptions({
+        nextDayThreshold: '00:00'
       })
 
       it('renders partial and full days', function() {
+        var options = {}
         options.events = [
           {
             title: 'event 1',
@@ -172,7 +172,7 @@ describe('ListView rendering', function() {
             end: '2016-08-17T11:00'
           }
         ]
-        $('#cal').fullCalendar(options)
+        initCalendar(options)
 
         var events = getEventInfo()
 
@@ -186,6 +186,7 @@ describe('ListView rendering', function() {
       })
 
       it('truncates an out-of-range start', function() {
+        var options = {}
         options.events = [
           {
             title: 'event 1',
@@ -193,7 +194,7 @@ describe('ListView rendering', function() {
             end: '2016-08-16T11:00'
           }
         ]
-        $('#cal').fullCalendar(options)
+        initCalendar(options)
 
         var events = getEventInfo()
 
@@ -207,6 +208,7 @@ describe('ListView rendering', function() {
       })
 
       it('truncates an out-of-range start', function() {
+        var options = {}
         options.events = [
           {
             title: 'event 1',
@@ -214,7 +216,7 @@ describe('ListView rendering', function() {
             end: '2016-08-21T11:00'
           }
         ]
-        $('#cal').fullCalendar(options)
+        initCalendar(options)
 
         var events = getEventInfo()
 
@@ -229,6 +231,7 @@ describe('ListView rendering', function() {
     })
 
     it('renders same days when equal to nextDayThreshold', function() {
+      var options = {}
       options.nextDayThreshold = '09:00'
       options.events = [
         {
@@ -238,7 +241,7 @@ describe('ListView rendering', function() {
         }
       ]
 
-      $('#cal').fullCalendar(options)
+      initCalendar(options)
 
       var events = getEventInfo()
 
@@ -252,6 +255,7 @@ describe('ListView rendering', function() {
     })
 
     it('renders fewer days when before nextDayThreshold', function() {
+      var options = {}
       options.nextDayThreshold = '09:00'
       options.events = [
         {
@@ -261,7 +265,7 @@ describe('ListView rendering', function() {
         }
       ]
 
-      $('#cal').fullCalendar(options)
+      initCalendar(options)
 
       var events = getEventInfo()
 
@@ -275,12 +279,13 @@ describe('ListView rendering', function() {
 
   describe('when an event has no title', function() {
     it('renders no text for its title', function() {
+      var options = {}
       options.events = [
         {
           start: '2016-08-15'
         }
       ]
-      $('#cal').fullCalendar(options)
+      initCalendar(options)
 
       var events = getEventInfo()
 
@@ -292,12 +297,13 @@ describe('ListView rendering', function() {
 
   describe('when no events', function() {
     it('renders an empty message', function() {
-      $('#cal').fullCalendar(options)
+      initCalendar()
       expect(getIsEmptyMessage()).toBe(true)
     })
   })
 
   it('sorts events correctly', function() {
+    var options = {}
     options.now = '2016-08-29'
     options.events = [
       {
@@ -340,7 +346,7 @@ describe('ListView rendering', function() {
       }
     ]
 
-    $('#cal').fullCalendar(options)
+    initCalendar(options)
 
     var days = getDayInfo()
     var events = getEventInfo()
@@ -384,18 +390,19 @@ describe('ListView rendering', function() {
   })
 
   it('updates rendered events despite fetch range being lazy', function() {
+    var options = {}
     options.now = '2016-09-12'
     options.defaultView = 'month'
     options.events = [
       { title: 'event1', start: '2016-09-12' }
     ]
 
-    $('#cal').fullCalendar(options)
-    $('#cal').fullCalendar('changeView', 'listWeek')
+    initCalendar(options)
+    currentCalendar.changeView('listWeek')
 
     expect($('.fc-list-item').length).toBe(1)
 
-    $('#cal').fullCalendar('prev')
+    currentCalendar.prev()
 
     expect($('.fc-list-item').length).toBe(0)
   })

+ 25 - 33
tests/legacy/allDayDefault.js

@@ -1,14 +1,9 @@
 
 describe('allDayDefault', function() {
-
-  beforeEach(function() {
-    affix('#cal')
-  })
-
   describe('when undefined', function() {
 
     it('guesses false if T in ISO8601 start date', function() {
-      $('#cal').fullCalendar({
+      initCalendar({
         events: [
           {
             id: '1',
@@ -16,12 +11,12 @@ describe('allDayDefault', function() {
           }
         ]
       })
-      var eventObj = $('#cal').fullCalendar('clientEvents', '1')[0]
+      var eventObj = currentCalendar.clientEvents('1')[0]
       expect(eventObj.allDay).toEqual(false)
     })
 
     it('guesses false if T in ISO8601 end date', function() {
-      $('#cal').fullCalendar({
+      initCalendar({
         events: [
           {
             id: '1',
@@ -30,12 +25,12 @@ describe('allDayDefault', function() {
           }
         ]
       })
-      var eventObj = $('#cal').fullCalendar('clientEvents', '1')[0]
+      var eventObj = currentCalendar.clientEvents('1')[0]
       expect(eventObj.allDay).toEqual(false)
     })
 
     it('guesses true if ISO8601 start date with no time and unspecified end date', function() {
-      $('#cal').fullCalendar({
+      initCalendar({
         events: [
           {
             id: '1',
@@ -43,12 +38,12 @@ describe('allDayDefault', function() {
           }
         ]
       })
-      var eventObj = $('#cal').fullCalendar('clientEvents', '1')[0]
+      var eventObj = currentCalendar.clientEvents('1')[0]
       expect(eventObj.allDay).toEqual(true)
     })
 
     it('guesses true if ISO8601 start and end date with no times', function() {
-      $('#cal').fullCalendar({
+      initCalendar({
         events: [
           {
             id: '1',
@@ -57,12 +52,12 @@ describe('allDayDefault', function() {
           }
         ]
       })
-      var eventObj = $('#cal').fullCalendar('clientEvents', '1')[0]
+      var eventObj = currentCalendar.clientEvents('1')[0]
       expect(eventObj.allDay).toEqual(true)
     })
 
     it('guesses false if start is a unix timestamp (which implies it has a time)', function() {
-      $('#cal').fullCalendar({
+      initCalendar({
         events: [
           {
             id: '1',
@@ -71,12 +66,13 @@ describe('allDayDefault', function() {
           }
         ]
       })
-      var eventObj = $('#cal').fullCalendar('clientEvents', '1')[0]
+
+      var eventObj = currentCalendar.clientEvents('1')[0]
       expect(eventObj.allDay).toEqual(false)
     })
 
     it('guesses false if end is a unix timestamp (which implies it has a time)', function() {
-      $('#cal').fullCalendar({
+      initCalendar({
         events: [
           {
             id: '1',
@@ -85,7 +81,7 @@ describe('allDayDefault', function() {
           }
         ]
       })
-      var eventObj = $('#cal').fullCalendar('clientEvents', '1')[0]
+      var eventObj = currentCalendar.clientEvents('1')[0]
       expect(eventObj.allDay).toEqual(false)
     })
 
@@ -94,7 +90,7 @@ describe('allDayDefault', function() {
   describe('when specified', function() {
 
     it('has an effect when an event\'s allDay is not specified', function() {
-      $('#cal').fullCalendar({
+      initCalendar({
         allDayDefault: false,
         events: [
           {
@@ -103,12 +99,12 @@ describe('allDayDefault', function() {
           }
         ]
       })
-      var eventObj = $('#cal').fullCalendar('clientEvents', '1')[0]
+      var eventObj = currentCalendar.clientEvents('1')[0]
       expect(eventObj.allDay).toEqual(false)
     })
 
     it('has no effect when an event\'s allDay is specified', function() {
-      $('#cal').fullCalendar({
+      initCalendar({
         allDayDefault: false,
         events: [
           {
@@ -118,7 +114,7 @@ describe('allDayDefault', function() {
           }
         ]
       })
-      var eventObj = $('#cal').fullCalendar('clientEvents', '1')[0]
+      var eventObj = currentCalendar.clientEvents('1')[0]
       expect(eventObj.allDay).toEqual(true)
     })
 
@@ -128,12 +124,8 @@ describe('allDayDefault', function() {
 
 describe('source.allDayDefault', function() {
 
-  beforeEach(function() {
-    affix('#cal')
-  })
-
   it('has an effect when an event\'s allDay is not specified', function() {
-    $('#cal').fullCalendar({
+    initCalendar({
       eventSources: [
         {
           allDayDefault: false,
@@ -146,12 +138,12 @@ describe('source.allDayDefault', function() {
         }
       ]
     })
-    var eventObj = $('#cal').fullCalendar('clientEvents', '1')[0]
+    var eventObj = currentCalendar.clientEvents('1')[0]
     expect(eventObj.allDay).toEqual(false)
   })
 
   it('a true value can override the global allDayDefault', function() {
-    $('#cal').fullCalendar({
+    initCalendar({
       allDayDefault: false,
       eventSources: [
         {
@@ -165,12 +157,12 @@ describe('source.allDayDefault', function() {
         }
       ]
     })
-    var eventObj = $('#cal').fullCalendar('clientEvents', '1')[0]
+    var eventObj = currentCalendar.clientEvents('1')[0]
     expect(eventObj.allDay).toEqual(true)
   })
 
   it('a false value can override the global allDayDefault', function() {
-    $('#cal').fullCalendar({
+    initCalendar({
       allDayDefault: true,
       eventSources: [
         {
@@ -184,12 +176,12 @@ describe('source.allDayDefault', function() {
         }
       ]
     })
-    var eventObj = $('#cal').fullCalendar('clientEvents', '1')[0]
+    var eventObj = currentCalendar.clientEvents('1')[0]
     expect(eventObj.allDay).toEqual(false)
   })
 
   it('has no effect when an event\'s allDay is specified', function() {
-    $('#cal').fullCalendar({
+    initCalendar({
       eventSources: [
         {
           allDayDefault: true,
@@ -203,7 +195,7 @@ describe('source.allDayDefault', function() {
         }
       ]
     })
-    var eventObj = $('#cal').fullCalendar('clientEvents', '1')[0]
+    var eventObj = currentCalendar.clientEvents('1')[0]
     expect(eventObj.allDay).toEqual(false)
   })
 

+ 93 - 72
tests/legacy/background-events.js

@@ -3,25 +3,17 @@ import { RED_REGEX } from '../lib/dom-misc'
 describe('background events', function() {
 
   // SEE ALSO: event-color.js
-
-  var options
-
-  beforeEach(function() {
-    options = {
-      defaultDate: '2014-11-04',
-      scrollTime: '00:00'
-    }
-    affix('#cal')
-    $('#cal').width(1100)
+  pushOptions({
+    defaultDate: '2014-11-04',
+    scrollTime: '00:00'
   })
 
   describe('when in month view', function() {
-    beforeEach(function() {
-      options.defaultView = 'month'
-    })
+    pushOptions({ defaultView: 'month' })
 
     describe('when LTR', function() {
       it('render correctly on a single day', function(done) {
+        var options = {}
         options.events = [ {
           title: 'hi',
           start: '2014-11-04',
@@ -35,9 +27,10 @@ describe('background events', function() {
           expect($('.fc-bgevent .fc-resizer').length).toBe(0) // can't resize
           done()
         }
-        $('#cal').fullCalendar(options)
+        initCalendar(options)
       })
       it('render correctly spanning multiple weeks', function(done) {
+        var options = {}
         options.events = [ {
           title: 'hi',
           start: '2014-11-04',
@@ -53,9 +46,10 @@ describe('background events', function() {
           expect($('.fc-event').length).toBe(0)
           done()
         }
-        $('#cal').fullCalendar(options)
+        initCalendar(options)
       })
       it('render correctly when two span on top of each other', function(done) {
+        var options = {}
         options.events = [
           {
             start: '2014-11-04',
@@ -76,10 +70,11 @@ describe('background events', function() {
           expect($('.fc-event').length).toBe(0)
           done()
         }
-        $('#cal').fullCalendar(options)
+        initCalendar(options)
       })
       describe('when weekNumbers', function() {
         it('renders to right of week numbers', function(done) {
+          var options = {}
           options.weekNumbers = true
           options.events = [ {
             start: '2014-11-02',
@@ -93,10 +88,11 @@ describe('background events', function() {
             expect($('.fc-event').length).toBe(0)
             done()
           }
-          $('#cal').fullCalendar(options)
+          initCalendar(options)
         })
       })
       it('renders "business hours" on whole days', function(done) {
+        var options = {}
         options.businessHours = true
         options.eventAfterAllRender = function() {
           setTimeout(function() { // no trigger when business hours renders. this will have to do.
@@ -104,15 +100,15 @@ describe('background events', function() {
             done()
           }, 0)
         }
-        $('#cal').fullCalendar(options)
+        initCalendar(options)
       })
     })
 
     describe('when RTL', function() {
-      beforeEach(function() {
-        options.isRTL = true
-      })
+      pushOptions({isRTL: true})
+
       it('render correctly on a single day', function(done) {
+        var options = {}
         options.events = [ {
           title: 'hi',
           start: '2014-11-04',
@@ -125,9 +121,10 @@ describe('background events', function() {
           expect($('.fc-event').length).toBe(0)
           done()
         }
-        $('#cal').fullCalendar(options)
+        initCalendar(options)
       })
       it('render correctly spanning multiple weeks', function(done) {
+        var options = {}
         options.events = [ {
           title: 'hi',
           start: '2014-11-04',
@@ -143,10 +140,11 @@ describe('background events', function() {
           expect($('.fc-event').length).toBe(0)
           done()
         }
-        $('#cal').fullCalendar(options)
+        initCalendar(options)
       })
       describe('when weekNumbers', function() {
         it('renders to left of week numbers', function(done) {
+          var options = {}
           options.weekNumbers = true
           options.events = [ {
             start: '2014-11-02',
@@ -160,7 +158,7 @@ describe('background events', function() {
             expect($('.fc-event').length).toBe(0)
             done()
           }
-          $('#cal').fullCalendar(options)
+          initCalendar(options)
         })
       })
     })
@@ -169,6 +167,7 @@ describe('background events', function() {
 
       describe('when LTR', function() {
         it('render correctly on a single day', function(done) {
+          var options = {}
           options.events = [ {
             title: 'hi',
             start: '2014-11-04',
@@ -191,9 +190,10 @@ describe('background events', function() {
             expect($('.fc-event').length).toBe(0)
             done()
           }
-          $('#cal').fullCalendar(options)
+          initCalendar(options)
         })
         it('render correctly spanning multiple weeks', function(done) {
+          var options = {}
           options.events = [ {
             title: 'hi',
             start: '2014-11-04',
@@ -218,9 +218,10 @@ describe('background events', function() {
             expect($('.fc-event').length).toBe(0)
             done()
           }
-          $('#cal').fullCalendar(options)
+          initCalendar(options)
         })
         it('render correctly when starts before start of month', function(done) {
+          var options = {}
           options.events = [ {
             start: '2014-10-24',
             end: '2014-11-06',
@@ -240,9 +241,10 @@ describe('background events', function() {
 
             done()
           }
-          $('#cal').fullCalendar(options)
+          initCalendar(options)
         })
         it('render correctly when ends after end of month', function(done) {
+          var options = {}
           options.events = [ {
             start: '2014-11-27',
             end: '2014-12-08',
@@ -262,9 +264,10 @@ describe('background events', function() {
 
             done()
           }
-          $('#cal').fullCalendar(options)
+          initCalendar(options)
         })
         it('render correctly with two related events, in reverse order', function(done) {
+          var options = {}
           options.events = [
             {
               id: 'hi',
@@ -288,21 +291,22 @@ describe('background events', function() {
 
             /* order in DOM is reversed
             expect($('.fc-day-grid .fc-row:eq(1) .fc-bgevent:eq(0)'))
-              .toBeLeftOf('.fc-day-grid .fc-row:eq(1) .fc-bgevent:eq(1)');
+              .toBeLeftOf('.fc-day-grid .fc-row:eq(1) .fc-bgevent:eq(1)')
             expect($('.fc-day-grid .fc-row:eq(1) .fc-bgevent:eq(1)'))
-              .toBeLeftOf('.fc-day-grid .fc-row:eq(1) .fc-bgevent:eq(2)'); */
+              .toBeLeftOf('.fc-day-grid .fc-row:eq(1) .fc-bgevent:eq(2)')
+            */
 
             done()
           }
-          $('#cal').fullCalendar(options)
+          initCalendar(options)
         })
       })
 
       describe('when RTL', function() {
-        beforeEach(function() {
-          options.isRTL = true
-        })
+        pushOptions({ isRTL: true })
+
         it('render correctly on a single day', function(done) {
+          var options = {}
           options.events = [ {
             title: 'hi',
             start: '2014-11-04',
@@ -319,19 +323,21 @@ describe('background events', function() {
 
             /* order in DOM is reversed
             expect($('.fc-day-grid .fc-row:eq(1) .fc-bgevent:eq(0)'))
-              .toBeLeftOf('.fc-day[data-date="2014-11-03"]');
+              .toBeLeftOf('.fc-day[data-date="2014-11-03"]')
             expect($('.fc-day-grid .fc-row:eq(1) .fc-bgevent:eq(1)'))
-              .toBeRightOf('.fc-day[data-date="2014-11-05"]'); */
+              .toBeRightOf('.fc-day[data-date="2014-11-05"]')
+            */
 
             done()
           }
-          $('#cal').fullCalendar(options)
+          initCalendar(options)
         })
       })
     })
 
     describe('when in month view', function() {
       it('can be activated when rendering set on the source', function(done) {
+        var options = {}
         options.defaultView = 'month'
         options.eventSources = [ {
           rendering: 'background',
@@ -344,12 +350,13 @@ describe('background events', function() {
           expect($('.fc-event').length).toBe(0)
           done()
         }
-        $('#cal').fullCalendar(options)
+        initCalendar(options)
       })
     })
 
     describe('when in agenda view and timed event', function() {
       it('can be activated when rendering set on the source', function(done) {
+        var options = {}
         options.defaultView = 'agendaWeek'
         options.eventSources = [ {
           rendering: 'background',
@@ -362,18 +369,17 @@ describe('background events', function() {
           expect($('.fc-event').length).toBe(0)
           done()
         }
-        $('#cal').fullCalendar(options)
+        initCalendar(options)
       })
     })
   })
 
   describe('when in agendaWeek view', function() {
-    beforeEach(function() {
-      options.defaultView = 'agendaWeek'
-    })
+    pushOptions({ defaultView: 'agendaWeek' })
 
     describe('when LTR', function() {
       it('render correctly on one day', function(done) {
+        var options = {}
         options.events = [ {
           start: '2014-11-04T01:00:00',
           end: '2014-11-04T05:00:00',
@@ -388,9 +394,10 @@ describe('background events', function() {
           expect($('.fc-bgevent .fc-resizer').length).toBe(0) // can't resize
           done()
         }
-        $('#cal').fullCalendar(options)
+        initCalendar(options)
       })
       it('render correctly spanning multiple days', function(done) {
+        var options = {}
         options.events = [ {
           start: '2014-11-04T01:00:00',
           end: '2014-11-05T05:00:00',
@@ -403,9 +410,10 @@ describe('background events', function() {
           // TODO: maybe check y coords
           done()
         }
-        $('#cal').fullCalendar(options)
+        initCalendar(options)
       })
       it('render correctly when two span on top of each other', function(done) {
+        var options = {}
         options.events = [
           {
             start: '2014-11-04T01:00:00',
@@ -425,22 +433,24 @@ describe('background events', function() {
           // TODO: maybe check y coords
           done()
         }
-        $('#cal').fullCalendar(options)
+        initCalendar(options)
       })
       describe('when businessHours', function() {
         it('renders correctly if assumed default', function() {
+          var options = {}
           options.businessHours = true
-          $('#cal').fullCalendar(options)
+          initCalendar(options)
           expect($('.fc-day-grid .fc-nonbusiness').length).toBe(2) // whole days in the day area
           expect($('.fc-time-grid .fc-nonbusiness').length).toBe(12) // strips of gray on the timed area
         })
         it('renders correctly if custom', function() {
+          var options = {}
           options.businessHours = {
             start: '02:00',
             end: '06:00',
             dow: [ 1, 2, 3, 4 ] // Mon-Thu
           }
-          $('#cal').fullCalendar(options)
+          initCalendar(options)
 
           // whole days
           expect($('.fc-day-grid .fc-nonbusiness').length).toBe(2) // each multi-day stretch is one element
@@ -458,10 +468,9 @@ describe('background events', function() {
       })
     })
     describe('when RTL', function() {
-      beforeEach(function() {
-        options.isRTL = true
-      })
+      pushOptions({ isRTL: true })
       it('render correctly on one day', function(done) {
+        var options = {}
         options.events = [ {
           start: '2014-11-04T01:00:00',
           end: '2014-11-04T05:00:00',
@@ -474,9 +483,10 @@ describe('background events', function() {
           expect($('.fc-bgevent')).toBeAbove('.fc-slats tr:eq(10)') // 5am
           done()
         }
-        $('#cal').fullCalendar(options)
+        initCalendar(options)
       })
       it('render correctly spanning multiple days', function(done) {
+        var options = {}
         options.events = [ {
           start: '2014-11-04T01:00:00',
           end: '2014-11-05T05:00:00',
@@ -488,16 +498,17 @@ describe('background events', function() {
           expect(queryBgEventsInCol(4).length).toBe(1)
           done()
         }
-        $('#cal').fullCalendar(options)
+        initCalendar(options)
       })
       describe('when businessHours', function() {
         it('renders correctly if custom', function() {
+          var options = {}
           options.businessHours = {
             start: '02:00',
             end: '06:00',
             dow: [ 1, 2, 3, 4 ] // Mon-Thu
           }
-          $('#cal').fullCalendar(options)
+          initCalendar(options)
 
           // whole days
           expect($('.fc-day-grid .fc-nonbusiness').length).toBe(2) // each stretch of days is one element
@@ -520,6 +531,7 @@ describe('background events', function() {
       describe('when LTR', function() {
 
         it('render correctly on one day', function(done) {
+          var options = {}
           options.events = [ {
             start: '2014-11-04T01:00:00',
             end: '2014-11-04T05:00:00',
@@ -537,10 +549,11 @@ describe('background events', function() {
             // TODO: maybe check y coords
             done()
           }
-          $('#cal').fullCalendar(options)
+          initCalendar(options)
         })
 
         it('render correctly spanning multiple days', function(done) {
+          var options = {}
           options.events = [ {
             start: '2014-11-04T01:00:00',
             end: '2014-11-05T05:00:00',
@@ -558,10 +571,11 @@ describe('background events', function() {
             // TODO: maybe check y coords
             done()
           }
-          $('#cal').fullCalendar(options)
+          initCalendar(options)
         })
 
         it('render correctly when starts before start of week', function(done) {
+          var options = {}
           options.events = [ {
             start: '2014-10-30T01:00:00',
             end: '2014-11-04T05:00:00',
@@ -579,10 +593,11 @@ describe('background events', function() {
             // TODO: maybe check y coords
             done()
           }
-          $('#cal').fullCalendar(options)
+          initCalendar(options)
         })
 
         it('render correctly when ends after end of week', function(done) {
+          var options = {}
           options.events = [ {
             start: '2014-11-04T01:00:00',
             end: '2014-11-12T05:00:00',
@@ -596,10 +611,11 @@ describe('background events', function() {
             // TODO: maybe check y coords
             done()
           }
-          $('#cal').fullCalendar(options)
+          initCalendar(options)
         })
 
         it('render correctly with two related events, in reverse order', function(done) {
+          var options = {}
           options.events = [
             {
               id: 'hello',
@@ -626,10 +642,11 @@ describe('background events', function() {
             // TODO: maybe check y coords
             done()
           }
-          $('#cal').fullCalendar(options)
+          initCalendar(options)
         })
 
         it('render correctly with two related events, nested', function(done) {
+          var options = {}
           options.events = [
             {
               id: 'hello',
@@ -659,16 +676,15 @@ describe('background events', function() {
 
             done()
           }
-          $('#cal').fullCalendar(options)
+          initCalendar(options)
         })
 
       })
 
       describe('when RTL', function() {
-        beforeEach(function() {
-          options.isRTL = true
-        })
+        pushOptions({ isRTL: true })
         it('render correctly on one day', function(done) {
+          var options = {}
           options.events = [ {
             start: '2014-11-04T01:00:00',
             end: '2014-11-04T05:00:00',
@@ -686,12 +702,13 @@ describe('background events', function() {
             // TODO: maybe check y coords
             done()
           }
-          $('#cal').fullCalendar(options)
+          initCalendar(options)
         })
       })
 
       describe('when out of view range', function() {
         it('should still render', function(done) {
+          var options = {}
           options.events = [ {
             start: '2014-01-01T01:00:00',
             end: '2014-01-01T05:00:00',
@@ -701,12 +718,13 @@ describe('background events', function() {
             expect($('.fc-bgevent').length).toBe(7)
             done()
           }
-          $('#cal').fullCalendar(options)
+          initCalendar(options)
         })
       })
     })
 
     it('can have custom Event Object color', function(done) {
+      var options = {}
       options.events = [ {
         start: '2014-11-04T01:00:00',
         rendering: 'background',
@@ -716,10 +734,11 @@ describe('background events', function() {
         expect($('.fc-bgevent').css('background-color')).toMatch(RED_REGEX)
         done()
       }
-      $('#cal').fullCalendar(options)
+      initCalendar(options)
     })
 
     it('can have custom Event Object backgroundColor', function(done) {
+      var options = {}
       options.events = [ {
         start: '2014-11-04T01:00:00',
         rendering: 'background',
@@ -729,10 +748,11 @@ describe('background events', function() {
         expect($('.fc-bgevent').css('background-color')).toMatch(RED_REGEX)
         done()
       }
-      $('#cal').fullCalendar(options)
+      initCalendar(options)
     })
 
     it('can have custom Event Source color', function(done) {
+      var options = {}
       options.eventSources = [ {
         color: 'red',
         events: [ {
@@ -744,10 +764,11 @@ describe('background events', function() {
         expect($('.fc-bgevent').css('background-color')).toMatch(RED_REGEX)
         done()
       }
-      $('#cal').fullCalendar(options)
+      initCalendar(options)
     })
 
     it('can have custom Event Source backgroundColor', function(done) {
+      var options = {}
       options.eventSources = [ {
         backgroundColor: 'red',
         events: [ {
@@ -759,10 +780,11 @@ describe('background events', function() {
         expect($('.fc-bgevent').css('background-color')).toMatch(RED_REGEX)
         done()
       }
-      $('#cal').fullCalendar(options)
+      initCalendar(options)
     })
 
     it('is affected by global eventColor', function(done) {
+      var options = {}
       options.eventColor = 'red'
       options.eventSources = [ {
         events: [ {
@@ -774,10 +796,11 @@ describe('background events', function() {
         expect($('.fc-bgevent').css('background-color')).toMatch(RED_REGEX)
         done()
       }
-      $('#cal').fullCalendar(options)
+      initCalendar(options)
     })
 
     it('is affected by global eventBackgroundColor', function(done) {
+      var options = {}
       options.eventBackgroundColor = 'red'
       options.eventSources = [ {
         events: [ {
@@ -789,11 +812,10 @@ describe('background events', function() {
         expect($('.fc-bgevent').css('background-color')).toMatch(RED_REGEX)
         done()
       }
-      $('#cal').fullCalendar(options)
+      initCalendar(options)
     })
   })
 
-
   function queryBgEventsInCol(col) {
     return $('.fc-time-grid .fc-content-skeleton td:not(.fc-axis):eq(' + col + ') .fc-bgevent')
   }
@@ -801,5 +823,4 @@ describe('background events', function() {
   function queryNonBusinessSegsInCol(col) {
     return $('.fc-time-grid .fc-content-skeleton td:not(.fc-axis):eq(' + col + ') .fc-nonbusiness')
   }
-
 })