Parcourir la source

more test retrofitting

Adam Shaw il y a 7 ans
Parent
commit
f1f2006e5f

+ 1 - 1
src/models/event/EventDefDateMutation.ts

@@ -1,6 +1,6 @@
 import Calendar from '../../Calendar'
 import EventDateProfile from './EventDateProfile'
-import { startOfDay, diffWholeDays, diffDayAndTime } from '../../datelib/marker'
+import { startOfDay, diffDayAndTime } from '../../datelib/marker'
 import { Duration, createDuration, subtractDurations } from '../../datelib/duration'
 
 export default class EventDefDateMutation {

+ 52 - 44
tests/automated/legacy/businessHours.js

@@ -7,6 +7,7 @@ import { getTimeGridTop, getTimeGridDayEls } from '../lib/time-grid'
 
 describe('businessHours', function() {
   pushOptions({
+    timezone: 'UTC',
     defaultDate: '2014-11-25',
     defaultView: 'month',
     businessHours: true
@@ -24,24 +25,24 @@ describe('businessHours', function() {
     // timed area
     expect(isTimeGridNonBusinessSegsRendered([
       // sun
-      { start: '2014-12-07T00:00', end: '2014-12-08T00:00' },
+      { start: '2014-12-07T00:00Z', end: '2014-12-08T00:00Z' },
       // mon
-      { start: '2014-12-08T00:00', end: '2014-12-08T09:00' },
-      { start: '2014-12-08T17:00', end: '2014-12-09T00:00' },
+      { start: '2014-12-08T00:00Z', end: '2014-12-08T09:00Z' },
+      { start: '2014-12-08T17:00Z', end: '2014-12-09T00:00Z' },
       // tue
-      { start: '2014-12-09T00:00', end: '2014-12-09T09:00' },
-      { start: '2014-12-09T17:00', end: '2014-12-10T00:00' },
+      { start: '2014-12-09T00:00Z', end: '2014-12-09T09:00Z' },
+      { start: '2014-12-09T17:00Z', end: '2014-12-10T00:00Z' },
       // wed
-      { start: '2014-12-10T00:00', end: '2014-12-10T09:00' },
-      { start: '2014-12-10T17:00', end: '2014-12-11T00:00' },
+      { start: '2014-12-10T00:00Z', end: '2014-12-10T09:00Z' },
+      { start: '2014-12-10T17:00Z', end: '2014-12-11T00:00Z' },
       // thu
-      { start: '2014-12-11T00:00', end: '2014-12-11T09:00' },
-      { start: '2014-12-11T17:00', end: '2014-12-12T00:00' },
+      { start: '2014-12-11T00:00Z', end: '2014-12-11T09:00Z' },
+      { start: '2014-12-11T17:00Z', end: '2014-12-12T00:00Z' },
       // fri
-      { start: '2014-12-12T00:00', end: '2014-12-12T09:00' },
-      { start: '2014-12-12T17:00', end: '2014-12-13T00:00' },
+      { start: '2014-12-12T00:00Z', end: '2014-12-12T09:00Z' },
+      { start: '2014-12-12T17:00Z', end: '2014-12-13T00:00Z' },
       // sat
-      { start: '2014-12-13T00:00', end: '2014-12-14T00:00' }
+      { start: '2014-12-13T00:00Z', end: '2014-12-14T00:00Z' }
     ])).toBe(true)
   })
 
@@ -105,24 +106,24 @@ describe('businessHours', function() {
       // timed area
       expect(isTimeGridNonBusinessSegsRendered([
         // sun
-        { start: '2014-12-07T00:00', end: '2014-12-08T00:00' },
+        { start: '2014-12-07T00:00Z', end: '2014-12-08T00:00Z' },
         // mon
-        { start: '2014-12-08T00:00', end: '2014-12-08T08:00' },
-        { start: '2014-12-08T18:00', end: '2014-12-09T00:00' },
+        { start: '2014-12-08T00:00Z', end: '2014-12-08T08:00Z' },
+        { start: '2014-12-08T18:00Z', end: '2014-12-09T00:00Z' },
         // tue
-        { start: '2014-12-09T00:00', end: '2014-12-09T08:00' },
-        { start: '2014-12-09T18:00', end: '2014-12-10T00:00' },
+        { start: '2014-12-09T00:00Z', end: '2014-12-09T08:00Z' },
+        { start: '2014-12-09T18:00Z', end: '2014-12-10T00:00Z' },
         // wed
-        { start: '2014-12-10T00:00', end: '2014-12-10T08:00' },
-        { start: '2014-12-10T18:00', end: '2014-12-11T00:00' },
+        { start: '2014-12-10T00:00Z', end: '2014-12-10T08:00Z' },
+        { start: '2014-12-10T18:00Z', end: '2014-12-11T00:00Z' },
         // thu
-        { start: '2014-12-11T00:00', end: '2014-12-11T10:00' },
-        { start: '2014-12-11T16:00', end: '2014-12-12T00:00' },
+        { start: '2014-12-11T00:00Z', end: '2014-12-11T10:00Z' },
+        { start: '2014-12-11T16:00Z', end: '2014-12-12T00:00Z' },
         // fri
-        { start: '2014-12-12T00:00', end: '2014-12-12T10:00' },
-        { start: '2014-12-12T16:00', end: '2014-12-13T00:00' },
+        { start: '2014-12-12T00:00Z', end: '2014-12-12T10:00Z' },
+        { start: '2014-12-12T16:00Z', end: '2014-12-13T00:00Z' },
         // sat
-        { start: '2014-12-13T00:00', end: '2014-12-14T00:00' }
+        { start: '2014-12-13T00:00Z', end: '2014-12-14T00:00Z' }
       ])).toBe(true)
     })
 
@@ -147,21 +148,21 @@ describe('businessHours', function() {
       // timed area
       expect(isTimeGridNonBusinessSegsRendered([
         // sun
-        { start: '2014-12-07T00:00', end: '2014-12-08T00:00' },
+        { start: '2014-12-07T00:00Z', end: '2014-12-08T00:00Z' },
         // mon
-        { start: '2014-12-08T00:00', end: '2014-12-09T00:00' },
+        { start: '2014-12-08T00:00Z', end: '2014-12-09T00:00Z' },
         // tue
-        { start: '2014-12-09T00:00', end: '2014-12-10T00:00' },
+        { start: '2014-12-09T00:00Z', end: '2014-12-10T00:00Z' },
         // wed
-        { start: '2014-12-10T00:00', end: '2014-12-11T00:00' },
+        { start: '2014-12-10T00:00Z', end: '2014-12-11T00:00Z' },
         // thu
-        { start: '2014-12-11T00:00', end: '2014-12-11T10:00' },
-        { start: '2014-12-11T16:00', end: '2014-12-12T00:00' },
+        { start: '2014-12-11T00:00Z', end: '2014-12-11T10:00Z' },
+        { start: '2014-12-11T16:00Z', end: '2014-12-12T00:00Z' },
         // fri
-        { start: '2014-12-12T00:00', end: '2014-12-12T10:00' },
-        { start: '2014-12-12T16:00', end: '2014-12-13T00:00' },
+        { start: '2014-12-12T00:00Z', end: '2014-12-12T10:00Z' },
+        { start: '2014-12-12T16:00Z', end: '2014-12-13T00:00Z' },
         // sat
-        { start: '2014-12-13T00:00', end: '2014-12-14T00:00' }
+        { start: '2014-12-13T00:00Z', end: '2014-12-14T00:00Z' }
       ])).toBe(true)
     })
   })
@@ -176,7 +177,7 @@ describe('businessHours', function() {
 
     // timed area
     expect(isTimeGridNonBusinessSegsRendered([
-      { start: '2016-07-23T00:00', end: '2016-07-24T00:00' }
+      { start: '2016-07-23T00:00Z', end: '2016-07-24T00:00Z' }
     ])).toBe(true)
   })
 
@@ -200,17 +201,24 @@ describe('businessHours', function() {
       end = obj.end
     }
 
-    start = FullCalendar.moment.parseZone(start)
-    end = FullCalendar.moment.parseZone(end)
+    if (typeof start === 'string') {
+      start = new Date(start)
+    }
+    if (typeof end === 'string') {
+      end = new Date(end)
+    }
+
+    var startDay = FullCalendar.startOfDay(start)
+    var endDay = FullCalendar.startOfDay(end)
+    var startTimeMs = start.valueOf() - startDay.valueOf()
+    var endTimeMs = end.valueOf() - endDay.valueOf()
 
-    var startTime = start.time()
-    var endTime
-    if (end.isSame(start, 'day')) {
-      endTime = end.time()
+    if (startDay.valueOf() === endDay.valueOf()) {
+      endTimeMs = end.valueOf() - endDay.valueOf()
     } else if (end < start) {
-      endTime = startTime
+      endTimeMs = startTimeMs
     } else {
-      endTime = moment.duration({ hours: 24 })
+      endTimeMs = 1000 * 60 * 60 * 24 // whole day
     }
 
     var dayEls = getTimeGridDayEls(start)
@@ -218,8 +226,8 @@ describe('businessHours', function() {
     return {
       left: dayRect.left,
       right: dayRect.right,
-      top: getTimeGridTop(startTime),
-      bottom: getTimeGridTop(endTime)
+      top: getTimeGridTop(startTimeMs),
+      bottom: getTimeGridTop(endTimeMs)
     }
   }
 

+ 30 - 24
tests/automated/legacy/columnHeaderFormat.js

@@ -3,11 +3,13 @@ describe('columnHeaderFormat', function() {
 
   describe('when columnFormat is not set', function() {
 
-    var viewWithFormat = [ { view: 'month', expected: 'Sun', selector: 'th.fc-day-header.fc-sun' },
+    var viewWithFormat = [
+      { view: 'month', expected: 'Sun', selector: 'th.fc-day-header.fc-sun' },
       { view: 'basicWeek', expected: 'Sun 5/11', selector: 'th.fc-day-header.fc-sun' },
       { view: 'agendaWeek', expected: 'Sun 5/11', selector: 'th.fc-widget-header.fc-sun' },
       { view: 'basicDay', expected: 'Sunday', selector: 'th.fc-day-header.fc-sun' },
-      { view: 'agendaDay', expected: 'Sunday', selector: 'th.fc-widget-header.fc-sun' } ]
+      { view: 'agendaDay', expected: 'Sunday', selector: 'th.fc-widget-header.fc-sun' }
+    ]
 
     beforeEach(function() {
       initCalendar({
@@ -27,21 +29,19 @@ describe('columnHeaderFormat', function() {
 
   describe('when columnHeaderFormat is set on a per-view basis', function() {
 
-    var viewWithFormat = [ { view: 'month', expected: 'Sunday', selector: 'th.fc-day-header.fc-sun' },
-      { view: 'basicWeek', expected: 'Sunday 11 - 5', selector: 'th.fc-day-header.fc-sun' },
-      { view: 'agendaWeek', expected: 'Sunday 11 , 5', selector: 'th.fc-widget-header.fc-sun' },
-      { view: 'basicDay', expected: 'Sunday 11 | 5', selector: 'th.fc-day-header.fc-sun' },
-      { view: 'agendaDay', expected: 'Sunday 5/11', selector: 'th.fc-widget-header.fc-sun' } ]
+    var viewWithFormat = [
+      { view: 'month', expected: 'Sunday', selector: 'th.fc-day-header.fc-sun' },
+      { view: 'agendaDay', expected: 'Sunday, May 11', selector: 'th.fc-widget-header.fc-sun' },
+      { view: 'basicWeek', expected: 'Sunday, 5/11', selector: 'th.fc-day-header.fc-sun' }
+    ]
 
     beforeEach(function() {
       initCalendar({
         defaultDate: '2014-05-11',
         views: {
-          month: { columnHeaderFormat: 'dddd' },
-          agendaDay: { columnHeaderFormat: 'dddd M/D' },
-          agendaWeek: { columnHeaderFormat: 'dddd D , M' },
-          basicDay: { columnHeaderFormat: 'dddd D | M' },
-          basicWeek: { columnHeaderFormat: 'dddd D - M' }
+          month: { columnHeaderFormat: { weekday: 'long' } },
+          agendaDay: { columnHeaderFormat: { weekday: 'long', month: 'long', day: 'numeric' } },
+          basicWeek: { columnHeaderFormat: { weekday: 'long', month: 'numeric', day: 'numeric' } }
         }
       })
     })
@@ -58,11 +58,13 @@ describe('columnHeaderFormat', function() {
 
   describe('when locale is French', function() {
 
-    var viewWithFormat = [ { view: 'month', expected: 'dim.', selector: 'th.fc-day-header.fc-sun' },
-      { view: 'basicWeek', expected: 'dim. 11/5', selector: 'th.fc-day-header.fc-sun' },
-      { view: 'agendaWeek', expected: 'dim. 11/5', selector: 'th.fc-widget-header.fc-sun' },
+    var viewWithFormat = [
+      { view: 'month', expected: 'dim.', selector: 'th.fc-day-header.fc-sun' },
+      { view: 'basicWeek', expected: 'dim. 11/05', selector: 'th.fc-day-header.fc-sun' },
+      { view: 'agendaWeek', expected: 'dim. 11/05', selector: 'th.fc-widget-header.fc-sun' },
       { view: 'basicDay', expected: 'dimanche', selector: 'th.fc-day-header.fc-sun' },
-      { view: 'agendaDay', expected: 'dimanche', selector: 'th.fc-widget-header.fc-sun' } ]
+      { view: 'agendaDay', expected: 'dimanche', selector: 'th.fc-widget-header.fc-sun' }
+    ]
 
     beforeEach(function() {
       initCalendar({
@@ -83,11 +85,13 @@ describe('columnHeaderFormat', function() {
 
   describe('when locale is en-gb', function() {
 
-    var viewWithFormat = [ { view: 'month', expected: 'Sun', selector: 'th.fc-day-header.fc-sun' },
-      { view: 'basicWeek', expected: 'Sun 11/5', selector: 'th.fc-day-header.fc-sun' },
-      { view: 'agendaWeek', expected: 'Sun 11/5', selector: 'th.fc-widget-header.fc-sun' },
+    var viewWithFormat = [
+      { view: 'month', expected: 'Sun', selector: 'th.fc-day-header.fc-sun' },
+      { view: 'basicWeek', expected: 'Sun 11/05', selector: 'th.fc-day-header.fc-sun' },
+      { view: 'agendaWeek', expected: 'Sun 11/05', selector: 'th.fc-widget-header.fc-sun' },
       { view: 'basicDay', expected: 'Sunday', selector: 'th.fc-day-header.fc-sun' },
-      { view: 'agendaDay', expected: 'Sunday', selector: 'th.fc-widget-header.fc-sun' } ]
+      { view: 'agendaDay', expected: 'Sunday', selector: 'th.fc-widget-header.fc-sun' }
+    ]
 
     beforeEach(function() {
       initCalendar({
@@ -108,11 +112,13 @@ describe('columnHeaderFormat', function() {
 
   describe('when locale is Korean', function() {
 
-    var viewWithFormat = [ { view: 'month', expected: '일', selector: 'th.fc-day-header.fc-sun' },
-      { view: 'basicWeek', expected: '일 05.11.', selector: 'th.fc-day-header.fc-sun' },
-      { view: 'agendaWeek', expected: '일 05.11.', selector: 'th.fc-widget-header.fc-sun' },
+    var viewWithFormat = [
+      { view: 'month', expected: '일', selector: 'th.fc-day-header.fc-sun' },
+      { view: 'basicWeek', expected: '5. 11. (일)', selector: 'th.fc-day-header.fc-sun' },
+      { view: 'agendaWeek', expected: '5. 11. (일)', selector: 'th.fc-widget-header.fc-sun' },
       { view: 'basicDay', expected: '일요일', selector: 'th.fc-day-header.fc-sun' },
-      { view: 'agendaDay', expected: '일요일', selector: 'th.fc-widget-header.fc-sun' } ]
+      { view: 'agendaDay', expected: '일요일', selector: 'th.fc-widget-header.fc-sun' }
+    ]
 
     beforeEach(function() {
       initCalendar({

+ 55 - 36
tests/automated/legacy/current-date.js

@@ -1,10 +1,16 @@
 describe('current date', function() {
+  var TITLE_FORMAT = {
+    month: 'long',
+    day: 'numeric',
+    year: 'numeric',
+    separator: ' - '
+  }
 
-  var TITLE_FORMAT = 'MMMM D YYYY'
   pushOptions({
     titleFormat: TITLE_FORMAT,
     titleRangeSeparator: ' - ',
-    defaultDate: '2014-06-01'
+    defaultDate: '2014-06-01',
+    timezone: 'UTC'
   })
 
   describe('defaultDate & getDate', function() { // keep getDate
@@ -15,8 +21,8 @@ describe('current date', function() {
         initCalendar(options)
         expectViewDates('2011-02-27', '2011-04-10', '2011-03-01', '2011-04-01')
         var currentDate = currentCalendar.getDate()
-        expect(moment.isMoment(currentDate)).toEqual(true) // test the type, but only here
-        expect(currentDate).toEqualMoment('2011-03-10')
+        expect(currentDate instanceof Date).toEqual(true) // test the type, but only here
+        expect(currentDate).toEqualDate('2011-03-10')
       })
     })
     describeWhenInWeek(function() {
@@ -25,14 +31,14 @@ describe('current date', function() {
         options.defaultDate = '2011-03-10'
         initCalendar(options)
         expectViewDates('2011-03-06', '2011-03-13')
-        expect(currentCalendar.getDate()).toEqualMoment('2011-03-10')
+        expect(currentCalendar.getDate()).toEqualDate('2011-03-10')
       })
-      it('should initialize at the date, given a Moment object', function() {
+      it('should initialize at the date, given a Date object', function() {
         var options = {}
-        options.defaultDate = FullCalendar.moment('2011-03-10')
+        options.defaultDate = new Date('2011-03-10')
         initCalendar(options)
         expectViewDates('2011-03-06', '2011-03-13')
-        expect(currentCalendar.getDate()).toEqualMoment('2011-03-10')
+        expect(currentCalendar.getDate()).toEqualDate('2011-03-10')
       })
     })
     describeWhenInDay(function() {
@@ -41,7 +47,7 @@ describe('current date', function() {
         options.defaultDate = '2011-03-10'
         initCalendar(options)
         expectViewDates('2011-03-10')
-        expect(currentCalendar.getDate()).toEqualMoment('2011-03-10')
+        expect(currentCalendar.getDate()).toEqualDate('2011-03-10')
       })
     })
   })
@@ -65,9 +71,9 @@ describe('current date', function() {
         currentCalendar.gotoDate('2015-04-01T12:00:00')
         expectViewDates('2015-03-29', '2015-04-05')
       })
-      it('should go to a date when given a moment object', function() {
+      it('should go to a date when given a Date object', function() {
         initCalendar()
-        currentCalendar.gotoDate(FullCalendar.moment('2015-04-01'))
+        currentCalendar.gotoDate(new Date('2015-04-01'))
         expectViewDates('2015-03-29', '2015-04-05')
       })
     })
@@ -170,10 +176,10 @@ describe('current date', function() {
         options.weekends = false
         initCalendar(options)
         var view = currentCalendar.getView()
-        expect(view.start).toEqualMoment('2014-06-02')
-        expect(view.end).toEqualMoment('2014-07-12')
-        expect(view.intervalStart).toEqualMoment('2014-06-01')
-        expect(view.intervalEnd).toEqualMoment('2014-07-01')
+        expect(view.start).toEqualDate('2014-06-02')
+        expect(view.end).toEqualDate('2014-07-12')
+        expect(view.intervalStart).toEqualDate('2014-06-01')
+        expect(view.intervalEnd).toEqualDate('2014-07-01')
       })
       it('should display the current month', function() {
         var options = {}
@@ -181,10 +187,10 @@ describe('current date', function() {
         options.weekends = false
         initCalendar(options)
         var view = currentCalendar.getView()
-        expect(view.start).toEqualMoment('2014-04-28')
-        expect(view.end).toEqualMoment('2014-06-07')
-        expect(view.intervalStart).toEqualMoment('2014-05-01')
-        expect(view.intervalEnd).toEqualMoment('2014-06-01')
+        expect(view.start).toEqualDate('2014-04-28')
+        expect(view.end).toEqualDate('2014-06-07')
+        expect(view.intervalStart).toEqualDate('2014-05-01')
+        expect(view.intervalEnd).toEqualDate('2014-06-01')
       })
       describe('when navigating back a month', function() {
         it('should not skip months', function() {
@@ -193,12 +199,12 @@ describe('current date', function() {
           options.weekends = false
           initCalendar(options)
           var view = currentCalendar.getView()
-          expect(view.intervalStart).toEqualMoment('2014-07-01')
-          expect(view.intervalEnd).toEqualMoment('2014-08-01')
+          expect(view.intervalStart).toEqualDate('2014-07-01')
+          expect(view.intervalEnd).toEqualDate('2014-08-01')
           currentCalendar.prev() // will move to Jun 1, which is a Sunday
           view = currentCalendar.getView()
-          expect(view.intervalStart).toEqualMoment('2014-06-01')
-          expect(view.intervalEnd).toEqualMoment('2014-07-01')
+          expect(view.intervalStart).toEqualDate('2014-06-01')
+          expect(view.intervalEnd).toEqualDate('2014-07-01')
         })
       })
     })
@@ -209,10 +215,10 @@ describe('current date', function() {
         options.weekends = false
         initCalendar(options)
         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')
-        expect(view.intervalEnd).toEqualMoment('2014-06-03')
+        expect(view.start).toEqualDate('2014-06-02')
+        expect(view.end).toEqualDate('2014-06-03')
+        expect(view.intervalStart).toEqualDate('2014-06-02')
+        expect(view.intervalEnd).toEqualDate('2014-06-03')
       })
     })
   })
@@ -247,20 +253,33 @@ describe('current date', function() {
     var calculatedEnd
     var title
 
-    start = FullCalendar.moment(start)
-    calculatedEnd = end ? FullCalendar.moment(end) : start.clone().add(1, 'days')
-    expect(start).toEqualMoment(view.start)
-    expect(calculatedEnd).toEqualMoment(view.end)
+    if (typeof start === 'string') {
+      start = new Date(start)
+    }
+    if (typeof end === 'string') {
+      end = new Date(end)
+    }
+    if (typeof titleStart === 'string') {
+      titleStart = new Date(titleStart)
+    }
+    if (typeof titleEnd === 'string') {
+      titleEnd = new Date(titleEnd)
+    }
+
+    calculatedEnd = end || FullCalendar.addDays(start, 1)
+
+    expect(start).toEqualDate(view.start)
+    expect(calculatedEnd).toEqualDate(view.end)
 
-    titleStart = titleStart ? FullCalendar.moment(titleStart) : start
-    titleEnd = titleEnd ? FullCalendar.moment(titleEnd) : calculatedEnd
+    titleStart = titleStart || start
+    titleEnd = titleEnd || calculatedEnd
 
     if (titleEnd) {
-      title = FullCalendar.formatRange(
+      title = currentCalendar.formatRange(
         titleStart,
-        titleEnd.clone().add(-1, 'ms'),
+        titleEnd,
         TITLE_FORMAT,
-        ' - '
+        true // isEndExclusive
       )
     } else {
       title = titleStart.format(TITLE_FORMAT)

+ 4 - 4
tests/automated/legacy/custom-view-class.js

@@ -16,15 +16,15 @@ describe('custom view class', function() {
       renderEvents: function(events) {
         expect($.type(events)).toBe('array')
         expect(events.length).toBe(1)
-        expect(moment.isMoment(events[0].start)).toBe(true)
-        expect(moment.isMoment(events[0].end)).toBe(true)
+        expect(events[0].start instanceof Date).toBe(true)
+        expect(events[0].end instanceof Date).toBe(true)
       },
       destroyEvents: function() {
       },
       renderSelection: function(range) {
         expect($.type(range)).toBe('object')
-        expect(moment.isMoment(range.start)).toBe(true)
-        expect(moment.isMoment(range.end)).toBe(true)
+        expect(range.start instanceof Date).toBe(true)
+        expect(range.end instanceof Date).toBe(true)
       },
       destroySelection: function() {
       }

+ 44 - 39
tests/automated/legacy/dayClick.js

@@ -1,26 +1,29 @@
 describe('dayClick', function() {
   pushOptions({
     defaultDate: '2014-05-27',
-    selectable: false
+    selectable: false,
+    timezone: 'UTC'
   });
+
   [ false, true ].forEach(function(isRTL) {
     describe('when isRTL is ' + isRTL, function() {
 
-      pushOptions({isRTL: isRTL});
+      pushOptions({ isRTL: isRTL });
 
       [ false, true ].forEach(function(selectable) {
         describe('when selectable is ' + selectable, function() {
           pushOptions({selectable: selectable})
           describe('when in month view', function() {
             pushOptions({defaultView: 'month'})
+
             it('fires correctly when clicking on a cell', function(done) {
               var options = {}
-              options.dayClick = function(date, jsEvent, view) {
-                expect(moment.isMoment(date)).toEqual(true)
-                expect(typeof jsEvent).toEqual('object') // TODO: more descrimination
-                expect(typeof view).toEqual('object') // "
-                expect(date.hasTime()).toEqual(false)
-                expect(date).toEqualMoment('2014-05-07')
+              options.dayClick = function(arg) {
+                expect(arg.date instanceof Date).toEqual(true)
+                expect(typeof arg.jsEvent).toEqual('object') // TODO: more descrimination
+                expect(typeof arg.view).toEqual('object') // "
+                expect(arg.isAllDay).toEqual(true)
+                expect(arg.date).toEqualDate('2014-05-07')
               }
               spyOn(options, 'dayClick').and.callThrough()
               initCalendar(options)
@@ -39,14 +42,15 @@ describe('dayClick', function() {
 
           describe('when in agendaWeek view', function() {
             pushOptions({defaultView: 'agendaWeek'})
+
             it('fires correctly when clicking on an all-day slot', function(done) {
               var options = {}
-              options.dayClick = function(date, jsEvent, view) {
-                expect(moment.isMoment(date)).toEqual(true)
-                expect(typeof jsEvent).toEqual('object') // TODO: more descrimination
-                expect(typeof view).toEqual('object') // "
-                expect(date.hasTime()).toEqual(false)
-                expect(date).toEqualMoment('2014-05-28')
+              options.dayClick = function(arg) {
+                expect(arg.date instanceof Date).toEqual(true)
+                expect(typeof arg.jsEvent).toEqual('object') // TODO: more descrimination
+                expect(typeof arg.view).toEqual('object') // "
+                expect(arg.isAllDay).toEqual(true)
+                expect(arg.date).toEqualDate('2014-05-28')
               }
               spyOn(options, 'dayClick').and.callThrough()
               initCalendar(options)
@@ -62,18 +66,19 @@ describe('dayClick', function() {
                 }
               })
             })
+
             it('fires correctly when clicking on a timed slot', function(done) {
               var options = {}
               // make sure the click slot will be in scroll view
               options.contentHeight = 500
               options.scrollTime = '07:00:00'
 
-              options.dayClick = function(date, jsEvent, view) {
-                expect(moment.isMoment(date)).toEqual(true)
-                expect(typeof jsEvent).toEqual('object') // TODO: more descrimination
-                expect(typeof view).toEqual('object') // "
-                expect(date.hasTime()).toEqual(true)
-                expect(date).toEqualMoment('2014-05-28T09:00:00')
+              options.dayClick = function(arg) {
+                expect(arg.date instanceof Date).toEqual(true)
+                expect(typeof arg.jsEvent).toEqual('object') // TODO: more descrimination
+                expect(typeof arg.view).toEqual('object') // "
+                expect(arg.isAllDay).toEqual(false)
+                expect(arg.date).toEqualDate('2014-05-28T09:00:00Z')
               }
               spyOn(options, 'dayClick').and.callThrough()
               initCalendar(options)
@@ -98,12 +103,12 @@ describe('dayClick', function() {
               options.scrollTime = '07:00:00'
               options.minTime = '02:00:00'
 
-              options.dayClick = function(date, jsEvent, view) {
-                expect(moment.isMoment(date)).toEqual(true)
-                expect(typeof jsEvent).toEqual('object') // TODO: more descrimination
-                expect(typeof view).toEqual('object') // "
-                expect(date.hasTime()).toEqual(true)
-                expect(date).toEqualMoment('2014-05-28T11:00:00')
+              options.dayClick = function(arg) {
+                expect(arg.date instanceof Date).toEqual(true)
+                expect(typeof arg.jsEvent).toEqual('object') // TODO: more descrimination
+                expect(typeof arg.view).toEqual('object') // "
+                expect(arg.isAllDay).toEqual(false)
+                expect(arg.date).toEqualDate('2014-05-28T11:00:00Z')
               }
               spyOn(options, 'dayClick').and.callThrough()
               initCalendar(options)
@@ -129,12 +134,12 @@ describe('dayClick', function() {
 
     it('fires correctly when simulated short drag on a cell', function(done) {
       var options = {}
-      options.dayClick = function(date, jsEvent, view) {
-        expect(moment.isMoment(date)).toEqual(true)
-        expect(typeof jsEvent).toEqual('object') // TODO: more descrimination
-        expect(typeof view).toEqual('object') // "
-        expect(date.hasTime()).toEqual(false)
-        expect(date).toEqualMoment('2014-05-07')
+      options.dayClick = function(arg) {
+        expect(arg.date instanceof Date).toEqual(true)
+        expect(typeof arg.jsEvent).toEqual('object') // TODO: more descrimination
+        expect(typeof arg.view).toEqual('object') // "
+        expect(arg.isAllDay).toEqual(true)
+        expect(arg.date).toEqualDate('2014-05-07')
       }
       spyOn(options, 'dayClick').and.callThrough()
       initCalendar(options)
@@ -153,7 +158,7 @@ describe('dayClick', function() {
 
     it('won\'t fire if touch moves outside of date cell', function(done) {
       var options = {}
-      options.dayClick = function(date, jsEvent, view) {}
+      options.dayClick = function(arg) {}
       spyOn(options, 'dayClick').and.callThrough()
 
       initCalendar(options)
@@ -175,12 +180,12 @@ describe('dayClick', function() {
 
     it('fires correctly when simulated click on a cell', function(done) {
       var options = {}
-      options.dayClick = function(date, jsEvent, view) {
-        expect(moment.isMoment(date)).toEqual(true)
-        expect(typeof jsEvent).toEqual('object') // TODO: more descrimination
-        expect(typeof view).toEqual('object') // "
-        expect(date.hasTime()).toEqual(false)
-        expect(date).toEqualMoment('2014-05-07')
+      options.dayClick = function(arg) {
+        expect(arg.date instanceof Date).toEqual(true)
+        expect(typeof arg.jsEvent).toEqual('object') // TODO: more descrimination
+        expect(typeof arg.view).toEqual('object') // "
+        expect(arg.isAllDay).toEqual(true)
+        expect(arg.date).toEqualDate('2014-05-07')
       }
       spyOn(options, 'dayClick').and.callThrough()
       initCalendar(options)

+ 41 - 28
tests/automated/lib/time-grid.js

@@ -1,4 +1,5 @@
 import { getBoundingRect } from '../lib/dom-geom'
+import { formatIsoDay, formatIsoTime } from '../datelib/utils'
 
 
 export function dragTimeGridEvent(eventEl, dropDate) {
@@ -44,8 +45,14 @@ export function selectTimeGrid(start, inclusiveEnd) {
 
 
 export function getTimeGridPoint(date) {
-  date = FullCalendar.moment.parseZone(date)
-  var top = getTimeGridTop(date.time())
+
+  if (typeof date === 'string') {
+    date = new Date(date)
+  }
+
+  var day = FullCalendar.startOfDay(date)
+  var timeMs = date.valueOf() - day.valueOf()
+  var top = getTimeGridTop(timeMs)
   var dayEls = getTimeGridDayEls(date)
   var dayRect
 
@@ -60,8 +67,14 @@ export function getTimeGridPoint(date) {
 
 
 export function getTimeGridLine(date) { // not in Scheduler
-  date = FullCalendar.moment.parseZone(date)
-  var top = getTimeGridTop(date.time())
+
+  if (typeof date === 'string') {
+    date = new Date(date)
+  }
+
+  var day = FullCalendar.startOfDay(date)
+  var timeMs = date.valueOf() - day.valueOf()
+  var top = getTimeGridTop(timeMs)
   var dayEls = getTimeGridDayEls(date)
   var dayRect
 
@@ -77,14 +90,10 @@ export function getTimeGridLine(date) { // not in Scheduler
 }
 
 
-/*
-targetTime is a time (duration) that can be in between slots
-*/
-export function getTimeGridTop(targetTime) {
-  let slotEl
-  targetTime = moment.duration(targetTime)
-  let slotEls = getTimeGridSlotEls(targetTime)
+export function getTimeGridTop(targetTimeMs) {
   const topBorderWidth = 1 // TODO: kill
+  let slotEls = getTimeGridSlotEls(targetTimeMs)
+  let slotEl
 
   // exact slot match
   if (slotEls.length === 1) {
@@ -92,56 +101,60 @@ export function getTimeGridTop(targetTime) {
   }
 
   slotEls = $('.fc-time-grid .fc-slats tr[data-time]') // all slots
-  let slotTime = null
-  let prevSlotTime = null
+  let slotTimeMs = null
+  let prevSlotTimeMs = null
 
   for (let i = 0; i < slotEls.length; i++) { // traverse earlier to later
     slotEl = slotEls[i]
     slotEl = $(slotEl)
 
-    prevSlotTime = slotTime
-    slotTime = moment.duration(slotEl.data('time'))
+    prevSlotTimeMs = slotTimeMs
+    slotTimeMs = FullCalendar.createDuration(slotEl.data('time')).time
 
     // is target time between start of previous slot but before this one?
-    if (targetTime < slotTime) {
+    if (targetTimeMs < slotTimeMs) {
       // before first slot
-      if (!prevSlotTime) {
+      if (!prevSlotTimeMs) {
         return slotEl.offset().top + topBorderWidth
       } else {
         const prevSlotEl = slotEls.eq(i - 1)
         return prevSlotEl.offset().top + // previous slot top
           topBorderWidth +
           (prevSlotEl.outerHeight() *
-          ((targetTime - prevSlotTime) / (slotTime - prevSlotTime)))
+          ((targetTimeMs - prevSlotTimeMs) / (slotTimeMs - prevSlotTimeMs)))
       }
     }
   }
 
   // target time must be after the start time of the last slot.
-  // `slotTime` is set to the start time of the last slot.
+  // `slotTimeMs` is set to the start time of the last slot.
 
   // guess the duration of the last slot, based on previous duration
-  const slotMsDuration = slotTime - prevSlotTime
+  const slotMsDuration = slotTimeMs - prevSlotTimeMs
 
   return slotEl.offset().top + // last slot's top
     topBorderWidth +
     (slotEl.outerHeight() *
-    Math.min(1, (targetTime - slotTime) / slotMsDuration)) // don't go past end of last slot
+    Math.min(1, (targetTimeMs - slotTimeMs) / slotMsDuration)) // don't go past end of last slot
 }
 
 
 export function getTimeGridDayEls(date) {
-  date = FullCalendar.moment.parseZone(date)
 
-  return $('.fc-time-grid .fc-day[data-date="' + date.format('YYYY-MM-DD') + '"]')
+  if (typeof date === 'string') {
+    date = new Date(date)
+  }
+
+  return $('.fc-time-grid .fc-day[data-date="' + formatIsoDay(date) + '"]')
 }
 
 
-export function getTimeGridSlotEls(timeDuration) {
-  timeDuration = moment.duration(timeDuration)
-  const date = FullCalendar.moment.utc('2016-01-01').time(timeDuration)
-  if (date.date() === 1) { // ensure no time overflow/underflow
-    return $(`.fc-time-grid .fc-slats tr[data-time="${date.format('HH:mm:ss')}"]`)
+export function getTimeGridSlotEls(timeMs) {
+  const date = new Date('2016-01-01')
+  date = new Date(date.valueOf() + timeMs)
+
+  if (date.getUTCDate() === 1) { // ensure no time overflow/underflow
+    return $('.fc-time-grid .fc-slats tr[data-time="' + formatIsoTime(date) + '"]')
   } else {
     return $()
   }

+ 4 - 10
tests/automated/view-dates/ViewDateUtils.js

@@ -3,11 +3,8 @@ export function expectRenderRange(start, end) {
   var currentView = currentCalendar.getView()
   var dateProfile = currentView.dateProfile
 
-  var renderRangeStart = currentCalendar.msToUtcMoment(dateProfile.renderUnzonedRange.startMs, dateProfile.isRangeAllDay)
-  var renderRangeEnd = currentCalendar.msToUtcMoment(dateProfile.renderUnzonedRange.endMs, dateProfile.isRangeAllDay)
-
-  expect(renderRangeStart).toEqualMoment(start)
-  expect(renderRangeEnd).toEqualMoment(end)
+  expect(dateProfile.renderUnzonedRange.start).toEqualDate(start)
+  expect(dateProfile.renderUnzonedRange.end).toEqualDate(end)
 }
 
 
@@ -15,9 +12,6 @@ export function expectActiveRange(start, end) {
   var currentView = currentCalendar.getView()
   var dateProfile = currentView.dateProfile
 
-  var activeRangeStart = currentCalendar.msToUtcMoment(dateProfile.activeUnzonedRange.startMs, dateProfile.isRangeAllDay)
-  var activeRangeEnd = currentCalendar.msToUtcMoment(dateProfile.activeUnzonedRange.endMs, dateProfile.isRangeAllDay)
-
-  expect(activeRangeStart).toEqualMoment(start)
-  expect(activeRangeEnd).toEqualMoment(end)
+  expect(dateProfile.activeUnzonedRange.start).toEqualDate(start)
+  expect(dateProfile.activeUnzonedRange.end).toEqualDate(end)
 }

+ 0 - 1
tests/automated/view-dates/next.js

@@ -22,7 +22,6 @@ describe('next', function() {
 
     describeOptions('dateIncrement', {
       'when two week dateIncrement specified as a plain object': { weeks: 2 },
-      'when two week dateIncrement specified as a Duration object': moment.duration({ weeks: 2 }),
       'when two week dateIncrement specified as a string': '14.00:00:00'
     }, function() {
       it('moves forward by two weeks', function() {

+ 5 - 28
tests/automated/view-dates/validRange.js

@@ -2,6 +2,7 @@ import { expectActiveRange, expectRenderRange } from './ViewDateUtils'
 
 describe('validRange', function() {
   pushOptions({
+    timezone: 'UTC',
     defaultDate: '2017-06-08'
   })
 
@@ -63,8 +64,8 @@ describe('validRange', function() {
 
       it('receives the nowDate, timezoneless', function() {
         var validRangeSpy = spyOnCalendarCallback('validRange', function(date) {
-          expect(moment.isMoment(date)).toBe(true)
-          expect(date).toEqualMoment(nowInput)
+          expect(date instanceof Date).toBe(true)
+          expect(date).toEqualDate(nowInput + 'Z')
         })
 
         initCalendar({
@@ -74,20 +75,6 @@ describe('validRange', function() {
         expect(validRangeSpy).toHaveBeenCalled()
       })
 
-      /* getNow() always returns ambig zone for some reason. intentional?
-      xit('receives the nowDate, with UTC timezone', function() {
-        var validRangeSpy = spyOnCalendarCallback('validRange', function(date) {
-          expect(date).toEqualMoment(nowInput + 'Z');
-        });
-
-        initCalendar({
-          timezone: 'UTC',
-          now: nowInput
-        });
-
-        expect(validRangeSpy).toHaveBeenCalled();
-      }); */
-
       it('can return a range object with strings', function() {
         var validRangeSpy = spyOnCalendarCallback('validRange', function() {
           return { start: '2017-06-06' }
@@ -100,9 +87,9 @@ describe('validRange', function() {
         expectActiveRange('2017-06-06', '2017-06-11')
       })
 
-      it('can return a range object with moments', function() {
+      it('can return a range object with Date objects', function() {
         var validRangeSpy = spyOnCalendarCallback('validRange', function() {
-          return { start: FullCalendar.moment.parseZone('2017-06-06') }
+          return { start: new Date('2017-06-06') }
         })
 
         initCalendar()
@@ -111,16 +98,6 @@ describe('validRange', function() {
         expectRenderRange('2017-06-04', '2017-06-11')
         expectActiveRange('2017-06-06', '2017-06-11')
       })
-
-      it('does not cause side effects when given date is mutated', function() {
-        initCalendar({
-          now: nowInput,
-          validRange: function(nowDate) {
-            nowDate.add(2, 'years')
-          }
-        })
-        expect(currentCalendar.getNow().year()).toBe(2017)
-      })
     })
   })
 

+ 10 - 18
tests/automated/view-dates/visibleRange.js

@@ -12,18 +12,18 @@ describe('visibleRange', function() {
       var endInput = '2017-06-29'
 
       describeOptions('visibleRange', {
-        'of moment objects': {
-          start: FullCalendar.moment(startInput),
-          end: FullCalendar.moment(endInput)
+        'of Date objects': {
+          start: new Date(startInput),
+          end: new Date(endInput)
         },
         'of strings': {
           start: startInput,
           end: endInput
         },
-        'of a function that returns moment objects': function() {
+        'of a function that returns date objects': function() {
           return {
-            start: FullCalendar.moment(startInput),
-            end: FullCalendar.moment(endInput)
+            start: new Date(startInput),
+            end: new Date(endInput)
           }
         },
         'of a function that returns strings': function() {
@@ -81,15 +81,16 @@ describe('visibleRange', function() {
     describe('when a function', function() {
       var defaultDateInput = '2017-06-08T12:30:00'
 
-      it('receives the calendar\'s defaultDate, timezoneless', function() {
+      it('receives the calendar\'s defaultDate, with local timezone', function() {
         var matched = false
 
         initCalendar({
+          timezone: 'local',
           defaultDate: defaultDateInput,
           visibleRange: function(date) {
             // this function will receive the date for prev/next,
             // which should be ignored. make sure just one call matches.
-            if (date.format() === defaultDateInput) {
+            if (date.valueOf() === new Date(defaultDateInput).valueOf()) {
               matched = true
             }
           }
@@ -107,7 +108,7 @@ describe('visibleRange', function() {
           visibleRange: function(date) {
             // this function will receive the date for prev/next,
             // which should be ignored. make sure just one call matches.
-            if (date.format() === defaultDateInput + 'Z') {
+            if (date.valueOf() === new Date(defaultDateInput + 'Z').valueOf()) {
               matched = true
             }
           }
@@ -116,15 +117,6 @@ describe('visibleRange', function() {
         expect(matched).toBe(true)
       })
 
-      it('does not cause side effects when given date is mutated', function() {
-        initCalendar({
-          defaultDate: defaultDateInput,
-          visibleRange: function(date) {
-            date.add(1, 'year')
-          }
-        })
-        expect(currentCalendar.getDate()).toEqualMoment(defaultDateInput)
-      })
     })
 
     describe('when given an invalid range', function() {

+ 3 - 2
tests/automated/view-render/DayGridRenderUtils.js

@@ -1,7 +1,8 @@
+import { formatIsoDay } from '../datelib/utils'
+
 
 export function getSingleDayEl(date) {
-  date = FullCalendar.moment.parseZone(date)
-  var els = $('.fc-day-grid .fc-bg .fc-day[data-date="' + date.format('YYYY-MM-DD') + '"]')
+  var els = $('.fc-day-grid .fc-bg .fc-day[data-date="' + formatIsoDay(date) + '"]')
   expect(els).toHaveLength(1)
   return els
 }