Skip to content

Commit

Permalink
tests for displayEventEnd, as well as affected dnd/resize tests
Browse files Browse the repository at this point in the history
  • Loading branch information
arshaw committed Jun 13, 2014
1 parent ee3715c commit 7e1dac7
Show file tree
Hide file tree
Showing 3 changed files with 295 additions and 0 deletions.
142 changes: 142 additions & 0 deletions tests/automated/displayEventEnd.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
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);
});
});
});
});
});
});
67 changes: 67 additions & 0 deletions tests/automated/event-dnd.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,73 @@ 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.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.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.
Expand Down
86 changes: 86 additions & 0 deletions tests/automated/event-resize.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,92 @@ describe('eventResize', function() {
}
);
});

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();
}
);
});
});

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();
}
);
});
});
});

Expand Down

0 comments on commit 7e1dac7

Please sign in to comment.