repeating.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import * as TimeGridEventDragUtils from './TimeGridEventDragUtils'
  2. describe('event dragging on repeating events', function() {
  3. pushOptions({
  4. defaultView: 'month',
  5. defaultDate: '2017-02-12',
  6. editable: true,
  7. events: [
  8. {
  9. id: 999,
  10. title: 'Repeating Event',
  11. start: '2017-02-09T16:00:00'
  12. },
  13. {
  14. id: 999,
  15. title: 'Repeating Event',
  16. start: '2017-02-16T16:00:00'
  17. }
  18. ]
  19. })
  20. // bug where offscreen instance of a repeating event was being incorrectly dragged
  21. pit('drags correct instance of event', function() {
  22. initCalendar()
  23. // event range needs out large (month) then scope down (agendaWeek)
  24. // so that the new view receives out-of-range events.
  25. currentCalendar.changeView('agendaWeek')
  26. return TimeGridEventDragUtils.drag('2017-02-16T16:00:00', '2017-02-16T12:00:00')
  27. .then(function(res) {
  28. expect(res.isSuccess).toBe(true)
  29. })
  30. })
  31. it('hides other repeating events when dragging', function(done) {
  32. initCalendar({
  33. eventDragStart: function() {
  34. setTimeout(function() { // try go execute DURING the drag
  35. expect(
  36. $('.fc-event:visible').filter(function(i, node) {
  37. return $(node).css('visibility') !== 'hidden'
  38. }).length
  39. ).toBe(1)
  40. }, 0)
  41. },
  42. eventDrop: function() {
  43. setTimeout(function() {
  44. done()
  45. }, 10)
  46. }
  47. })
  48. $('.fc-event:first').simulate('drag', {
  49. dx: 100,
  50. duration: 100 // ample time for separate eventDragStart/eventDrop
  51. })
  52. })
  53. // inverse of above test
  54. it('doesnt accidentally hide all non-id events when dragging', function(done) {
  55. initCalendar({
  56. events: [
  57. {
  58. title: 'Regular Event',
  59. start: '2017-02-09T16:00:00'
  60. },
  61. {
  62. title: 'Other Regular Event',
  63. start: '2017-02-16T16:00:00'
  64. }
  65. ],
  66. eventDragStart: function() {
  67. setTimeout(function() { // try go execute DURING the drag
  68. expect(
  69. $('.fc-event:visible').filter(function(i, node) {
  70. return $(node).css('visibility') !== 'hidden'
  71. }).length
  72. ).toBe(2) // the dragging event AND the other regular event
  73. }, 0)
  74. },
  75. eventDrop: function() {
  76. setTimeout(function() {
  77. done()
  78. }, 10)
  79. }
  80. })
  81. $('.fc-event:first').simulate('drag', {
  82. dx: 100,
  83. duration: 100 // ample time for separate eventDragStart/eventDrop
  84. })
  85. })
  86. })