eventLimitClick.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. describe('eventLimitClick', function() { // simulate a click
  2. pushOptions({
  3. defaultDate: '2014-08-01', // important that it is the first week, so works w/ month + week views
  4. defaultView: 'month',
  5. eventLimit: 3,
  6. events: [
  7. { title: 'event1', start: '2014-07-29' },
  8. { title: 'event2', start: '2014-07-29' },
  9. { title: 'event2', start: '2014-07-29' },
  10. { title: 'event2', start: '2014-07-29' }
  11. ]
  12. })
  13. describe('when set to "popover"', function() {
  14. pushOptions({
  15. eventLimitClick: 'popover'
  16. })
  17. it('renders a popover upon click', function() {
  18. initCalendar()
  19. $('.fc-more').simulate('click')
  20. expect($('.fc-more-popover')).toBeVisible()
  21. })
  22. // more popover tests are done in eventLimit-popover
  23. })
  24. describe('when set to "week"', function() {
  25. pushOptions({
  26. eventLimitClick: 'week'
  27. })
  28. it('should go to basicWeek if it is one of the available views', function() {
  29. initCalendar({
  30. header: {
  31. left: 'prev,next today',
  32. center: 'title',
  33. right: 'month,basicWeek,basicDay'
  34. }
  35. })
  36. $('.fc-more').simulate('click')
  37. var view = currentCalendar.getView()
  38. expect(view.name).toBe('basicWeek') // .name should be deprecated
  39. expect(view.type).toBe('basicWeek')
  40. })
  41. it('should go to agendaWeek if it is one of the available views', function() {
  42. initCalendar({
  43. header: {
  44. left: 'prev,next today',
  45. center: 'title',
  46. right: 'month,agendaWeek,agendaDay'
  47. }
  48. })
  49. $('.fc-more').simulate('click')
  50. var view = currentCalendar.getView()
  51. expect(view.name).toBe('agendaWeek') // .name should be deprecated
  52. expect(view.type).toBe('agendaWeek')
  53. })
  54. })
  55. describe('when set to "day"', function() {
  56. pushOptions({
  57. eventLimitClick: 'day'
  58. })
  59. it('should go to basicDay if it is one of the available views', function() {
  60. initCalendar({
  61. header: {
  62. left: 'prev,next today',
  63. center: 'title',
  64. right: 'month,basicWeek,basicDay'
  65. }
  66. })
  67. $('.fc-more').simulate('click')
  68. var view = currentCalendar.getView()
  69. expect(view.name).toBe('basicDay')
  70. })
  71. it('should go to agendaDay if it is one of the available views', function() {
  72. initCalendar({
  73. header: {
  74. left: 'prev,next today',
  75. center: 'title',
  76. right: 'month,agendaWeek,agendaDay'
  77. }
  78. })
  79. $('.fc-more').simulate('click')
  80. var view = currentCalendar.getView()
  81. expect(view.name).toBe('agendaDay')
  82. })
  83. })
  84. it('works with an explicit view name', function() {
  85. initCalendar({
  86. eventLimitClick: 'agendaWeek',
  87. header: {
  88. left: 'prev,next today',
  89. center: 'title',
  90. right: 'month,basicWeek,basicDay'
  91. }
  92. })
  93. $('.fc-more').simulate('click')
  94. var view = currentCalendar.getView()
  95. expect(view.name).toBe('agendaWeek')
  96. })
  97. it('works with custom function and all the arguments are correct', function() {
  98. initCalendar({
  99. eventLimitClick: function(cellInfo, jsEvent) {
  100. expect(typeof cellInfo).toBe('object')
  101. expect(typeof jsEvent).toBe('object')
  102. expect(cellInfo.date).toEqualMoment('2014-07-29')
  103. expect(cellInfo.dayEl.data('date')).toBe('2014-07-29')
  104. expect(cellInfo.hiddenSegs.length).toBe(2)
  105. expect(cellInfo.segs.length).toBe(4)
  106. expect(cellInfo.moreEl).toHaveClass('fc-more')
  107. }
  108. })
  109. $('.fc-more').simulate('click')
  110. })
  111. it('works with custom function, and can return a view name', function() {
  112. initCalendar({
  113. eventLimitClick: function(cellInfo, jsEvent) {
  114. return 'agendaDay'
  115. }
  116. })
  117. $('.fc-more').simulate('click')
  118. var view = currentCalendar.getView()
  119. expect(view.name).toBe('agendaDay')
  120. })
  121. })