maxTime.js 3.3 KB

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