columnFormat.js 7.7 KB

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