ソースを参照

Update legacy tests

acerix 8 年 前
コミット
8574122592
1 ファイル変更44 行追加44 行削除
  1. 44 44
      tests/legacy/defaultAllDayEventDuration.js

+ 44 - 44
tests/legacy/defaultAllDayEventDuration.js

@@ -1,63 +1,63 @@
 describe('defaultAllDayEventDuration', function() {
 
-  var options
-
-  beforeEach(function() {
-    affix('#cal')
-
-    options = {
-      defaultDate: '2014-05-01',
-      defaultView: 'month'
-    }
+  pushOptions({
+    defaultDate: '2014-05-01',
+    defaultView: 'month'
   })
 
   describe('when forceEventDuration is on', function() {
 
-    beforeEach(function() {
-      options.forceEventDuration = true
+    pushOptions({
+      forceEventDuration: true
     })
 
     it('correctly calculates an unspecified end when using a Duration object input', function() {
-      options.defaultAllDayEventDuration = { days: 2 }
-      options.events = [
-        {
-          allDay: true,
-          start: '2014-05-05'
-        }
-      ]
-      $('#cal').fullCalendar(options)
-      var event = $('#cal').fullCalendar('clientEvents')[0]
+
+      initCalendar({
+        defaultAllDayEventDuration: { days: 2 },
+        events: [
+          {
+            allDay: true,
+            start: '2014-05-05'
+          }
+        ]
+      })
+
+      var event = currentCalendar.clientEvents()[0]
       expect(event.end).toEqualMoment('2014-05-07')
     })
 
     it('correctly calculates an unspecified end when using a string Duration input', function() {
-      options.defaultAllDayEventDuration = '3.00:00:00'
-      options.events = [
-        {
-          allDay: true,
-          start: '2014-05-05'
-        }
-      ]
-      $('#cal').fullCalendar(options)
-      var event = $('#cal').fullCalendar('clientEvents')[0]
+
+      initCalendar({
+        defaultAllDayEventDuration: '3.00:00:00',
+        events: [
+          {
+            allDay: true,
+            start: '2014-05-05'
+          }
+        ]
+      })
+
+      var event = currentCalendar.clientEvents()[0]
       expect(event.end).toEqualMoment('2014-05-08')
     })
   })
 
   describe('when forceEventDuration is off', function() {
 
-    beforeEach(function() {
-      options.forceEventDuration = false
-    });
+    pushOptions({
+      forceEventDuration: false
+    })
 
-    [ 'basicWeek', 'agendaWeek' ].forEach(function(viewName) { // because they render all-day events in similar ways
-      describe('with ' + viewName + ' view', function() {
-        beforeEach(function() {
-          options.defaultView = viewName
-        })
-        it('renders an all-day event with no `end` to appear to have the default duration', function(done) {
-          options.defaultAllDayEventDuration = { days: 2 }
-          options.events = [
+    describeOptions('defaultView', {
+      'with basicWeek view': 'basicWeek',
+      'with agendaWeek view': 'agendaWeek'
+    }, function() {
+      it('renders an all-day event with no `end` to appear to have the default duration', function(done) {
+        initCalendar({
+          defaultAllDayEventDuration: { days: 2 },
+          events: [
             {
               // a control. so we know how wide it should be
               title: 'control event',
@@ -71,15 +71,15 @@ describe('defaultAllDayEventDuration', function() {
               allDay: true,
               start: '2014-04-28'
             }
-          ]
-          options.eventAfterAllRender = function() {
-            var eventElms = $('#cal .fc-event')
+          ],
+          eventAfterAllRender: function() {
+            var eventElms = $('.fc-event', currentCalendar.el)
             var width0 = eventElms.eq(0).outerWidth()
             var width1 = eventElms.eq(1).outerWidth()
+            expect(width0).toBeGreaterThan(0)
             expect(width0).toEqual(width1)
             done()
           }
-          $('#cal').fullCalendar(options)
         })
       })
     })