Преглед изворни кода

bunch of manual test fixes

Adam Shaw пре 8 година
родитељ
комит
435df87ff8

+ 1 - 0
tests/event-data/lazyFetching.js

@@ -39,6 +39,7 @@ describe('lazyFetching', function() {
     })
 
     it('will fetch each new week range', function() {
+      var args
       var options = {
         events: function(start, end, timezone, callback) {
           callback([])

+ 0 - 1
tests/event-drag/repeating.js

@@ -1,4 +1,3 @@
-import * as EventDragUtils from './EventDragUtils'
 import * as TimeGridEventDragUtils from './TimeGridEventDragUtils'
 
 describe('event dragging on repeating events', function() {

+ 0 - 1
tests/event-drag/validRange.js

@@ -1,4 +1,3 @@
-import * as EventDragUtils from './EventDragUtils'
 import * as DayGridEventDragUtils from './DayGridEventDragUtils'
 
 

+ 3 - 1
tests/event-render/TimeGridEventRenderUtils.js

@@ -33,7 +33,7 @@ function checkEventRenderingMatch(expectedRects, eventEls) {
   var i, expectedRect
   var elRect
 
-  if (eventEls.length != expectedLength) {
+  if (eventEls.length !== expectedLength) {
     console.log('does not match element count')
     return false
   }
@@ -63,6 +63,8 @@ export function computeSpanRects(start, end) {
   var slotStructs = computeSlots()
   var dayI, dayStruct
   var slotI, slotStruct
+  var slotStart
+  var slotEnd
   var coverage
   var startTop = null
   var endTop = null

+ 1 - 1
tests/index.js

@@ -5,7 +5,7 @@ require('./jasmine-ext')
 var context = require.context(
   '.',
   true, // recursive?
-  /[^\/]+\/[^\/]+\.(js|ts)$/ // inside subdirectory
+  /[^/]+\/[^/]+\.(js|ts)$/ // inside subdirectory
 )
 
 context.keys().forEach(context)

+ 1 - 2
tests/legacy/addEventSource.js

@@ -71,8 +71,7 @@ describe('addEventSource', function() {
     var options = {}
     options.eventAfterAllRender = function() {
       callCnt++
-      if (callCnt == 2) { // once for initial render. second time for addEventSource
-        called = true
+      if (callCnt === 2) { // once for initial render. second time for addEventSource
 
         checkAllEvents()
         if (extraTestFunc) {

+ 1 - 2
tests/legacy/businessHours.js

@@ -1,7 +1,6 @@
 // most other businessHours tests are in background-events.js
 
 import { doElsMatchSegs, getBoundingRect } from '../lib/dom-utils'
-import { getTimeGridTop, getTimeGridDayEls, getTimeGridSlotEls } from '../lib/time-grid'
 
 describe('businessHours', function() {
   pushOptions({
@@ -263,7 +262,7 @@ describe('businessHours', function() {
   function getTimeGridSlotEls(timeDuration) {
     timeDuration = moment.duration(timeDuration)
     var date = $.fullCalendar.moment.utc('2016-01-01').time(timeDuration)
-    if (date.date() == 1) { // ensure no time overflow/underflow
+    if (date.date() === 1) { // ensure no time overflow/underflow
       return $('.fc-time-grid .fc-slats tr[data-time="' + date.format('HH:mm:ss') + '"]')
     } else {
       return $()

+ 0 - 5
tests/legacy/buttonIcons.js

@@ -40,7 +40,6 @@ describe('buttonIcons', function() {
       initCalendar()
       var $cal = $(currentCalendar.el)
       var prevBtn = $cal.find('.fc-prev-button')
-      var nextBtn = $cal.find('.fc-next-button')
       var prevYearBtn = $cal.find('.fc-prevYear-button')
       var nextYearBtn = $cal.find('.fc-nextYear-button')
 
@@ -60,10 +59,6 @@ describe('buttonIcons', function() {
     it('buttonIcons is ignored', function() {
       initCalendar()
       var $cal = $(currentCalendar.el)
-      var prevBtn = $cal.find('.fc-prev-button')
-      var nextBtn = $cal.find('.fc-next-button')
-      var prevYearBtn = $cal.find('.fc-prevYear-button')
-      var nextYearBtn = $cal.find('.fc-nextYear-button')
       var classesToSearch = [ '.fc-icon-left-single-arrow', '.fc-icon-right-double-arrow',
         '.fc-icon-right-single-arrow', '.fc-icon-left-double-arrow' ]
 

+ 1 - 1
tests/legacy/current-date.js

@@ -208,7 +208,7 @@ describe('current date', function() {
         options.now = options.defaultDate = '2014-06-01' // a Sunday
         options.weekends = false
         initCalendar(options)
-        view = currentCalendar.getView()
+        var view = currentCalendar.getView()
         expect(view.start).toEqualMoment('2014-06-02')
         expect(view.end).toEqualMoment('2014-06-03')
         expect(view.intervalStart).toEqualMoment('2014-06-02')

+ 0 - 1
tests/legacy/dayNamesShort.js

@@ -50,7 +50,6 @@ describe('short day names', function() {
             $('#cal').fullCalendar(settings)
 
             moment.locale(locale)
-            var dow = moment.localeData(locale)._week.dow
             var weekdays = moment.weekdaysShort()
 
             dayClasses.forEach(function(cls, index, classes) {

+ 2 - 4
tests/legacy/event-dnd.js

@@ -340,7 +340,6 @@ describe('eventDrop', function() {
     describe('when dragging a timed event with no end time', function() {
       it('should continue to only show the updated start time', function(done) {
         var dragged = false
-        var eventElm
 
         options.scrollTime = '01:00:00'
         options.height = 400 // short enough to make scrolling happen
@@ -352,7 +351,7 @@ describe('eventDrop', function() {
 
         init(
           function() {
-            eventElm = $('.fc-event .fc-time').simulate('drag', {
+            $('.fc-event .fc-time').simulate('drag', {
               dy: $('.fc-slats tr:eq(1)').height() * 2.9, // 1.5 hours
               onBeforeRelease: function() {
                 dragged = true
@@ -371,7 +370,6 @@ describe('eventDrop', function() {
     describe('when dragging a timed event with an end time', function() {
       it('should continue to show the updated start and end time', function(done) {
         var dragged = false
-        var eventElm
 
         options.scrollTime = '01:00:00'
         options.height = 400 // short enough to make scrolling happen
@@ -384,7 +382,7 @@ describe('eventDrop', function() {
 
         init(
           function() {
-            eventElm = $('.fc-event .fc-time').simulate('drag', {
+            $('.fc-event .fc-time').simulate('drag', {
               dy: $('.fc-slats tr:eq(1)').height() * 2.9, // 1.5 hours
               onBeforeRelease: function() {
                 dragged = true

+ 4 - 4
tests/legacy/event-obj.js

@@ -87,8 +87,8 @@ describe('event object creation', function() {
 
   it('allows ASP dates for start', function() {
     init({
-      start: '\/Date(1239018869048)\/',
-      end: '\/Date(1239105269048)\/'
+      start: '/Date(1239018869048)/',
+      end: '/Date(1239105269048)/'
     })
     expect(moment.isMoment(event.start)).toBe(true)
     expect(+event.start).toBe(1239018869048)
@@ -98,8 +98,8 @@ describe('event object creation', function() {
 
   it('produces null end when given an invalid ASP date end', function() {
     init({
-      start: '\/Date(1239018869048)\/',
-      end: '\/Date(1239018869048)\/' // same as start
+      start: '/Date(1239018869048)/',
+      end: '/Date(1239018869048)/' // same as start
     })
     expect(moment.isMoment(event.start)).toBe(true)
     expect(+event.start).toBe(1239018869048)

+ 0 - 4
tests/legacy/eventLimit-popoverDestroy.js

@@ -20,10 +20,6 @@ describe('eventLimit popover', function() {
     }
   })
 
-  function init() {
-    $('.fc-more').simulate('click')
-  }
-
   it('closes when user clicks the X and trigger eventDestroy for every render', function() {
     var eventsRendered = {}
     var renderCount = 0

+ 1 - 1
tests/legacy/eventMouseover.js

@@ -14,7 +14,7 @@ describe('eventMouseover', function() {
 
       it('will trigger a eventMouseout with updateEvent', function(done) {
 
-        var eventMouseoutSpy = spyOnCalendarCallback('eventMouseout', function(event, ev) {
+        spyOnCalendarCallback('eventMouseout', function(event, ev) {
           expect(typeof event).toBe('object')
           expect(typeof ev).toBe('object')
           done()

+ 1 - 2
tests/legacy/events-gcal.js

@@ -313,7 +313,7 @@ xdescribe('Google Calendar plugin', function() {
 
       if (cmds.length === 1) {
         expect(cmds).toEqual([ true ])
-      } else if (cmds.length == 2) {
+      } else if (cmds.length === 2) {
         expect(cmds).toEqual([ true, false ])
         done()
       }
@@ -324,7 +324,6 @@ xdescribe('Google Calendar plugin', function() {
   describe('removeEventSource', function() {
 
     it('works when specifying only the Google Calendar ID', function(done) {
-      var CALENDAR_ID = HOLIDAY_CALENDAR_ID
       var called = false
 
       options.googleCalendarApiKey = API_KEY

+ 0 - 1
tests/legacy/header-rendering.js

@@ -79,7 +79,6 @@ describe('header rendering', function() {
     [ true, false ].forEach(function(isRTL) {
       describe('when isRTL is ' + isRTL, function() {
         beforeEach(function() {
-          var options = {}
           $('#calendar').fullCalendar({
             header: {
               left: 'prev',

+ 1 - 1
tests/legacy/monthNames.js

@@ -53,7 +53,7 @@ describe('month name', function() {
 
               settings.defaultDate = $.fullCalendar.moment(referenceDate).add(index, 'months')
               settings.eventAfterAllRender = function() {
-                if (viewClass == 'month') { // with month view check for occurence of the monthname in the title
+                if (viewClass === 'month') { // with month view check for occurence of the monthname in the title
                   expect($('.fc-toolbar h2')).toContainText(localeMonth)
                 } else { // with day views ensure that title contains the properly formatted phrase
                   expect($('.fc-toolbar h2')).toHaveText(settings.defaultDate.format('LL'))

+ 1 - 1
tests/legacy/navLinks.js

@@ -166,7 +166,7 @@ describe('navLinks', function() {
   }
 
   function getCurrentViewName() {
-    return $('.fc-view').attr('class').match(/fc\-(\w+)\-view/)[1]
+    return $('.fc-view').attr('class').match(/fc-(\w+)-view/)[1]
   }
 
   // day headers (for both day grid and time grid)

+ 2 - 2
tests/legacy/refetchEvents.js

@@ -28,14 +28,14 @@ describe('refetchEvents', function() {
         eventAfterAllRender: function() {
           var scrollEl = $('.fc-time-grid-container.fc-scroller')
           renderCalls++
-          if (renderCalls == 1) {
+          if (renderCalls === 1) {
             setTimeout(function() {
               scrollEl.scrollTop(100)
               setTimeout(function() {
                 $('#cal').fullCalendar('refetchEvents')
               }, 100)
             }, 100)
-          } else if (renderCalls == 2) {
+          } else if (renderCalls === 2) {
             expect(scrollEl.scrollTop()).toBe(100)
             done()
           }

+ 2 - 2
tests/legacy/titleFormat.js

@@ -142,7 +142,7 @@ describe('titleFormat', function() {
         defaultDate: '2014-12-25',
         titleRangeSeparator: ' - '
       })
-      expect($('h2').text()).toMatch(/Dec 21\,? 2014 \- Jan 3\,? 2015/)
+      expect($('h2').text()).toMatch(/Dec 21,? 2014 - Jan 3,? 2015/)
     })
 
     it('multi-day default displays short full date', function() {
@@ -157,7 +157,7 @@ describe('titleFormat', function() {
         defaultDate: '2014-12-25',
         titleRangeSeparator: ' - '
       })
-      expect($('h2').text()).toMatch(/Dec 25 \- 26\,? 2014/)
+      expect($('h2').text()).toMatch(/Dec 25 - 26,? 2014/)
     })
   })
 

+ 0 - 23
tests/legacy/updateEvent.js

@@ -1,9 +1,6 @@
 
 describe('updateEvent', function() {
-
   var options
-  var event
-  var relatedEvent
 
   beforeEach(function() {
     affix('#cal')
@@ -11,8 +8,6 @@ describe('updateEvent', function() {
       defaultDate: '2014-05-01',
       defaultView: 'month'
     }
-    event = null
-    relatedEvent = null
   })
 
   function getMainEvent() {
@@ -633,24 +628,6 @@ describe('updateEvent', function() {
     })
   }
 
-  function whenReportingUnchanged(should) { // not used right now
-    describe('when reporting an event that hasn\'t changed', function() {
-      beforeEach(function() {
-        var event
-
-        options.events = [
-          { id: '1', start: '2014-05-01T06:00:00+05:00', end: '2014-05-03T06:00:00+05:00', allDay: false, className: 'mainEvent' },
-          { id: '1', start: '2014-05-11T06:00:00+05:00', end: '2014-05-13T06:00:00+05:00', allDay: false, className: 'relatedEvent' }
-        ]
-        $('#cal').fullCalendar(options)
-
-        event = getMainEvent()
-        $('#cal').fullCalendar('updateEvent', event)
-      })
-      should()
-    })
-  }
-
   function shouldBeAmbiguouslyZoned() {
     it('should make the events ambiguously zoned', function() {
       var event = getMainEvent()

+ 3 - 2
tests/lib/dnd-resize-utils.js

@@ -66,10 +66,10 @@ export function testEventDrag(options, dropDate, expectSuccess, callback, eventC
           }
 
           if (dropDate.hasTime()) { // dropped on a slot
-            successfulDrop = eventObj.start.format() == dropDate.format() // compare exact times
+            successfulDrop = eventObj.start.format() === dropDate.format() // compare exact times
           } else { // dropped on a whole day
             // only compare days
-            successfulDrop = eventObj.start.format('YYYY-MM-DD') == dropDate.format('YYYY-MM-DD')
+            successfulDrop = eventObj.start.format('YYYY-MM-DD') === dropDate.format('YYYY-MM-DD')
           }
 
           expect(successfulDrop).toBe(allowed)
@@ -157,6 +157,7 @@ export function testEventResize(options, resizeDate, expectSuccess, callback, ev
 export function testSelection(options, startTime, end, expectSuccess, callback) {
   var successfulSelection = false
   var calendar
+  var start
   var firstDayEl, lastDayEl
   var firstSlatIndex, lastSlatIndex
   var firstSlatEl, lastSlatEl

+ 2 - 2
tests/lib/geom.js

@@ -21,8 +21,8 @@ export function buildRectViaDims(left, top, width, height) {
     top: top,
     width: width,
     height: height,
-    right: x + width,
-    bottom: y + height
+    right: left + width,
+    bottom: top + height
   }
 }
 

+ 5 - 5
tests/lib/time-grid.js

@@ -48,7 +48,7 @@ export function selectTimeGrid(start, inclusiveEnd) {
 
 
 function getTimeGridPoint(date) {
-  var date = $.fullCalendar.moment.parseZone(date)
+  date = $.fullCalendar.moment.parseZone(date)
   var top = getTimeGridTop(date.time())
   var dayEls = getTimeGridDayEls(date)
   var dayRect
@@ -64,7 +64,7 @@ function getTimeGridPoint(date) {
 
 
 export function getTimeGridLine(date) { // not in Scheduler
-  var date = $.fullCalendar.moment.parseZone(date)
+  date = $.fullCalendar.moment.parseZone(date)
   var top = getTimeGridTop(date.time())
   var dayEls = getTimeGridDayEls(date)
   var dayRect
@@ -82,7 +82,7 @@ export function getTimeGridLine(date) { // not in Scheduler
 
 
 export function getTimeGridTop(time) {
-  var time = moment.duration(time)
+  time = moment.duration(time)
   var slotEls = getTimeGridSlotEls(time)
 
   expect(slotEls.length).toBe(1)
@@ -92,14 +92,14 @@ export function getTimeGridTop(time) {
 
 
 export function getTimeGridDayEls(date) {
-  var date = $.fullCalendar.moment.parseZone(date)
+  date = $.fullCalendar.moment.parseZone(date)
 
   return $('.fc-time-grid .fc-day[data-date="' + date.format('YYYY-MM-DD') + '"]')
 }
 
 
 export function getTimeGridSlotEls(timeDuration) {
-  var timeDuration = moment.duration(timeDuration)
+  timeDuration = moment.duration(timeDuration)
   var date = $.fullCalendar.moment.utc('2016-01-01').time(timeDuration)
 
   return $('.fc-time-grid .fc-slats tr[data-time="' + date.format('HH:mm:ss') + '"]')