tests for maxTime. improvements to minTime tests

This commit is contained in:
Adam Shaw
2014-05-30 16:15:27 -07:00
parent 67853e0866
commit 593e59d52c
2 changed files with 133 additions and 11 deletions
+124
View File
@@ -0,0 +1,124 @@
describe('maxTime', function() {
beforeEach(function() {
affix('#cal');
});
var numToStringConverter = function(timeIn) {
var time = (timeIn % 12) || 12;
var amPm = 'am';
if ((timeIn % 24) > 11) {
amPm = 'pm';
}
return time + amPm;
};
describe('when using the default settings', function() {
describe('in agendaWeek', function() {
it('should start at 12am', function() {
var options = {
defaultView: 'agendaWeek'
};
$('#cal').fullCalendar(options);
var lastSlotText = $('.fc-agenda-slots tr:not(.fc-minor):last th').text();
expect(lastSlotText).toEqual('11pm');
});
});
describe('in agendaDay', function() {
it('should start at 12am', function() {
var options = {
defaultView: 'agendaDay'
};
$('#cal').fullCalendar(options);
var lastSlotText = $('.fc-agenda-slots tr:not(.fc-minor):last th').text();
expect(lastSlotText).toEqual('11pm');
});
});
});
describe('when using a whole number', function() {
var hourNumbers = [ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 ];
describe('in agendaWeek', function() {
beforeEach(function() {
affix('#cal2');
});
hourNumbers.forEach(function(hourNumber) {
it('should end at ' + hourNumber, function() {
var options = {
defaultView: 'agendaWeek',
maxTime: { hours: hourNumber }
};
$('#cal2').fullCalendar(options);
var lastSlotText = $('.fc-agenda-slots tr:not(.fc-minor):last th').text();
var expected = numToStringConverter(hourNumber - 1);
expect(lastSlotText).toEqual(expected);
});
});
});
describe('in agendaDay', function() {
beforeEach(function() {
affix('#cal2');
});
hourNumbers.forEach(function(hourNumber) {
it('should end at ' + hourNumber, function() {
var options = {
defaultView: 'agendaDay',
maxTime: hourNumber + ':00' // in addition, test string duration input
};
$('#cal2').fullCalendar(options);
var lastSlotText = $('.fc-agenda-slots tr:not(.fc-minor):last th').text();
var expected = numToStringConverter(hourNumber - 1);
expect(lastSlotText).toEqual(expected);
});
});
});
});
describe('when using default slotInterval and \'uneven\' maxTime', function() {
var hourNumbers = [ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 ];
describe('in agendaWeek', function() {
beforeEach(function() {
affix('#cal2');
});
hourNumbers.forEach(function(hourNumber) {
it('should end at ' + hourNumber + ':20', function() {
var options = {
defaultView: 'agendaWeek',
maxTime: { hours: hourNumber, minutes: 20 }
};
$('#cal2').fullCalendar(options);
var lastSlotText = $('.fc-agenda-slots tr:not(.fc-minor):last th').text();
// since exclusive end is :20, last slot will be on the current hour's 00:00
var expected = numToStringConverter(hourNumber);
expect(lastSlotText).toEqual(expected);
});
});
});
describe('in agendaDay', function() {
beforeEach(function() {
affix('#cal2');
});
hourNumbers.forEach(function(hourNumber) {
it('should end at ' + hourNumber + ':20', function() {
var options = {
defaultView: 'agendaDay',
maxTime: { hours: hourNumber, minutes: 20 }
};
$('#cal2').fullCalendar(options);
var lastSlotText = $('.fc-agenda-slots tr:not(.fc-minor):last th').text();
// since exclusive end is :20, last slot will be on the current hour's 00:00
var expected = numToStringConverter(hourNumber);
expect(lastSlotText).toEqual(expected);
});
});
});
});
});
+9 -11
View File
@@ -1,20 +1,16 @@
describe('minTime', function() {
beforeEach(function() {
affix('#cal');
});
var numToStringConverter = function(timeIn) {
var time = (timeIn % 12);
if ($.inArray(timeIn, [ 0, 12 ]) != -1) {
time = 12;
}
var numToStringConverter = function(timeIn, mins) {
var time = (timeIn % 12) || 12;
var amPm = 'am';
if (timeIn > 11) {
if ((timeIn % 24) > 11) {
amPm = 'pm';
}
return time + amPm;
return time + (mins != null ? ':' + mins : '') + amPm;
};
describe('when using the default settings', function() {
@@ -44,7 +40,7 @@ describe('minTime', function() {
describe('when using a whole number', function() {
var hourNumbers = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 ];
var hourNumbers = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ];
describe('in agendaWeek', function() {
beforeEach(function() {
@@ -72,7 +68,7 @@ describe('minTime', function() {
it('should start at ' + hourNumber, function() {
var options = {
defaultView: 'agendaDay',
minTime: { hours: hourNumber }
minTime: hourNumber + ':00' // in addition, test string duration input
};
$('#cal2').fullCalendar(options);
var firstSlotText = $('.fc-slot0 th').text();
@@ -85,7 +81,7 @@ describe('minTime', function() {
describe('when using default slotInterval and \'uneven\' minTime', function() {
var hourNumbers = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22 ];
var hourNumbers = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ];
describe('in agendaWeek', function() {
beforeEach(function() {
@@ -104,6 +100,7 @@ describe('minTime', function() {
expect(firstSlotElement).toHaveClass('fc-minor');
expect(secondSlotElement).toHaveClass('fc-minor');
expect(thirdSlotElement).toHaveClass('fc-minor');
// TODO: fix bad behavior in src where no slots have text
});
});
});
@@ -125,6 +122,7 @@ describe('minTime', function() {
expect(firstSlotElement).toHaveClass('fc-minor');
expect(secondSlotElement).toHaveClass('fc-minor');
expect(thirdSlotElement).toHaveClass('fc-minor');
// TODO: fix bad behavior in src where no slots have text
});
});
});