moment-2.8 compatibility, automated tests (2.1), .add() calls

This commit is contained in:
Adam Shaw
2014-08-06 17:28:19 -07:00
parent 6c04fca1f3
commit 67e2d45cf5
7 changed files with 27 additions and 27 deletions
+2 -2
View File
@@ -270,7 +270,7 @@ describe('current date', function() {
var title;
start = $.fullCalendar.moment(start);
calculatedEnd = end ? $.fullCalendar.moment(end) : start.clone().add('days', 1);
calculatedEnd = end ? $.fullCalendar.moment(end) : start.clone().add(1, 'days');
expect(start).toEqualMoment(view.start);
expect(calculatedEnd).toEqualMoment(view.end);
@@ -280,7 +280,7 @@ describe('current date', function() {
else {
title = $.fullCalendar.formatRange(
start,
calculatedEnd.clone().add('ms', -1),
calculatedEnd.clone().add(-1, 'ms'),
TITLE_FORMAT
);
}
+3 -3
View File
@@ -41,7 +41,7 @@ describe('day names', function() {
dayClasses.forEach(function(cls, index, classes) {
var weekdays = moment.weekdays();
it('should be ' + weekdays[index], function() {
settings.now = moment(referenceDate).add('days', index);
settings.now = moment(referenceDate).add(index, 'days');
$('#cal').fullCalendar(settings);
expect($('.fc-view thead ' + dayClasses[index])).toHaveText(weekdays[index]);
@@ -58,7 +58,7 @@ describe('day names', function() {
dayClasses.forEach(function(cls, index, classes) {
it('should be the translation for ' + moment.weekdays()[index], function() {
settings.lang = language;
settings.now = moment(referenceDate).add('days', index);
settings.now = moment(referenceDate).add(index, 'days');
$('#cal').fullCalendar(settings);
expect($('.fc-view thead ' + dayClasses[index])).toHaveText(moment.weekdays()[index]);
@@ -81,7 +81,7 @@ describe('day names', function() {
dayClasses.forEach(function(cls, idx, classes) {
it('should be ' + weekdays[idx], function() {
settings.dayNames = [].slice.call(weekdays); // copy. in case there is a mutation
settings.now = moment(referenceDate).add('days', idx);
settings.now = moment(referenceDate).add(idx, 'days');
$('#cal').fullCalendar(settings);
+2 -2
View File
@@ -32,7 +32,7 @@ describe('ambiguously-zoned moment', function() {
expect(clone.hasZone()).toBe(false);
expect(clone.format()).toBe('2014-06-08T10:00:00');
expect(clone).not.toBe(mom);
clone.add('months', 1);
clone.add(1, 'months');
expect(+clone).not.toBe(+mom);
});
@@ -108,7 +108,7 @@ describe('ambiguously-timed moment', function() {
expect(clone.hasTime()).toBe(false);
expect(clone.format()).toBe('2014-06-08');
expect(clone).not.toBe(mom);
clone.add('months', 1);
clone.add(1, 'months');
expect(+clone).not.toBe(+mom);
});
+4 -4
View File
@@ -196,7 +196,7 @@ function testDefaultProcessing(construct) {
var newMoment = construct(oldMoment);
expect(newMoment).not.toBe(oldMoment);
expect(+newMoment).toBe(+oldMoment);
newMoment.add('months', 1);
newMoment.add(1, 'months');
expect(+newMoment).not.toBe(+oldMoment);
});
});
@@ -349,7 +349,7 @@ function testForcedLocalProcessing(construct) {
var newMoment = construct(oldMoment);
expect(newMoment).not.toBe(oldMoment);
expect(+newMoment).toBe(+oldMoment);
newMoment.add('months', 1);
newMoment.add(1, 'months');
expect(+newMoment).not.toBe(+oldMoment);
});
});
@@ -493,7 +493,7 @@ function testForcedUTCProcessing(construct) {
var newMoment = construct(oldMoment);
expect(newMoment).not.toBe(oldMoment);
expect(+newMoment).toBe(+oldMoment);
newMoment.add('months', 1);
newMoment.add(1, 'months');
expect(+newMoment).not.toBe(+oldMoment);
});
});
@@ -635,7 +635,7 @@ function testLiteralProcessing(construct) {
var newMoment = construct(oldMoment);
expect(newMoment).not.toBe(oldMoment);
expect(+newMoment).toBe(+oldMoment);
newMoment.add('months', 1);
newMoment.add(1, 'months');
expect(+newMoment).not.toBe(+oldMoment);
});
+3 -3
View File
@@ -28,7 +28,7 @@ describe('month name', function() {
moment.months().forEach(function(month, index, months) {
it('should be ' + month, function(done) {
settings.defaultDate = $.fullCalendar.moment(referenceDate).add('months', index);
settings.defaultDate = $.fullCalendar.moment(referenceDate).add(index, 'months');
settings.eventAfterAllRender = function() {
expect($('.fc-toolbar h2')).toContainText(month);
done();
@@ -51,7 +51,7 @@ describe('month name', function() {
var langMonths = moment.months();
var langMonth = langMonths[index];
settings.defaultDate = $.fullCalendar.moment(referenceDate).add('months', index);
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
expect($('.fc-toolbar h2')).toContainText(langMonth);
@@ -86,7 +86,7 @@ describe('month name', function() {
months.forEach(function(month, index, months) { // `month` is our custom month name
it('should be the translated name for ' + month, function(done) {
settings.defaultDate = $.fullCalendar.moment(referenceDate).add('months', index);
settings.defaultDate = $.fullCalendar.moment(referenceDate).add(index, 'months');
settings.monthNames = months;
settings.eventAfterAllRender = function() {
expect($('.fc-toolbar h2')).toContainText(month);
+3 -3
View File
@@ -28,7 +28,7 @@ describe('short month name', function() {
moment.monthsShort().forEach(function(monthShort, index) {
it('should be ' + monthShort, function(done) {
settings.defaultDate = $.fullCalendar.moment(referenceDate).add('months', index);
settings.defaultDate = $.fullCalendar.moment(referenceDate).add(index, 'months');
settings.eventAfterAllRender = function() {
expect($('.fc-toolbar h2')).toContainText(monthShort);
done();
@@ -51,7 +51,7 @@ describe('short month name', function() {
var langMonthsShort = moment.monthsShort();
var langMonthShort = langMonthsShort[index];
settings.defaultDate = $.fullCalendar.moment(referenceDate).add('months', index);
settings.defaultDate = $.fullCalendar.moment(referenceDate).add(index, 'months');
settings.eventAfterAllRender = function() {
expect($('.fc-toolbar h2')).toContainText(langMonthShort);
done();
@@ -81,7 +81,7 @@ describe('short month name', function() {
monthsShort.forEach(function(monthShort, index) { // `monthShort` will be our custom month name
it('should be the translated name for ' + monthShort, function(done) {
settings.defaultDate = $.fullCalendar.moment(referenceDate).add('months', index);
settings.defaultDate = $.fullCalendar.moment(referenceDate).add(index, 'months');
settings.monthNamesShort = monthsShort;
settings.eventAfterAllRender = function() {
expect($('.fc-toolbar h2')).toContainText(monthShort);
+10 -10
View File
@@ -30,7 +30,7 @@ describe('updateEvent', function() {
{ id: '1', start: '2014-05-10', allDay: true }
];
init();
event.start.add('days', 2);
event.start.add(2, 'days');
$('#cal').fullCalendar('updateEvent', event);
expect(event.start).toEqualMoment('2014-05-03');
expect(event.end).toBeNull();
@@ -45,7 +45,7 @@ describe('updateEvent', function() {
{ id: '1', start: '2014-05-10', end: '2014-05-12', allDay: true }
];
init();
event.start.add('days', 2);
event.start.add(2, 'days');
expect(event.start).toEqualMoment('2014-05-03');
expect(event.end).toBeNull();
$('#cal').fullCalendar('updateEvent', event);
@@ -97,7 +97,7 @@ describe('updateEvent', function() {
{ id: '1', start: '2014-05-10', allDay: true }
];
init();
event.end.add('days', 1);
event.end.add(1, 'days');
$('#cal').fullCalendar('updateEvent', event);
expect(event.start).toEqualMoment('2014-05-01');
expect(event.end).toEqualMoment('2014-05-04');
@@ -112,7 +112,7 @@ describe('updateEvent', function() {
{ id: '1', start: '2014-05-10', end: '2014-05-13', allDay: true }
];
init();
event.end.add('days', 1);
event.end.add(1, 'days');
$('#cal').fullCalendar('updateEvent', event);
expect(event.start).toEqualMoment('2014-05-01');
expect(event.end).toEqualMoment('2014-05-04');
@@ -184,8 +184,8 @@ describe('updateEvent', function() {
{ id: '1', start: '2014-05-10', end: '2014-05-13', allDay: true }
];
init();
event.start.add('days', 2);
event.end.add('day', 3);
event.start.add(2, 'days');
event.end.add(3, 'day');
$('#cal').fullCalendar('updateEvent', event);
expect(event.start).toEqualMoment('2014-05-03');
expect(event.end).toEqualMoment('2014-05-06');
@@ -273,7 +273,7 @@ describe('updateEvent', function() {
];
init();
event.allDay = false;
event.start.add('days', 1);
event.start.add(1, 'days');
$('#cal').fullCalendar('updateEvent', event);
expect(event.allDay).toEqual(false);
expect(event.start).toEqualMoment('2014-05-02T00:00:00');
@@ -308,7 +308,7 @@ describe('updateEvent', function() {
];
init();
event.allDay = true;
event.start.add('days', 1);
event.start.add(1, 'days');
$('#cal').fullCalendar('updateEvent', event);
expect(event.allDay).toEqual(true);
expect(event.start).toEqualMoment('2014-05-02');
@@ -348,7 +348,7 @@ describe('updateEvent', function() {
{ id: '1', start: '2014-05-11T06:00:00+05:00', end: '2014-05-13T06:00:00+05:00', allDay: false }
];
init();
event.start.add('hours', 2);
event.start.add(2, 'hours');
$('#cal').fullCalendar('updateEvent', event);
});
should();
@@ -363,7 +363,7 @@ describe('updateEvent', function() {
{ id: '1', start: '2014-05-11T06:00:00+05:00', end: '2014-05-13T06:00:00+05:00', allDay: false }
];
init();
event.end.add('hours', 2);
event.end.add(2, 'hours');
$('#cal').fullCalendar('updateEvent', event);
});
should();