Przeglądaj źródła

Update legacy tests

acerix 7 lat temu
rodzic
commit
5a21581487

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

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

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

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

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

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