next.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. import { expectActiveRange } from './ViewDateUtils'
  2. import * as TimeGridRenderUtils from '../view-render/TimeGridRenderUtils'
  3. describe('next', function() {
  4. pushOptions({
  5. defaultDate: '2017-06-08'
  6. })
  7. describe('when in agendaWeek view', function() {
  8. pushOptions({
  9. defaultView: 'agendaWeek'
  10. })
  11. describe('when dateIncrement not specified', function() {
  12. it('moves forward by one week', function() {
  13. initCalendar()
  14. currentCalendar.next()
  15. expectActiveRange('2017-06-11', '2017-06-18')
  16. })
  17. })
  18. describeOptions('dateIncrement', {
  19. 'when two week dateIncrement specified as a plain object': { weeks: 2 },
  20. 'when two week dateIncrement specified as a Duration object': moment.duration({ weeks: 2 }),
  21. 'when two week dateIncrement specified as a string': '14.00:00:00'
  22. }, function() {
  23. it('moves forward by two weeks', function() {
  24. initCalendar()
  25. currentCalendar.next()
  26. expectActiveRange('2017-06-18', '2017-06-25')
  27. })
  28. })
  29. it('does not duplicate-render skeleton', function() {
  30. initCalendar()
  31. currentCalendar.next()
  32. expect(TimeGridRenderUtils.isStructureValid()).toBe(true)
  33. })
  34. })
  35. describe('when in a month view', function() {
  36. pushOptions({
  37. defaultView: 'month'
  38. })
  39. describe('when dateIncrement not specified', function() {
  40. it('moves forward by one month', function() {
  41. initCalendar()
  42. currentCalendar.next()
  43. expectActiveRange('2017-06-25', '2017-08-06')
  44. })
  45. })
  46. describe('when two month dateIncrement is specified', function() {
  47. pushOptions({
  48. dateIncrement: { months: 2 }
  49. })
  50. it('moves forward by two months', function() {
  51. initCalendar()
  52. currentCalendar.next()
  53. expectActiveRange('2017-07-30', '2017-09-10')
  54. })
  55. })
  56. })
  57. describe('when in custom three day view', function() {
  58. pushOptions({
  59. defaultView: 'basic',
  60. duration: { days: 3 }
  61. })
  62. describe('when no dateAlignment is specified', function() {
  63. describe('when dateIncrement not specified', function() {
  64. it('moves forward three days', function() {
  65. initCalendar()
  66. currentCalendar.next()
  67. expectActiveRange('2017-06-11', '2017-06-14')
  68. })
  69. })
  70. describe('when two day dateIncrement is specified', function() {
  71. pushOptions({
  72. dateIncrement: { days: 2 }
  73. })
  74. it('moves forward two days', function() {
  75. initCalendar()
  76. currentCalendar.next()
  77. expectActiveRange('2017-06-10', '2017-06-13')
  78. })
  79. })
  80. })
  81. describe('when week dateAlignment is specified', function() {
  82. pushOptions({
  83. dateAlignment: 'week'
  84. })
  85. describe('when dateIncrement not specified', function() {
  86. it('moves forward one week', function() {
  87. initCalendar()
  88. currentCalendar.next()
  89. expectActiveRange('2017-06-11', '2017-06-14')
  90. })
  91. })
  92. describe('when two day dateIncrement is specified', function() {
  93. pushOptions({
  94. dateIncrement: { days: 2 }
  95. })
  96. it('does not navigate nor rerender', function() {
  97. var called
  98. initCalendar({
  99. viewRender: function() {
  100. called = true
  101. }
  102. })
  103. called = false
  104. currentCalendar.next()
  105. expectActiveRange('2017-06-04', '2017-06-07') // the same as how it started
  106. expect(called).toBe(false)
  107. })
  108. })
  109. })
  110. })
  111. describe('when in a custom two day view and weekends:false', function() {
  112. pushOptions({
  113. weekends: false,
  114. defaultView: 'agenda',
  115. duration: { days: 2 }
  116. })
  117. it('skips over weekends if there would be alignment with weekend', function() {
  118. initCalendar({
  119. defaultDate: '2017-11-09'
  120. })
  121. currentCalendar.next()
  122. })
  123. })
  124. })