defaultTimedEventDuration.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. describe('defaultTimedEventDuration', function() {
  2. pushOptions({
  3. defaultDate: '2014-05-01',
  4. defaultView: 'month'
  5. })
  6. describe('when forceEventDuration is on', function() {
  7. pushOptions({
  8. forceEventDuration: true
  9. })
  10. it('correctly calculates an unspecified end when using a Duration object input', function() {
  11. initCalendar({
  12. defaultTimedEventDuration: { hours: 2, minutes: 30 },
  13. events: [
  14. {
  15. allDay: false,
  16. start: '2014-05-05T04:00:00'
  17. }
  18. ]
  19. })
  20. var event = currentCalendar.clientEvents()[0]
  21. expect(event.end).toEqualMoment('2014-05-05T06:30:00')
  22. })
  23. it('correctly calculates an unspecified end when using a string Duration input', function() {
  24. initCalendar({
  25. defaultTimedEventDuration: '03:15:00',
  26. events: [
  27. {
  28. allDay: false,
  29. start: '2014-05-05T04:00:00'
  30. }
  31. ]
  32. })
  33. var event = currentCalendar.clientEvents()[0]
  34. expect(event.end).toEqualMoment('2014-05-05T07:15:00')
  35. })
  36. })
  37. describe('when forceEventDuration is off', function() {
  38. pushOptions({
  39. forceEventDuration: false
  40. })
  41. describe('with agendaWeek view', function() {
  42. pushOptions({
  43. defaultView: 'agendaWeek'
  44. })
  45. it('renders a timed event with no `end` to appear to have the default duration', function(done) {
  46. initCalendar({
  47. defaultTimedEventDuration: '01:15:00',
  48. events: [
  49. {
  50. // a control. so we know how tall it should be
  51. title: 'control event',
  52. allDay: false,
  53. start: '2014-05-01T04:00:00',
  54. end: '2014-05-01T05:15:00'
  55. },
  56. {
  57. // one day after the control. no specified end
  58. title: 'test event',
  59. allDay: false,
  60. start: '2014-05-02T04:00:00'
  61. }
  62. ],
  63. eventAfterAllRender: function() {
  64. var eventElms = $('.fc-event', currentCalendar.el)
  65. var height0 = eventElms.eq(0).outerHeight()
  66. var height1 = eventElms.eq(1).outerHeight()
  67. expect(height0).toBeGreaterThan(0)
  68. expect(height0).toEqual(height1)
  69. done()
  70. }
  71. })
  72. })
  73. })
  74. describe('with basicWeek view', function() {
  75. pushOptions({
  76. defaultView: 'basicWeek'
  77. })
  78. it('renders a timed event with no `end` to appear to have the default duration', function(done) {
  79. initCalendar({
  80. defaultTimedEventDuration: { days: 2 },
  81. events: [
  82. {
  83. // a control. so we know how wide it should be
  84. title: 'control event',
  85. allDay: false,
  86. start: '2014-04-28T04:00:00',
  87. end: '2014-04-30T00:00:00'
  88. },
  89. {
  90. // one day after the control. no specified end
  91. title: 'test event',
  92. allDay: false,
  93. start: '2014-04-28T04:00:00'
  94. }
  95. ],
  96. eventAfterAllRender: function() {
  97. var eventElms = $('.fc-event', currentCalendar.el)
  98. var width0 = eventElms.eq(0).outerWidth()
  99. var width1 = eventElms.eq(1).outerWidth()
  100. expect(width0).toBeGreaterThan(0)
  101. expect(width0).toEqual(width1)
  102. done()
  103. }
  104. })
  105. })
  106. })
  107. })
  108. })