2
0
Эх сурвалжийг харах

remove more legacy including affix

Adam Shaw 7 жил өмнө
parent
commit
0760f127f5

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

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

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

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

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

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

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

@@ -1,6 +1,4 @@
 describe('refetchEventSources', function() {
-  var calendarEl
-  var options
 
   // used by createEventGenerator
   var eventCount
@@ -8,43 +6,42 @@ describe('refetchEventSources', function() {
   var fetchDelay
 
   beforeEach(function() {
-    affix('#cal')
-    calendarEl = $('#cal')
     eventCount = 1
     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() {
     it('only refetches events for the specified event source', function(done) {
-      calendarEl.fullCalendar(options)
+      initCalendar()
 
       expect($('.source1-7').length).toEqual(1)
       expect($('.source2-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) {
         return eventSource.color === 'blue'
       })[0]
@@ -53,7 +50,7 @@ describe('refetchEventSources', function() {
       eventCount = 2
       fetchId = 8
 
-      calendarEl.fullCalendar('refetchEventSources', blueEventSource)
+      currentCalendar.refetchEventSources(blueEventSource)
 
       // events from unaffected sources remain
       expect($('.source1-7').length).toEqual(1)
@@ -70,7 +67,7 @@ describe('refetchEventSources', function() {
   })
   describe('with a single event source ID passed in', function() {
     it('only refetches events for the specified event source', function(done) {
-      calendarEl.fullCalendar(options)
+      initCalendar()
 
       expect($('.source1-7').length).toEqual(1)
       expect($('.source2-7').length).toEqual(1)
@@ -80,7 +77,7 @@ describe('refetchEventSources', function() {
       eventCount = 2
       fetchId = 8
 
-      calendarEl.fullCalendar('refetchEventSources', 2)
+      currentCalendar.refetchEventSources(2)
 
       // events from unaffected sources remain
       expect($('.source1-7').length).toEqual(1)
@@ -98,13 +95,13 @@ describe('refetchEventSources', function() {
 
   describe('with an array of multiple event sources passed in', function() {
     it('only refetches events for the specified event sources', function(done) {
-      calendarEl.fullCalendar(options)
+      initCalendar()
 
       expect($('.source1-7').length).toEqual(1)
       expect($('.source2-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) {
         return eventSource.color === 'green'
       })
@@ -113,7 +110,7 @@ describe('refetchEventSources', function() {
       eventCount = 2
       fetchId = 8
 
-      calendarEl.fullCalendar('refetchEventSources', greenEventSources)
+      currentCalendar.refetchEventSources(greenEventSources)
 
       // events from unaffected sources remain
       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() {
     it('only refetches events for the specified event sources', function(done) {
-      calendarEl.fullCalendar(options)
+      initCalendar()
 
       expect($('.source1-7').length).toEqual(1)
       expect($('.source2-7').length).toEqual(1)
@@ -142,7 +139,7 @@ describe('refetchEventSources', function() {
       eventCount = 2
       fetchId = 8
 
-      calendarEl.fullCalendar('refetchEventSources', [ 1, 3 ])
+      currentCalendar.refetchEventSources([ 1, 3 ])
 
       // events from unaffected sources remain
       expect($('.source2-7').length).toEqual(1)
@@ -161,27 +158,27 @@ describe('refetchEventSources', function() {
 
   describe('when called while initial fetch is still pending', function() {
     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
         return eventSource.color === 'green'
       })
@@ -190,7 +187,7 @@ describe('refetchEventSources', function() {
       eventCount = 2
       fetchId = 8
 
-      calendarEl.fullCalendar('refetchEventSources', greenEventSources)
+      currentCalendar.refetchEventSources(greenEventSources)
     })
   })