columnHeaderFormat.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. describe('columnHeaderFormat', function() {
  2. describe('when columnFormat is not set', function() {
  3. var viewWithFormat = [ { view: 'month', expected: 'Sun', selector: 'th.fc-day-header.fc-sun' },
  4. { view: 'basicWeek', expected: 'Sun 5/11', selector: 'th.fc-day-header.fc-sun' },
  5. { view: 'agendaWeek', expected: 'Sun 5/11', selector: 'th.fc-widget-header.fc-sun' },
  6. { view: 'basicDay', expected: 'Sunday', selector: 'th.fc-day-header.fc-sun' },
  7. { view: 'agendaDay', expected: 'Sunday', selector: 'th.fc-widget-header.fc-sun' } ]
  8. beforeEach(function() {
  9. initCalendar({
  10. defaultDate: '2014-05-11'
  11. })
  12. })
  13. it('should have default values', function() {
  14. for (var i = 0; i < viewWithFormat.length; i++) {
  15. var crtView = viewWithFormat[i]
  16. currentCalendar.changeView(crtView.view)
  17. expect(currentCalendar.el.find(crtView.selector).text()).toBe(crtView.expected)
  18. };
  19. })
  20. })
  21. describe('when columnHeaderFormat is set on a per-view basis', function() {
  22. var viewWithFormat = [ { view: 'month', expected: 'Sunday', selector: 'th.fc-day-header.fc-sun' },
  23. { view: 'basicWeek', expected: 'Sunday 11 - 5', selector: 'th.fc-day-header.fc-sun' },
  24. { view: 'agendaWeek', expected: 'Sunday 11 , 5', selector: 'th.fc-widget-header.fc-sun' },
  25. { view: 'basicDay', expected: 'Sunday 11 | 5', selector: 'th.fc-day-header.fc-sun' },
  26. { view: 'agendaDay', expected: 'Sunday 5/11', selector: 'th.fc-widget-header.fc-sun' } ]
  27. beforeEach(function() {
  28. initCalendar({
  29. defaultDate: '2014-05-11',
  30. views: {
  31. month: { columnHeaderFormat: 'dddd' },
  32. agendaDay: { columnHeaderFormat: 'dddd M/D' },
  33. agendaWeek: { columnHeaderFormat: 'dddd D , M' },
  34. basicDay: { columnHeaderFormat: 'dddd D | M' },
  35. basicWeek: { columnHeaderFormat: 'dddd D - M' }
  36. }
  37. })
  38. })
  39. it('should have the correct values', function() {
  40. for (var i = 0; i < viewWithFormat.length; i++) {
  41. var crtView = viewWithFormat[i]
  42. currentCalendar.changeView(crtView.view)
  43. expect(currentCalendar.el.find(crtView.selector).text()).toBe(crtView.expected)
  44. };
  45. })
  46. })
  47. describe('when locale is French', function() {
  48. var viewWithFormat = [ { view: 'month', expected: 'dim.', selector: 'th.fc-day-header.fc-sun' },
  49. { view: 'basicWeek', expected: 'dim. 11/5', selector: 'th.fc-day-header.fc-sun' },
  50. { view: 'agendaWeek', expected: 'dim. 11/5', selector: 'th.fc-widget-header.fc-sun' },
  51. { view: 'basicDay', expected: 'dimanche', selector: 'th.fc-day-header.fc-sun' },
  52. { view: 'agendaDay', expected: 'dimanche', selector: 'th.fc-widget-header.fc-sun' } ]
  53. beforeEach(function() {
  54. initCalendar({
  55. defaultDate: '2014-05-11',
  56. locale: 'fr'
  57. })
  58. })
  59. it('should have the translated dates', function() {
  60. for (var i = 0; i < viewWithFormat.length; i++) {
  61. var crtView = viewWithFormat[i]
  62. currentCalendar.changeView(crtView.view)
  63. expect(currentCalendar.el.find(crtView.selector).text()).toBe(crtView.expected)
  64. };
  65. })
  66. })
  67. describe('when locale is en-gb', function() {
  68. var viewWithFormat = [ { view: 'month', expected: 'Sun', selector: 'th.fc-day-header.fc-sun' },
  69. { view: 'basicWeek', expected: 'Sun 11/5', selector: 'th.fc-day-header.fc-sun' },
  70. { view: 'agendaWeek', expected: 'Sun 11/5', selector: 'th.fc-widget-header.fc-sun' },
  71. { view: 'basicDay', expected: 'Sunday', selector: 'th.fc-day-header.fc-sun' },
  72. { view: 'agendaDay', expected: 'Sunday', selector: 'th.fc-widget-header.fc-sun' } ]
  73. beforeEach(function() {
  74. initCalendar({
  75. defaultDate: '2014-05-11',
  76. locale: 'en-gb'
  77. })
  78. })
  79. it('should have the translated dates', function() {
  80. for (var i = 0; i < viewWithFormat.length; i++) {
  81. var crtView = viewWithFormat[i]
  82. currentCalendar.changeView(crtView.view)
  83. expect(currentCalendar.el.find(crtView.selector).text()).toBe(crtView.expected)
  84. };
  85. })
  86. })
  87. describe('when locale is Korean', function() {
  88. var viewWithFormat = [ { view: 'month', expected: '일', selector: 'th.fc-day-header.fc-sun' },
  89. { view: 'basicWeek', expected: '일 05.11.', selector: 'th.fc-day-header.fc-sun' },
  90. { view: 'agendaWeek', expected: '일 05.11.', selector: 'th.fc-widget-header.fc-sun' },
  91. { view: 'basicDay', expected: '일요일', selector: 'th.fc-day-header.fc-sun' },
  92. { view: 'agendaDay', expected: '일요일', selector: 'th.fc-widget-header.fc-sun' } ]
  93. beforeEach(function() {
  94. initCalendar({
  95. defaultDate: '2014-05-11',
  96. locale: 'ko'
  97. })
  98. })
  99. it('should have the translated dates and columnHeaderFormat should be computed differently', function() {
  100. for (var i = 0; i < viewWithFormat.length; i++) {
  101. var crtView = viewWithFormat[i]
  102. currentCalendar.changeView(crtView.view)
  103. expect(currentCalendar.el.find(crtView.selector).text()).toBe(crtView.expected)
  104. };
  105. })
  106. })
  107. describe('using custom views', function() {
  108. it('multi-year default only displays day-of-week', function() {
  109. initCalendar({
  110. views: {
  111. multiYear: {
  112. type: 'basic',
  113. duration: { years: 2 }
  114. }
  115. },
  116. defaultView: 'multiYear',
  117. defaultDate: '2014-12-25'
  118. })
  119. expect($('.fc-day-header:first')).toHaveText('Sun')
  120. })
  121. it('multi-month default only displays day-of-week', function() {
  122. initCalendar({
  123. views: {
  124. multiMonth: {
  125. type: 'basic',
  126. duration: { months: 2 }
  127. }
  128. },
  129. defaultView: 'multiMonth',
  130. defaultDate: '2014-12-25'
  131. })
  132. expect($('.fc-day-header:first')).toHaveText('Sun')
  133. })
  134. it('multi-week default only displays day-of-week', function() {
  135. initCalendar({
  136. views: {
  137. multiWeek: {
  138. type: 'basic',
  139. duration: { weeks: 2 }
  140. }
  141. },
  142. defaultView: 'multiWeek',
  143. defaultDate: '2014-12-25'
  144. })
  145. expect($('.fc-day-header:first')).toHaveText('Sun')
  146. })
  147. it('multi-day default displays short full date', function() {
  148. initCalendar({
  149. views: {
  150. multiDay: {
  151. type: 'basic',
  152. duration: { days: 2 }
  153. }
  154. },
  155. defaultView: 'multiDay',
  156. defaultDate: '2014-12-25'
  157. })
  158. expect($('.fc-day-header:first')).toHaveText('Thu 12/25')
  159. })
  160. })
  161. })