Procházet zdrojové kódy

Update legacy tests

acerix před 7 roky
rodič
revize
4c1cd14585

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

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

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

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

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

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