defaultTimedEventDuration.js 3.1 KB

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