Przeglądaj źródła

Update legacy tests

acerix 8 lat temu
rodzic
commit
77628145e0
2 zmienionych plików z 29 dodań i 30 usunięć
  1. 27 27
      tests/legacy/eventAllow.js
  2. 2 3
      tests/lib/time-grid.js

+ 27 - 27
tests/legacy/eventAllow.js

@@ -1,36 +1,34 @@
 import { dragTimeGridEvent } from '../lib/time-grid'
 
 describe('eventAllow', function() {
-  var options
-
-  beforeEach(function() {
-    options = {
-      now: '2016-09-04',
-      defaultView: 'agendaWeek',
-      scrollTime: '00:00',
-      editable: true,
-      events: [
-        {
-          title: 'event 1',
-          start: '2016-09-04T01:00'
-        }
-      ]
-    }
-    affix('#cal')
+
+  pushOptions({
+    now: '2016-09-04',
+    defaultView: 'agendaWeek',
+    scrollTime: '00:00',
+    editable: true,
+    events: [
+      {
+        title: 'event 1',
+        start: '2016-09-04T01:00'
+      }
+    ]
   })
 
   it('disallows dragging when returning false', function(done) { // and given correct params
-    options.eventAllow = function(dropInfo, event) {
-      expect(typeof dropInfo).toBe('object')
-      expect(moment.isMoment(dropInfo.start)).toBe(true)
-      expect(moment.isMoment(dropInfo.end)).toBe(true)
-      expect(typeof event).toBe('object')
-      expect(event.title).toBe('event 1')
-      return false
+    var options = {
+      eventAllow: function(dropInfo, event) {
+        expect(typeof dropInfo).toBe('object')
+        expect(moment.isMoment(dropInfo.start)).toBe(true)
+        expect(moment.isMoment(dropInfo.end)).toBe(true)
+        expect(typeof event).toBe('object')
+        expect(event.title).toBe('event 1')
+        return false
+      }
     }
     spyOn(options, 'eventAllow').and.callThrough()
 
-    $('#cal').fullCalendar(options)
+    initCalendar(options)
 
     dragTimeGridEvent($('.fc-event'), '2016-09-04T03:00:00')
       .then(function(modifiedEvent) {
@@ -41,12 +39,14 @@ describe('eventAllow', function() {
   })
 
   it('allows dragging when returning true', function(done) {
-    options.eventAllow = function(dropInfo, event) {
-      return true
+    var options = {
+      eventAllow: function(dropInfo, event) {
+        return true
+      }
     }
     spyOn(options, 'eventAllow').and.callThrough()
 
-    $('#cal').fullCalendar(options)
+    initCalendar(options)
 
     dragTimeGridEvent($('.fc-event'), '2016-09-04T03:00:00')
       .then(function(modifiedEvent) {

+ 2 - 3
tests/lib/time-grid.js

@@ -3,15 +3,14 @@ import { getBoundingRect } from '../lib/dom-geom'
 
 export function dragTimeGridEvent(eventEl, dropDate) {
   return new Promise(function(resolve) {
-    var calendar = $('#cal').fullCalendar('getCalendar')
     var modifiedEvent = null
 
-    calendar.on('eventDragStop', function() {
+    currentCalendar.on('eventDragStop', function() {
       setTimeout(function() { // wait for eventDrop to be called
         resolve(modifiedEvent)
       })
     })
-    calendar.on('eventDrop', function(event) {
+    currentCalendar.on('eventDrop', function(event) {
       modifiedEvent = event
     })