dayCount.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import { expectActiveRange } from './ViewDateUtils'
  2. import { expectDay } from '../view-render/ViewRenderUtils'
  3. describe('dayCount', function() {
  4. pushOptions({
  5. defaultDate: '2017-03-15', // wed
  6. weekends: false
  7. })
  8. describeOptions({
  9. 'when specified as top-level options': {
  10. defaultView: 'basic',
  11. dayCount: 5
  12. },
  13. 'when specified as custom view': {
  14. views: {
  15. myCustomView: {
  16. type: 'basic',
  17. dayCount: 5
  18. }
  19. },
  20. defaultView: 'myCustomView'
  21. }
  22. }, function() {
  23. it('renders the exact day count', function() {
  24. initCalendar()
  25. expectActiveRange('2017-03-15', '2017-03-22')
  26. expectDay('2017-03-15', true)
  27. expectDay('2017-03-16', true)
  28. expectDay('2017-03-17', true)
  29. expectDay('2017-03-18', false) // sat
  30. expectDay('2017-03-19', false) // sun
  31. expectDay('2017-03-20', true)
  32. expectDay('2017-03-21', true)
  33. })
  34. })
  35. it('can span multiple weeks', function() {
  36. initCalendar({
  37. defaultView: 'agenda',
  38. dayCount: 9
  39. })
  40. expectActiveRange('2017-03-15', '2017-03-28')
  41. expectDay('2017-03-15', true)
  42. expectDay('2017-03-16', true)
  43. expectDay('2017-03-17', true)
  44. expectDay('2017-03-18', false) // sat
  45. expectDay('2017-03-19', false) // sun
  46. expectDay('2017-03-20', true)
  47. expectDay('2017-03-21', true)
  48. expectDay('2017-03-22', true)
  49. expectDay('2017-03-23', true)
  50. expectDay('2017-03-24', true)
  51. expectDay('2017-03-25', false) // sat
  52. expectDay('2017-03-26', false) // sun
  53. expectDay('2017-03-27', true)
  54. })
  55. it('can navigate in reverse with a small dateIncrement split by hidden days', function() {
  56. initCalendar({
  57. defaultDate: '2018-06-11',
  58. defaultView: 'agendaTwoDay',
  59. header: {
  60. left: 'prev,next',
  61. center: 'title',
  62. right: 'month,agendaWeek,agendaDay,agendaTwoDay'
  63. },
  64. hiddenDays: [ 0, 6 ],
  65. views: {
  66. agendaTwoDay: {
  67. type: 'agenda',
  68. dayCount: 2,
  69. dateIncrement: { days: 1 },
  70. buttonText: '2 days'
  71. }
  72. }
  73. })
  74. currentCalendar.prev()
  75. expectActiveRange('2018-06-08', '2018-06-12')
  76. })
  77. })