maxTime.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. describe('maxTime', function() {
  2. beforeEach(function() {
  3. affix('#cal');
  4. });
  5. var numToStringConverter = function(timeIn) {
  6. var time = (timeIn % 12) || 12;
  7. var amPm = 'am';
  8. if ((timeIn % 24) > 11) {
  9. amPm = 'pm';
  10. }
  11. return time + amPm;
  12. };
  13. describe('when using the default settings', function() {
  14. describe('in agendaWeek', function() {
  15. it('should start at 12am', function() {
  16. var options = {
  17. defaultView: 'agendaWeek'
  18. };
  19. $('#cal').fullCalendar(options);
  20. var lastSlotText = $('.fc-slats tr:not(.fc-minor):last .fc-time').text();
  21. expect(lastSlotText).toEqual('11pm');
  22. });
  23. });
  24. describe('in agendaDay', function() {
  25. it('should start at 12am', function() {
  26. var options = {
  27. defaultView: 'agendaDay'
  28. };
  29. $('#cal').fullCalendar(options);
  30. var lastSlotText = $('.fc-slats tr:not(.fc-minor):last .fc-time').text();
  31. expect(lastSlotText).toEqual('11pm');
  32. });
  33. });
  34. });
  35. describe('when using a whole number', function() {
  36. var hourNumbers = [ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 ];
  37. describe('in agendaWeek', function() {
  38. beforeEach(function() {
  39. affix('#cal2');
  40. });
  41. hourNumbers.forEach(function(hourNumber) {
  42. it('should end at ' + hourNumber, function() {
  43. var options = {
  44. defaultView: 'agendaWeek',
  45. maxTime: { hours: hourNumber }
  46. };
  47. $('#cal2').fullCalendar(options);
  48. var lastSlotText = $('.fc-slats tr:not(.fc-minor):last .fc-time').text();
  49. var expected = numToStringConverter(hourNumber - 1);
  50. expect(lastSlotText).toEqual(expected);
  51. });
  52. });
  53. });
  54. describe('in agendaDay', function() {
  55. beforeEach(function() {
  56. affix('#cal2');
  57. });
  58. hourNumbers.forEach(function(hourNumber) {
  59. it('should end at ' + hourNumber, function() {
  60. var options = {
  61. defaultView: 'agendaDay',
  62. maxTime: hourNumber + ':00' // in addition, test string duration input
  63. };
  64. $('#cal2').fullCalendar(options);
  65. var lastSlotText = $('.fc-slats tr:not(.fc-minor):last .fc-time').text();
  66. var expected = numToStringConverter(hourNumber - 1);
  67. expect(lastSlotText).toEqual(expected);
  68. });
  69. });
  70. });
  71. });
  72. describe('when using default slotInterval and \'uneven\' maxTime', function() {
  73. var hourNumbers = [ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 ];
  74. describe('in agendaWeek', function() {
  75. beforeEach(function() {
  76. affix('#cal2');
  77. });
  78. hourNumbers.forEach(function(hourNumber) {
  79. it('should end at ' + hourNumber + ':20', function() {
  80. var options = {
  81. defaultView: 'agendaWeek',
  82. maxTime: { hours: hourNumber, minutes: 20 }
  83. };
  84. $('#cal2').fullCalendar(options);
  85. var lastSlotText = $('.fc-slats tr:not(.fc-minor):last .fc-time').text();
  86. // since exclusive end is :20, last slot will be on the current hour's 00:00
  87. var expected = numToStringConverter(hourNumber);
  88. expect(lastSlotText).toEqual(expected);
  89. });
  90. });
  91. });
  92. describe('in agendaDay', function() {
  93. beforeEach(function() {
  94. affix('#cal2');
  95. });
  96. hourNumbers.forEach(function(hourNumber) {
  97. it('should end at ' + hourNumber + ':20', function() {
  98. var options = {
  99. defaultView: 'agendaDay',
  100. maxTime: { hours: hourNumber, minutes: 20 }
  101. };
  102. $('#cal2').fullCalendar(options);
  103. var lastSlotText = $('.fc-slats tr:not(.fc-minor):last .fc-time').text();
  104. // since exclusive end is :20, last slot will be on the current hour's 00:00
  105. var expected = numToStringConverter(hourNumber);
  106. expect(lastSlotText).toEqual(expected);
  107. });
  108. });
  109. });
  110. });
  111. });