Fix for Issue 29 (languages)

This commit is contained in:
sean kenny
2014-09-04 14:37:09 +01:00
parent 4140f6aae9
commit 79ef1f0820
65 changed files with 125 additions and 11767 deletions
-108
View File
@@ -1,108 +0,0 @@
describe('addEventSource', function() {
var options;
var eventArray = [
{ id: 0, title: 'event zero', start: '2014-06-24', className: 'event-zero' },
{ id: 1, title: 'event one', start: '2014-06-24', className: 'event-non-zero event-one' },
{ id: 2, title: 'event two', start: '2014-06-24', className: 'event-non-zero event-two' }
];
beforeEach(function() {
affix('#cal');
options = {
defaultDate: '2014-06-24',
defaultView: 'month'
};
});
it('correctly adds an array source', function(done) {
go(
function() {
$('#cal').fullCalendar('addEventSource', eventArray);
},
null,
done
);
});
it('correctly adds a function source', function(done) {
go(
function() {
$('#cal').fullCalendar('addEventSource', function(start, end, timezone, callback) {
callback(eventArray);
});
},
null,
done
);
});
it('correctly adds an extended array source', function(done) {
go(
function() {
$('#cal').fullCalendar('addEventSource', {
className: 'arraysource',
events: eventArray
});
},
function() {
expect($('.arraysource').length).toEqual(3);
},
done
);
});
it('correctly adds an extended array source', function(done) {
go(
function() {
$('#cal').fullCalendar('addEventSource', {
className: 'funcsource',
events: function(start, end, timezone, callback) {
callback(eventArray);
}
});
},
function() {
expect($('.funcsource').length).toEqual(3);
},
done
);
});
function go(addFunc, extraTestFunc, doneFunc) {
var callCnt = 0;
options.eventAfterAllRender = function() {
callCnt++;
if (callCnt == 2) { // once for initial render. second time for addEventSource
called = true;
checkAllEvents();
if (extraTestFunc) {
extraTestFunc();
}
// move the calendar back out of view, then back in (for issue 2191)
$('#cal').fullCalendar('next');
$('#cal').fullCalendar('prev');
checkAllEvents();
if (extraTestFunc) {
extraTestFunc();
}
doneFunc();
}
};
$('#cal').fullCalendar(options);
addFunc();
}
// Checks to make sure all events have been rendered and that the calendar
// has internal info on all the events.
function checkAllEvents() {
expect($('#cal').fullCalendar('clientEvents').length).toEqual(3);
expect($('.fc-event').length).toEqual(3);
}
});
+3
View File
@@ -37,6 +37,8 @@ describe('constructor', function() {
expect(options).toEqual(optionsCopy);
});
/*
TODO: implement this behavior
it('should not modify the eventSources array', function() {
var options = {
defaultView: 'month',
@@ -54,6 +56,7 @@ describe('constructor', function() {
$('#calendar').fullCalendar(options);
expect(options).toEqual(optionsCopy);
});
*/
describe('when called on a div', function() {
-27
View File
@@ -1,27 +0,0 @@
describe('destroy', function() {
beforeEach(function() {
affix('#cal');
});
describe('when calendar is LTR', function() {
it('cleans up all classNames on the root element', function() {
$('#cal').fullCalendar({
isRTL: false
});
$('#cal').fullCalendar('destroy');
expect($('#cal')[0].className).toBe('');
});
});
describe('when calendar is RTL', function() {
it('cleans up all classNames on the root element', function() {
$('#cal').fullCalendar({
isRTL: true
});
$('#cal').fullCalendar('destroy');
expect($('#cal')[0].className).toBe('');
});
});
});
-142
View File
@@ -1,142 +0,0 @@
describe('displayEventEnd', function() {
var options;
beforeEach(function() {
affix('#cal');
options = {
defaultDate: '2014-06-13',
timeFormat: 'H:mm'
};
});
afterEach(function() {
$('#cal').fullCalendar('destroy');
});
[ 'month', 'agendaWeek' ].forEach(function(viewName) {
describe('when in ' + viewName + ' view', function() {
beforeEach(function() {
options.defaultView = viewName;
});
describe('when off', function() {
beforeEach(function() {
options.displayEventEnd = false;
});
describe('with an all-day event', function() {
beforeEach(function() {
options.events = [ {
title: 'timed event',
start: '2014-06-13',
end: '2014-06-13',
allDay: true
} ];
});
it('displays no time text', function(done) {
options.eventAfterAllRender = function() {
expect($('.fc-event-time').length).toBe(0);
done();
};
$('#cal').fullCalendar(options);
});
});
describe('with a timed event with no end time', function(done) {
beforeEach(function() {
options.events = [ {
title: 'timed event',
start: '2014-06-13T01:00:00',
allDay: false
} ];
});
it('displays only the start time text', function(done) {
options.eventAfterAllRender = function() {
expect($('.fc-event-time')).toHaveText('1:00');
done();
};
$('#cal').fullCalendar(options);
});
});
describe('with a timed event with an end time', function() {
beforeEach(function() {
options.events = [ {
title: 'timed event',
start: '2014-06-13T01:00:00',
end: '2014-06-13T02:00:00',
allDay: false
} ];
});
it('displays only the start time text', function(done) {
options.eventAfterAllRender = function() {
expect($('.fc-event-time')).toHaveText('1:00');
done();
};
$('#cal').fullCalendar(options);
});
});
});
describe('when on', function() {
beforeEach(function() {
options.displayEventEnd = true;
});
describe('with an all-day event', function() {
beforeEach(function() {
options.events = [ {
title: 'timed event',
start: '2014-06-13',
end: '2014-06-13',
allDay: true
} ];
});
it('displays no time text', function(done) {
options.eventAfterAllRender = function() {
expect($('.fc-event-time').length).toBe(0);
done();
};
$('#cal').fullCalendar(options);
});
});
describe('with a timed event with no end time', function(done) {
beforeEach(function() {
options.events = [ {
title: 'timed event',
start: '2014-06-13T01:00:00',
allDay: false
} ];
});
it('displays only the start time text', function(done) {
options.eventAfterAllRender = function() {
expect($('.fc-event-time')).toHaveText('1:00');
done();
};
$('#cal').fullCalendar(options);
});
});
describe('with a timed event with an end time', function() {
beforeEach(function() {
options.events = [ {
title: 'timed event',
start: '2014-06-13T01:00:00',
end: '2014-06-13T02:00:00',
allDay: false
} ];
});
it('displays both the start and end time text', function(done) {
options.eventAfterAllRender = function() {
expect($('.fc-event-time')).toHaveText('1:00 - 2:00');
done();
};
$('#cal').fullCalendar(options);
});
});
});
});
});
});
+28 -385
View File
@@ -1,389 +1,32 @@
describe('eventDrop', function() {
var options;
beforeEach(function() {
options = {
defaultDate: '2014-06-11',
// can't do event dragging yet.
// need to work out how fullCalendar is intercepting events.
/*
xdescribe('when event is dragged from one cell to another', function() {
it('should move to the new cell', function() {
var eventName = 'xyzAllDayEvent';
$('#calendar').fullCalendar({
editable: true
});
$('#calendar').fullCalendar('addEventSource', {
events: [
{
title: eventName,
start: new Date()
}
]
});
var el = $('div .fc-event');
var offsetBefore = el.offset();
dump(offsetBefore);
var options = {
dx: 200,
dy: 0,
moves: 10,
handle: 'corner'
};
affix('#cal');
el.simulate('drag', options);
dump(el.offset());
});
afterEach(function() {
$('#cal').fullCalendar('destroy');
});
describe('when in month view', function() {
beforeEach(function() {
options.defaultView = 'month';
});
describe('when dragging an all-day event to another day', function() {
it('should be given correct arguments, with whole-day delta', function(done) {
options.events = [ {
title: 'all-day event',
start: '2014-06-11',
allDay: true
} ];
init(
function() {
$('.fc-event')
.simulate('mouseover') // for our dumb optimization
.simulate('drag-n-drop', {
dx: $('.fc-day').width() * 2,
dy: $('.fc-day').height()
});
},
function(event, delta, revertFunc) {
expect(delta.asDays()).toBe(9);
expect(delta.hours()).toBe(0);
expect(delta.minutes()).toBe(0);
expect(delta.seconds()).toBe(0);
expect(delta.milliseconds()).toBe(0);
expect(event.start).toEqualMoment('2014-06-20');
expect(event.end).toBeNull();
revertFunc();
expect(event.start).toEqualMoment('2014-06-11');
expect(event.end).toBeNull();
done();
}
);
});
});
describe('when gragging a timed event to another day', function() {
it('should be given correct arguments, with whole-day delta', function(done) {
options.events = [ {
title: 'timed event',
start: '2014-06-11T06:00:00',
allDay: false
} ];
init(
function() {
$('.fc-event')
.simulate('mouseover') // for our dumb optimization
.simulate('drag-n-drop', {
dx: $('.fc-day').width() * -2,
dy: $('.fc-day').height()
});
},
function(event, delta, revertFunc) {
expect(delta.asDays()).toBe(5);
expect(delta.hours()).toBe(0);
expect(delta.minutes()).toBe(0);
expect(delta.seconds()).toBe(0);
expect(delta.milliseconds()).toBe(0);
expect(event.start).toEqualMoment('2014-06-16T06:00:00');
expect(event.end).toBeNull();
revertFunc();
expect(event.start).toEqualMoment('2014-06-11T06:00:00');
expect(event.end).toBeNull();
done();
}
);
});
});
});
describe('when in agenda view', function() {
beforeEach(function() {
options.defaultView = 'agendaWeek';
});
describe('when dragging a timed event to another time on a different day', function() {
it('should be given correct arguments and delta with days/time', function(done) {
options.events = [ {
title: 'timed event',
start: '2014-06-11T06:00:00',
allDay: false
} ];
init(
function() {
$('.fc-event')
.simulate('mouseover') // for our dumb optimization
.simulate('drag-n-drop', {
dx: $('th.fc-wed').width(), // 1 day
dy: $('tr.fc-slot1').height() * 3 // 1.5 hours
});
},
function(event, delta, revertFunc) {
expect(delta.days()).toBe(1);
expect(delta.hours()).toBe(1);
expect(delta.minutes()).toBe(30);
expect(delta.seconds()).toBe(0);
expect(delta.milliseconds()).toBe(0);
expect(event.start).toEqualMoment('2014-06-12T07:30:00');
expect(event.end).toBeNull();
revertFunc();
expect(event.start).toEqualMoment('2014-06-11T06:00:00');
expect(event.end).toBeNull();
done();
}
);
});
});
describe('when dragging an all-day event to another all-day', function() {
it('should be given correct arguments, with whole-day delta', function(done) {
options.events = [ {
title: 'all-day event',
start: '2014-06-11',
allDay: true
} ];
init(
function() {
$('.fc-event')
.simulate('mouseover') // for our dumb optimization
.simulate('drag-n-drop', {
dx: $('th.fc-wed').width() * 2 // 2 days
});
},
function(event, delta, revertFunc) {
expect(delta.days()).toBe(2);
expect(delta.hours()).toBe(0);
expect(delta.minutes()).toBe(0);
expect(delta.seconds()).toBe(0);
expect(delta.milliseconds()).toBe(0);
expect(event.start).toEqualMoment('2014-06-13');
expect(event.end).toBeNull();
revertFunc();
expect(event.start).toEqualMoment('2014-06-11');
expect(event.end).toBeNull();
done();
}
);
});
});
describe('when dragging an all-day event to a time slot on a different day', function() {
it('should be given correct arguments and delta with days/time', function(done) {
options.scrollTime = '01:00:00';
options.height = 400; // short enough to make scrolling happen
options.events = [ {
title: 'all-day event',
start: '2014-06-11',
allDay: true
} ];
init(
function() {
$('.fc-event')
.simulate('mouseover') // for our dumb optimization
.simulate('drag-n-drop', {
dx: $('th.fc-wed').width() * -1,
dy: $('.fc-agenda-allday').outerHeight() + $('.fc-agenda-divider').outerHeight()
});
},
function(event, delta, revertFunc) {
expect(delta.days()).toBe(-1);
expect(delta.hours()).toBe(1);
expect(delta.minutes()).toBe(0);
expect(delta.seconds()).toBe(0);
expect(delta.milliseconds()).toBe(0);
expect(event.start).toEqualMoment('2014-06-10T01:00:00');
expect(event.end).toBeNull();
expect(event.allDay).toBe(false);
revertFunc();
expect(event.start).toEqualMoment('2014-06-11');
expect(event.end).toBeNull();
expect(event.allDay).toBe(true);
done();
}
);
});
});
describe('when dragging a timed event to an all-day slot on a different day', function() {
it('should be given correct arguments, with whole-day delta', function(done) {
var eventElm;
options.scrollTime = '01:00:00';
options.height = 400; // short enough to make scrolling happen
options.events = [ {
title: 'timed event',
start: '2014-06-11T01:00:00',
allDay: false
} ];
init(
function() {
eventElm = $('.fc-event')
.simulate('mouseover') // for our dumb optimization
.simulate('drag', {
dx: $('th.fc-wed').width() * -1,
dy: -$('.fc-agenda-allday').outerHeight(),
callback: function() {
// the all day slot works off of mouse-moving coordinates
var offset = eventElm.offset();
$('.fc-agenda-allday .fc-day-content')
.simulate('mouseover', {
clientX: offset.left + 10,
clientY: offset.top + 10
})
.simulate('mousemove', {
clientX: offset.left + 10,
clientY: offset.top + 10
});
setTimeout(function() {
eventElm.simulate('drop');
}, 100);
}
});
},
function(event, delta, revertFunc) {
expect(delta.days()).toBe(-1);
expect(delta.hours()).toBe(0);
expect(delta.minutes()).toBe(0);
expect(delta.seconds()).toBe(0);
expect(delta.milliseconds()).toBe(0);
expect(event.start).toEqualMoment('2014-06-10');
expect(event.end).toBeNull();
expect(event.allDay).toBe(true);
revertFunc();
expect(event.start).toEqualMoment('2014-06-11T01:00:00');
expect(event.end).toBeNull();
expect(event.allDay).toBe(false);
done();
}
);
});
});
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
options.events = [ {
title: 'timed event',
start: '2014-06-11T01:00:00',
allDay: false
} ];
init(
function() {
eventElm = $('.fc-event')
.simulate('mouseover') // for our dumb optimization
.simulate('drag', {
dy: $('tr.fc-slot1').height() * 3, // 1.5 hours
callback: function() {
dragged = true;
expect(eventElm.find('.fc-event-time')).toHaveText('2:30');
eventElm.simulate('drop');
}
});
},
function() {
expect(dragged).toBe(true);
done();
}
);
});
});
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
options.events = [ {
title: 'timed event',
start: '2014-06-11T01:00:00',
end: '2014-06-11T02:00:00',
allDay: false
} ];
init(
function() {
eventElm = $('.fc-event')
.simulate('mouseover') // for our dumb optimization
.simulate('drag', {
dy: $('tr.fc-slot1').height() * 3, // 1.5 hours
callback: function() {
dragged = true;
expect(eventElm.find('.fc-event-time')).toHaveText('2:30 - 3:30');
eventElm.simulate('drop');
}
});
},
function() {
expect(dragged).toBe(true);
done();
}
);
});
});
});
// Initialize a calendar, run a drag, and do type-checking of all arguments for all handlers.
// TODO: more descrimination instead of just checking for 'object'
function init(dragFunc, dropHandler) {
var eventsRendered = false;
options.eventAfterAllRender = function() {
if (!eventsRendered) { // because event rerendering will happen upon drop
dragFunc();
eventsRendered = true;
}
};
options.eventDragStart = function(event, jsEvent, uiEvent, view) {
expect(this instanceof Element).toBe(true);
expect(this).toHaveClass('fc-event');
expect(typeof event).toBe('object');
expect(typeof jsEvent).toBe('object');
expect(typeof uiEvent).toBe('object');
expect(typeof view).toBe('object');
};
options.eventDragStop = function(event, jsEvent, uiEvent, view) {
expect(options.eventDragStart).toHaveBeenCalled();
expect(this instanceof Element).toBe(true);
expect(this).toHaveClass('fc-event');
expect(typeof event).toBe('object');
expect(typeof jsEvent).toBe('object');
expect(typeof uiEvent).toBe('object');
expect(typeof view).toBe('object');
};
options.eventDrop = function(event, delta, revertFunc, jsEvent, uiEvent, view) {
expect(options.eventDragStop).toHaveBeenCalled();
expect(this instanceof Element).toBe(true);
expect(this).toHaveClass('fc-event');
expect(typeof event).toBe('object');
expect(moment.isDuration(delta)).toBe(true);
expect(typeof revertFunc).toBe('function');
expect(typeof jsEvent).toBe('object');
expect(typeof uiEvent).toBe('object');
expect(typeof view).toBe('object');
dropHandler.apply(this, arguments);
};
spyOn(options, 'eventDragStart').and.callThrough();
spyOn(options, 'eventDragStop').and.callThrough();
setTimeout(function() { // hack. agenda view scroll state would get messed up between tests
$('#cal').fullCalendar(options);
}, 0);
}
});
});
*/
-312
View File
@@ -1,312 +0,0 @@
describe('eventResize', function() {
var options;
beforeEach(function() {
options = {
defaultDate: '2014-06-11',
editable: true
};
affix('#cal');
});
afterEach(function() {
$('#cal').fullCalendar('destroy');
});
describe('when in month view', function() {
beforeEach(function() {
options.defaultView = 'month';
});
describe('when resizing an all-day event', function() {
it('should have correct arguments with a whole-day delta', function(done) {
options.events = [ {
title: 'all-day event',
start: '2014-06-11',
allDay: true
} ];
init(
function() {
$('.fc-event .ui-resizable-handle')
.simulate('mouseover') // for our dumb optimization
.simulate('drag-n-drop', {
dx: $('.fc-day').width() * -2,
dy: $('.fc-day').height()
});
},
function(event, delta, revertFunc) {
expect(delta.asDays()).toBe(5);
expect(delta.hours()).toBe(0);
expect(delta.minutes()).toBe(0);
expect(delta.seconds()).toBe(0);
expect(delta.milliseconds()).toBe(0);
expect(event.start).toEqualMoment('2014-06-11');
expect(event.end).toEqualMoment('2014-06-17');
revertFunc();
expect(event.start).toEqualMoment('2014-06-11');
expect(event.end).toBeNull();
done();
}
);
});
});
describe('when rendering a timed event', function() {
it('should not have resize capabilities', function(done) {
options.events = [ {
title: 'timed event',
start: '2014-06-11T08:00:00',
allDay: false
} ];
options.eventAfterAllRender = function() {
expect($('.fc-event .ui-resizable-handle').length).toBe(0);
done();
};
$('#cal').fullCalendar(options);
});
});
});
describe('when in agenda view', function() {
beforeEach(function() {
options.defaultView = 'agendaWeek';
});
describe('when resizing an all-day event', function() {
it('should have correct arguments with a whole-day delta', function(done) {
options.events = [ {
title: 'all-day event',
start: '2014-06-11',
allDay: true
} ];
init(
function() {
$('.fc-event .ui-resizable-handle')
.simulate('mouseover') // for our dumb optimization
.simulate('drag-n-drop', {
dx: $('th.fc-wed').width() * 1.5 // two days
});
},
function(event, delta, revertFunc) {
expect(delta.asDays()).toBe(2);
expect(delta.hours()).toBe(0);
expect(delta.minutes()).toBe(0);
expect(delta.seconds()).toBe(0);
expect(delta.milliseconds()).toBe(0);
expect(event.start).toEqualMoment('2014-06-11');
expect(event.end).toEqualMoment('2014-06-14');
revertFunc();
expect(event.start).toEqualMoment('2014-06-11');
expect(event.end).toBeNull();
done();
}
);
});
});
describe('when resizing a timed event with an end', function() {
beforeEach(function() {
options.events = [ {
title: 'timed event event',
start: '2014-06-11T05:00:00',
end: '2014-06-11T07:00:00',
allDay: false
} ];
});
it('should have correct arguments with a timed delta', function(done) {
init(
function() {
$('.fc-event .ui-resizable-handle')
.simulate('mouseover') // for our dumb optimization
.simulate('drag-n-drop', {
dy: $('tr.fc-slot1').height() * 4.5 // 5 slots, so 2.5 hours
});
},
function(event, delta, revertFunc) {
expect(delta.days()).toBe(0);
expect(delta.hours()).toBe(2);
expect(delta.minutes()).toBe(30);
expect(delta.seconds()).toBe(0);
expect(delta.milliseconds()).toBe(0);
expect(event.start).toEqualMoment('2014-06-11T05:00:00');
expect(event.end).toEqualMoment('2014-06-11T09:30:00');
revertFunc();
expect(event.start).toEqualMoment('2014-06-11T05:00:00');
expect(event.end).toEqualMoment('2014-06-11T07:00:00');
done();
}
);
});
it('should display the correct time text while resizing', function(done) {
var dy;
var handle;
init(
function() {
dy = $('tr.fc-slot1').height() * 4.5; // 5 slots, so 2.5 hours
handle = $('.fc-event .ui-resizable-handle')
.simulate('mouseover') // for our dumb optimization
.simulate('drag', {
dy: dy,
callback: function() {
expect($('.fc-event-time')).toHaveText('5:00 - 9:30');
handle.simulate('drag', {
// BUG with jquery-simulate-ext
// I guess the delta is still relative to the original position, so should be zero.
// But zero causes nothing to happen, so make it a tiny non-zero delta.
dy: -1,
callback: function() {
expect($('.fc-event-time')).toHaveText('5:00 - 7:00');
handle.simulate('drop', {
callback: function() {
done();
}
});
}
});
}
});
},
function() {
// this wasn't firing for some reason. do it in the drop callback instead
//done();
}
);
});
it('should not fire the windowResize handler', function(done) { // bug 1116
options.windowResize = function() { };
options.windowResizeDelay = 0;
spyOn(options, 'windowResize');
init(
function() {
$('.fc-event .ui-resizable-handle')
.simulate('mouseover') // for our dumb optimization
.simulate('drag-n-drop', {
dy: 200,
interpolation: {
stepCount: 10,
duration: 100
}
});
},
function() { // if an unintended rerender happened, won't get here anyway
expect(options.windowResize).not.toHaveBeenCalled();
done();
}
);
});
});
describe('when resizing a timed event without an end', function() {
beforeEach(function() {
options.events = [ {
title: 'timed event event',
start: '2014-06-11T05:00:00',
allDay: false
} ];
});
it('should display the correct time text while resizing', function(done) {
var dy;
var handle;
init(
function() {
dy = $('tr.fc-slot1').height() * 4.5; // 5 slots, so 2.5 hours
handle = $('.fc-event .ui-resizable-handle')
.simulate('mouseover') // for our dumb optimization
.simulate('drag', {
dy: dy,
callback: function() {
expect($('.fc-event-time')).toHaveText('5:00 - 9:30');
handle.simulate('drag', {
// BUG with jquery-simulate-ext
// I guess the delta is still relative to the original position, so should be zero.
// But zero causes nothing to happen, so make it a tiny non-zero delta.
dy: -1,
callback: function() {
expect($('.fc-event-time')).toHaveText('5:00');
handle.simulate('drop', {
callback: function() {
done();
}
});
}
});
}
});
},
function() {
// this wasn't firing for some reason. do it in the drop callback instead
//done();
}
);
});
});
});
// Initialize a calendar, run a resize, and do type-checking of all arguments for all handlers.
// TODO: more descrimination instead of just checking for 'object'
function init(resizeStartFunc, resizeDoneFunc) {
var eventsRendered = false;
options.eventAfterAllRender = function() {
if (!eventsRendered) { // because event rerendering will happen when resize is over
resizeStartFunc();
eventsRendered = true;
}
};
options.eventResizeStart = function(event, jsEvent, uiEvent, view) {
expect(this instanceof Element).toBe(true);
expect(this).toHaveClass('fc-event');
expect(typeof event).toBe('object');
expect(typeof jsEvent).toBe('object');
expect(typeof uiEvent).toBe('object');
expect(typeof view).toBe('object');
};
options.eventResizeStop = function(event, jsEvent, uiEvent, view) {
expect(options.eventResizeStart).toHaveBeenCalled();
expect(this instanceof Element).toBe(true);
expect(this).toHaveClass('fc-event');
expect(typeof event).toBe('object');
expect(typeof jsEvent).toBe('object');
expect(typeof uiEvent).toBe('object');
expect(typeof view).toBe('object');
};
options.eventResize = function(event, delta, revertFunc, jsEvent, uiEvent, view) {
expect(options.eventResizeStop).toHaveBeenCalled();
expect(this instanceof Element).toBe(true);
expect(this).toHaveClass('fc-event');
expect(typeof event).toBe('object');
expect(moment.isDuration(delta)).toBe(true);
expect(typeof revertFunc).toBe('function');
expect(typeof jsEvent).toBe('object');
expect(typeof uiEvent).toBe('object'); // might be a non-jqui dummy object
expect(typeof view).toBe('object');
resizeDoneFunc.apply(this, arguments);
};
spyOn(options, 'eventResizeStart').and.callThrough();
spyOn(options, 'eventResizeStop').and.callThrough();
setTimeout(function() { // hack. agenda view scroll state would get messed up between tests
$('#cal').fullCalendar(options);
}, 0);
}
});
-13
View File
@@ -118,17 +118,4 @@ describe('events as a function', function() {
$('#cal').fullCalendar(options);
});
it('requests the correct dates when days at the start/end of the month are hidden', function(done) {
options.currentView = 'month';
options.defaultDate = '2013-06-01'; // June 2013 has first day as Saturday, and last as Sunday!
options.weekends = false;
options.weekMode = 'variable';
options.events = function(start, end, timezone, callback) {
expect(start).toEqualMoment('2013-06-03');
expect(end).toEqualMoment('2013-06-29');
done();
};
$('#cal').fullCalendar(options);
});
});
-67
View File
@@ -1,67 +0,0 @@
describe('FCMoment::time', function() {
describe('getter', function() {
// the scenario where an ambiguously-timed moment's 00:00 time is checked
// is taken care of in moment-ambig.js
it('should return 00:00 for a moment with 00:00 time', function() {
var mom = $.fullCalendar.moment.utc('2014-06-08T00:00:00');
var time = mom.time();
expect(time).toEqualDuration('00:00');
});
it('should return the time of a moment with a time', function() {
var mom = $.fullCalendar.moment.utc('2014-06-08T07:30:00');
var time = mom.time();
expect(time).toEqualDuration('07:30');
});
});
describe('setter', function() {
// the scenario where an ambiguously-timed moment is given a time via the setter
// is taken care of in moment-ambig.js
describe('when setting with a Duration', function() {
it('should give a moment with 00:00 a time', function() {
var mom = $.fullCalendar.moment.utc('2014-06-08T00:00:00');
var dur = moment.duration('13:25');
mom.time(dur);
expect(mom).toEqualMoment('2014-06-08T13:25:00+00:00');
});
it('should overwrite the time of a moment with a time', function() {
var mom = $.fullCalendar.moment.utc('2014-06-08T05:00:00');
var dur = moment.duration('13:25');
mom.time(dur);
expect(mom).toEqualMoment('2014-06-08T13:25:00+00:00');
});
it('should move to next day if greater than 24 hours', function() {
var mom = $.fullCalendar.moment.utc('2014-06-08T00:00:00');
var dur = moment.duration('1.01:00:00'); // 1 day, 1 hour
mom.time(dur);
expect(mom).toEqualMoment('2014-06-09T01:00:00+00:00');
});
});
describe('when setting with another Moment', function() {
it('should give a moment with 00:00 a time', function() {
var mom1 = $.fullCalendar.moment.utc('2014-06-09T00:00:00');
var mom2 = $.fullCalendar.moment.utc('2014-07-22T05:30:00'); // a Tues, so .days() -> 2
mom1.time(mom2);
expect(mom1).toEqualMoment('2014-06-09T05:30:00+00:00');
});
it('should overwrite the time of a moment with a time', function() {
var mom1 = $.fullCalendar.moment.utc('2014-06-09T04:15:00');
var mom2 = $.fullCalendar.moment.utc('2014-07-22T05:30:00'); // a Tues, so .days() -> 2
mom1.time(mom2);
expect(mom1).toEqualMoment('2014-06-09T05:30:00+00:00');
});
});
});
});
-150
View File
@@ -1,150 +0,0 @@
describe('removeEvents', function() {
var options;
var eventArray = [
{ id: 0, title: 'event zero', start: '2014-06-24', className: 'event-zero' },
{ id: 1, title: 'event one', start: '2014-06-24', className: 'event-non-zero event-one' },
{ id: 2, title: 'event two', start: '2014-06-24', className: 'event-non-zero event-two' }
];
var eventFunc = function(start, end, timezone, callback) {
callback(eventArray);
};
beforeEach(function() {
affix('#cal');
options = {
defaultDate: '2014-06-24',
defaultView: 'month'
};
});
$.each({
'with an array of events': eventArray,
'with an event function': eventFunc
}, function(description, events) {
describe(description, function() {
it('can remove all events if no args specified', function(done) {
go(
events,
function() {
$('#cal').fullCalendar('removeEvents');
},
function() {
expect($('#cal').fullCalendar('clientEvents').length).toEqual(0);
expect($('.fc-event').length).toEqual(0);
},
done
);
});
it('can remove events with a numeric ID', function(done) {
go(
events,
function() {
$('#cal').fullCalendar('removeEvents', 1);
},
function() {
expect($('#cal').fullCalendar('clientEvents').length).toEqual(2);
expect($('.fc-event').length).toEqual(2);
expect($('.event-zero').length).toEqual(1);
expect($('.event-two').length).toEqual(1);
},
done
);
});
it('can remove events with a string ID', function(done) {
go(
events,
function() {
$('#cal').fullCalendar('removeEvents', '1');
},
function() {
expect($('#cal').fullCalendar('clientEvents').length).toEqual(2);
expect($('.fc-event').length).toEqual(2);
expect($('.event-zero').length).toEqual(1);
expect($('.event-two').length).toEqual(1);
},
done
);
});
it('can remove events with a filter function', function(done) {
go(
events,
function() {
$('#cal').fullCalendar('removeEvents', function(event) {
return $.inArray('event-one', event.className) !== -1;
});
},
function() {
expect($('#cal').fullCalendar('clientEvents').length).toEqual(2);
expect($('.fc-event').length).toEqual(2);
expect($('.event-zero').length).toEqual(1);
expect($('.event-two').length).toEqual(1);
},
done
);
});
it('can remove an event with ID 0', function(done) { // for issue 2082
go(
events,
function() {
$('#cal').fullCalendar('removeEvents', 0);
},
function() {
expect($('#cal').fullCalendar('clientEvents').length).toEqual(2);
expect($('.fc-event').length).toEqual(2);
expect($('.event-zero').length).toEqual(0);
expect($('.event-non-zero').length).toEqual(2);
},
done
);
});
});
});
// Verifies the actions in removeFunc executed correctly by calling checkFunc.
function go(events, removeFunc, checkFunc, doneFunc) {
var called = false;
options.events = events;
options.eventAfterAllRender = function() {
if (!called) { // don't execute on subsequent removeEvents/next/prev
called = true;
checkAllEvents(); // make sure all events initially rendered correctly
removeFunc(); // remove the events
checkFunc(); // check correctness
// move the calendar back out of view, then back in
$('#cal').fullCalendar('next');
$('#cal').fullCalendar('prev');
// array event sources should maintain the same state
// whereas "dynamic" event sources should refetch and reset the state
if ($.isArray(events)) {
checkFunc(); // for issue 2187
}
else {
checkAllEvents();
}
doneFunc();
}
};
$('#cal').fullCalendar(options);
}
// Checks to make sure all events have been rendered and that the calendar
// has internal info on all the events.
function checkAllEvents() {
expect($('#cal').fullCalendar('clientEvents').length).toEqual(3);
expect($('.fc-event').length).toEqual(3);
}
});
-2
View File
@@ -11,7 +11,6 @@ describe('scrollTime', function() {
it('accepts a string Duration', function() {
options.scrollTime = '02:00:00';
options.height = 400; // short enough to make scrolling happen
$('#cal').fullCalendar(options);
var slotCell = $('.fc-slot4 td'); // 2am slot
var slotTop = slotCell.position().top;
@@ -25,7 +24,6 @@ describe('scrollTime', function() {
it('accepts a Duration object', function() {
options.scrollTime = { hours: 2 };
options.height = 400; // short enough to make scrolling happen
$('#cal').fullCalendar(options);
var slotCell = $('.fc-slot4 td'); // 2am slot
var slotTop = slotCell.position().top;
+24
View File
@@ -38,6 +38,10 @@ describe('select callback', function() {
$('#cal').fullCalendar(options);
$('.fc-day[data-date="2014-04-28"]').simulate('drag-n-drop', {
dropTarget: '.fc-day[data-date="2014-05-06"]',
interpolation: {
stepCount: 10,
duration: 100
},
callback: function() {
expect(options.select).toHaveBeenCalled();
done();
@@ -59,6 +63,10 @@ describe('select callback', function() {
$('#cal').fullCalendar(options);
$('.fc-day[data-date="2014-04-28"]').simulate('drag-n-drop', {
dropTarget: '.fc-day[data-date="2014-04-28"]',
interpolation: {
stepCount: 10,
duration: 100
},
callback: function() {
expect(options.select).toHaveBeenCalled();
done();
@@ -87,6 +95,10 @@ describe('select callback', function() {
$('#cal').fullCalendar(options);
$('.fc-agenda-allday .fc-day-content').simulate('drag-n-drop', { // middle will be 2014-05-28
dx: $('.fc-sun').outerWidth() * (isRTL ? -1 : 1), // the width of one column
interpolation: {
stepCount: 10,
duration: 100
},
callback: function() {
expect(options.select).toHaveBeenCalled();
done();
@@ -107,6 +119,10 @@ describe('select callback', function() {
spyOn(options, 'select').and.callThrough();
$('#cal').fullCalendar(options);
$('.fc-agenda-allday .fc-day-content').simulate('drag-n-drop', { // middle will be 2014-05-28
interpolation: {
stepCount: 10,
duration: 100
},
callback: function() {
expect(options.select).toHaveBeenCalled();
done();
@@ -130,6 +146,10 @@ describe('select callback', function() {
$('#cal').fullCalendar(options);
$('tr.fc-slot18 td').simulate('drag-n-drop', { // middle will be 2014-05-28T09:00:00
dy: $('tr.fc-slot18 td').outerHeight() * 2, // move down two slots
interpolation: {
stepCount: 10,
duration: 100
},
callback: function() {
expect(options.select).toHaveBeenCalled();
done();
@@ -150,6 +170,10 @@ describe('select callback', function() {
spyOn(options, 'select').and.callThrough();
$('#cal').fullCalendar(options);
$('tr.fc-slot18 td').simulate('drag-n-drop', { // middle will be 2014-05-28T09:00:00
interpolation: {
stepCount: 10,
duration: 100
},
callback: function() {
expect(options.select).toHaveBeenCalled();
done();
-1
View File
@@ -101,7 +101,6 @@ describe('select method', function() {
beforeEach(function() {
options.defaultView = 'agendaWeek';
options.scrollTime = '01:00:00'; // so that most events will be below the divider
options.height = 400; // short enought to make scrolling happen
});
describe('when called with timed moments', function() {
describe('when in bounds', function() {
-27
View File
@@ -1,27 +0,0 @@
ddescribe('', function() {
var options;
beforeEach(function() {
//affix('#cal');
$('body').append('<div id="cal"></div>');
options = {
defaultDate: ''
};
});
afterEach(function() {
//$('#cal').fullCalendar('destroy');
});
describe('', function() {
beforeEach(function() {
options.defaultView = '';
});
iit('', function() {
$('#cal').fullCalendar(options);
});
});
});
-18
View File
@@ -113,15 +113,6 @@ describe('weekMode', function() {
});
});
it('should not display an empty week when no visible days and weekMode is set to liquid', function() {
$('#cal').fullCalendar({
defaultDate: '2013-06-01', // June 2013 has first day as Saturday, and last as Sunday!
weekMode: 'liquid',
weekends: false
});
expect($('.fc-week').length).toBe(4);
});
describe('when weekMode is set to variable', function() {
beforeEach(function() {
$('#cal').fullCalendar({
@@ -154,13 +145,4 @@ describe('weekMode', function() {
expect(fiveWeekHeight).toEqual(sixWeekHeight);
});
});
it('should not display an empty week when no visible days and weekMode is set to variable', function() {
$('#cal').fullCalendar({
defaultDate: '2013-06-01', // June 2013 has first day as Saturday, and last as Sunday!
weekMode: 'variable',
weekends: false
});
expect($('.fc-week').length).toBe(4);
});
});
-7
View File
File diff suppressed because one or more lines are too long
-7
View File
File diff suppressed because one or more lines are too long
+9 -46
View File
@@ -1,64 +1,27 @@
beforeEach(function() {
jasmine.addMatchers({
toEqualMoment: function() {
return {
compare: function(actual, expected) {
var actualStr = $.fullCalendar.moment.parseZone(actual).format();
var expectedStr = $.fullCalendar.moment.parseZone(expected).format();
var result = {
pass: actualStr === expectedStr
return {
pass: $.fullCalendar.moment.parseZone(actual).format() ===
$.fullCalendar.moment.parseZone(expected).format()
};
if (!result.pass) {
result.message = 'Moment ' + actualStr + ' does not equal ' + expectedStr;
}
return result;
}
};
},
toEqualNow: function() {
return {
compare: function(actual) {
var actualMoment = $.fullCalendar.moment.parseZone(actual);
var result = {
pass: Math.abs(actualMoment - new Date()) < 1000 // within a second of current datetime
return {
pass: Math.abs(
$.fullCalendar.moment.parseZone(actual) -
new Date()
) < 1000 // within a second of current datetime
};
if (!result.pass) {
result.message = 'Moment ' + actualMoment.format() + ' is not close enough to now';
}
return result;
}
};
},
toEqualDuration: function() {
return {
compare: function(actual, expected) {
var actualStr = serializeDuration(moment.duration(actual));
var expectedStr = serializeDuration(moment.duration(expected));
var result = {
pass: actualStr === expectedStr
};
if (!result.pass) {
result.message = 'Duration ' + actualStr + ' does not equal ' + expectedStr;
}
return result;
}
};
}
});
function serializeDuration(duration) {
return Math.floor(duration.asDays()) + '.' +
pad(duration.hours(), 2) + ':' +
pad(duration.minutes(), 2) + ':' +
pad(duration.seconds(), 2) + '.' +
pad(duration.milliseconds(), 3);
}
function pad(n, width) {
n = n + '';
return n.length >= width ? n : new Array(width - n.length + 1).join('0') + n;
}
});
});
-23
View File
@@ -28,27 +28,4 @@
};
}
/*
Give jquery-simulate-ext drag-n-drop a default interpolation.
*/
var originalSimulate = $.fn.simulate;
$.fn.simulate = function(eventName, options) {
if (eventName == 'drag' || eventName == 'drop' || eventName == 'drag-n-drop') {
options = options || {};
if (options.interpolation === undefined) {
options.interpolation = {
stepCount: 10,
duration: 100
};
}
return originalSimulate.call(this, eventName, options);
}
return originalSimulate.apply(this, arguments);
};
})(jQuery);