weekNumbers.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. describe('weekNumbers', function() {
  2. var options;
  3. var counts;
  4. beforeEach(function() {
  5. affix('#cal');
  6. counts = {};
  7. options = {};
  8. });
  9. afterEach(function() {
  10. $('#cal').fullCalendar('destroy');
  11. });
  12. describe('when using month view', function() {
  13. beforeEach(function() {
  14. options.defaultView = 'month';
  15. options.fixedWeekCount = true; // will make 6 rows
  16. });
  17. describe('with default weekNumbers', function() { // which is false!
  18. describe('and default weekNumbersWithinDays', function() {
  19. it('should not display week numbers at all', function() {
  20. counts = getCounts();
  21. expect(counts.allWeekNumbers).toEqual(0);
  22. });
  23. });
  24. describe('and weekNumbersWithinDays set to false', function() {
  25. it('should not display week numbers at all', function() {
  26. options.weekNumbersWithinDays = false;
  27. counts = getCounts();
  28. expect(counts.allWeekNumbers).toEqual(0);
  29. });
  30. });
  31. describe('and weekNumbersWithinDays set to true', function() {
  32. it('should not display week numbers at all', function() {
  33. options.weekNumbersWithinDays = true;
  34. counts = getCounts();
  35. expect(counts.allWeekNumbers).toEqual(0);
  36. });
  37. });
  38. });
  39. describe('with weekNumbers to false', function() {
  40. beforeEach(function() {
  41. options.weekNumbers = false;
  42. });
  43. describe('and default weekNumbersWithinDays', function() {
  44. it('should not display week numbers at all', function() {
  45. counts = getCounts();
  46. expect(counts.allWeekNumbers).toEqual(0);
  47. });
  48. });
  49. describe('and weekNumbersWithinDays set to false', function() {
  50. it('should not display week numbers at all', function() {
  51. options.weekNumbersWithinDays = false;
  52. counts = getCounts();
  53. expect(counts.allWeekNumbers).toEqual(0);
  54. });
  55. });
  56. describe('and weekNumbersWithinDays set to true', function() {
  57. it('should not display week numbers at all', function() {
  58. options.weekNumbersWithinDays = true;
  59. counts = getCounts();
  60. expect(counts.allWeekNumbers).toEqual(0);
  61. });
  62. });
  63. });
  64. describe('with weekNumbers to true', function() {
  65. beforeEach(function() {
  66. options.weekNumbers = true;
  67. });
  68. describe('and default weekNumbersWithinDays', function() {
  69. it('should display week numbers along the side only', function() {
  70. counts = getCounts();
  71. // TODO: Is it possible to remove class fc-week-number from
  72. // headers and fillers, bringing allWeekNumbers down to 6?
  73. expect(counts.colWeekNumbers).toEqual(6);
  74. expect(counts.cellWeekNumbers).toEqual(0);
  75. expect(counts.cornerWeekNumbers).toEqual(0);
  76. });
  77. });
  78. describe('and weekNumbersWithinDays set to false', function() {
  79. it('should display week numbers along the side only', function() {
  80. options.weekNumbersWithinDays = false;
  81. counts = getCounts();
  82. // TODO: Is it possible to remove class fc-week-number from
  83. // headers and fillers, bringing allWeekNumbers down to 6?
  84. expect(counts.colWeekNumbers).toEqual(6);
  85. expect(counts.cellWeekNumbers).toEqual(0);
  86. expect(counts.cornerWeekNumbers).toEqual(0);
  87. });
  88. });
  89. describe('and weekNumbersWithinDays set to true', function() {
  90. it('should display week numbers in the day cells only', function() {
  91. options.weekNumbersWithinDays = true;
  92. counts = getCounts();
  93. expect(counts.colWeekNumbers).toEqual(0);
  94. expect(counts.cellWeekNumbers).toEqual(6);
  95. expect(counts.cornerWeekNumbers).toEqual(0);
  96. });
  97. });
  98. });
  99. });
  100. describe('when using basicWeek view', function() {
  101. beforeEach(function() {
  102. options.defaultView = 'basicWeek';
  103. });
  104. describe('with default weekNumbers', function() {
  105. describe('and default weekNumbersWithinDays', function() {
  106. it('should not display week numbers at all', function() {
  107. counts = getCounts();
  108. expect(counts.allWeekNumbers).toEqual(0);
  109. });
  110. });
  111. describe('and weekNumbersWithinDays set to false', function() {
  112. it('should not display week numbers at all', function() {
  113. options.weekNumbersWithinDays = false;
  114. counts = getCounts();
  115. expect(counts.allWeekNumbers).toEqual(0);
  116. });
  117. });
  118. describe('and weekNumbersWithinDays set to true', function() {
  119. it('should not display week numbers at all', function() {
  120. options.weekNumbersWithinDays = true;
  121. counts = getCounts();
  122. expect(counts.allWeekNumbers).toEqual(0);
  123. });
  124. });
  125. });
  126. describe('with weekNumbers to false', function() {
  127. beforeEach(function() {
  128. options.weekNumbers = false;
  129. });
  130. describe('and default weekNumbersWithinDays', function() {
  131. it('should not display week numbers at all', function() {
  132. counts = getCounts();
  133. expect(counts.allWeekNumbers).toEqual(0);
  134. });
  135. });
  136. describe('and weekNumbersWithinDays set to false', function() {
  137. it('should not display week numbers at all', function() {
  138. options.weekNumbersWithinDays = false;
  139. counts = getCounts();
  140. expect(counts.allWeekNumbers).toEqual(0);
  141. });
  142. });
  143. describe('and weekNumbersWithinDays set to true', function() {
  144. it('should not display week numbers at all', function() {
  145. options.weekNumbersWithinDays = true;
  146. counts = getCounts();
  147. expect(counts.allWeekNumbers).toEqual(0);
  148. });
  149. });
  150. });
  151. describe('with weekNumbers to true', function() {
  152. beforeEach(function() {
  153. options.weekNumbers = true;
  154. });
  155. describe('and default weekNumbersWithinDays', function() {
  156. it('should display week numbers along the side only', function() {
  157. counts = getCounts();
  158. // TODO: Is it possible to remove class fc-week-number from
  159. // headers and fillers, bringing allWeekNumbers down to 1?
  160. expect(counts.colWeekNumbers).toEqual(1);
  161. expect(counts.cellWeekNumbers).toEqual(0);
  162. expect(counts.cornerWeekNumbers).toEqual(0);
  163. });
  164. });
  165. describe('and weekNumbersWithinDays set to false', function() {
  166. it('should display week numbers along the side only', function() {
  167. options.weekNumbersWithinDays = false;
  168. counts = getCounts();
  169. // TODO: Is it possible to remove class fc-week-number from
  170. // headers and fillers, bringing allWeekNumbers down to 1?
  171. expect(counts.colWeekNumbers).toEqual(1);
  172. expect(counts.cellWeekNumbers).toEqual(0);
  173. expect(counts.cornerWeekNumbers).toEqual(0);
  174. });
  175. });
  176. describe('and weekNumbersWithinDays set to true', function() {
  177. it('should display week numbers in the day cells only', function() {
  178. options.weekNumbersWithinDays = true;
  179. counts = getCounts();
  180. expect(counts.colWeekNumbers).toEqual(0);
  181. expect(counts.cellWeekNumbers).toEqual(1);
  182. expect(counts.cornerWeekNumbers).toEqual(0);
  183. });
  184. });
  185. });
  186. });
  187. describe('when using an agenda view', function() {
  188. beforeEach(function() {
  189. options.defaultView = 'agendaWeek';
  190. });
  191. describe('with default weekNumbers', function() {
  192. describe('and default weekNumbersWithinDays', function() {
  193. it('should not display week numbers at all', function() {
  194. counts = getCounts();
  195. expect(counts.allWeekNumbers).toEqual(0);
  196. });
  197. });
  198. describe('and weekNumbersWithinDays set to false', function() {
  199. it('should not display week numbers at all', function() {
  200. options.weekNumbersWithinDays = false;
  201. counts = getCounts();
  202. expect(counts.allWeekNumbers).toEqual(0);
  203. });
  204. });
  205. describe('and weekNumbersWithinDays set to true', function() {
  206. it('should not display week numbers at all', function() {
  207. options.weekNumbersWithinDays = true;
  208. counts = getCounts();
  209. expect(counts.allWeekNumbers).toEqual(0);
  210. });
  211. });
  212. });
  213. describe('with weekNumbers to false', function() {
  214. beforeEach(function() {
  215. options.weekNumbers = false;
  216. });
  217. describe('and default weekNumbersWithinDays', function() {
  218. it('should not display week numbers at all', function() {
  219. counts = getCounts();
  220. expect(counts.allWeekNumbers).toEqual(0);
  221. });
  222. });
  223. describe('and weekNumbersWithinDays set to false', function() {
  224. it('should not display week numbers at all', function() {
  225. options.weekNumbersWithinDays = false;
  226. counts = getCounts();
  227. expect(counts.allWeekNumbers).toEqual(0);
  228. });
  229. });
  230. describe('and weekNumbersWithinDays set to true', function() {
  231. it('should not display week numbers at all', function() {
  232. options.weekNumbersWithinDays = true;
  233. counts = getCounts();
  234. expect(counts.allWeekNumbers).toEqual(0);
  235. });
  236. });
  237. });
  238. describe('with weekNumbers to true', function() {
  239. beforeEach(function() {
  240. options.weekNumbers = true;
  241. });
  242. describe('and default weekNumbersWithinDays', function() {
  243. it('should display week numbers in the top left corner only', function() {
  244. counts = getCounts();
  245. expect(counts.allWeekNumbers).toEqual(1);
  246. expect(counts.colWeekNumbers).toEqual(0);
  247. expect(counts.cellWeekNumbers).toEqual(0);
  248. expect(counts.cornerWeekNumbers).toEqual(1);
  249. });
  250. });
  251. describe('and weekNumbersWithinDays set to false', function() {
  252. it('should display week numbers in the top left corner only', function() {
  253. options.weekNumbersWithinDays = false;
  254. counts = getCounts();
  255. expect(counts.allWeekNumbers).toEqual(1);
  256. expect(counts.colWeekNumbers).toEqual(0);
  257. expect(counts.cellWeekNumbers).toEqual(0);
  258. expect(counts.cornerWeekNumbers).toEqual(1);
  259. });
  260. });
  261. describe('and weekNumbersWithinDays set to true', function() {
  262. it('should display week numbers in the top left corner only', function() {
  263. options.weekNumbersWithinDays = true;
  264. counts = getCounts();
  265. expect(counts.allWeekNumbers).toEqual(1);
  266. expect(counts.colWeekNumbers).toEqual(0);
  267. expect(counts.cellWeekNumbers).toEqual(0);
  268. expect(counts.cornerWeekNumbers).toEqual(1);
  269. });
  270. });
  271. });
  272. });
  273. function getCounts() {
  274. var t = {};
  275. $('#cal').fullCalendar(options);
  276. t.allWeekNumbers = $('.fc-week-number').length;
  277. t.colWeekNumbers = $('.fc-content-skeleton thead td.fc-week-number').length;
  278. t.cellWeekNumbers = $('.fc-content-skeleton thead .fc-day-top span.fc-week-number').length;
  279. t.cornerWeekNumbers = $('.fc-axis.fc-widget-header.fc-week-number').length;
  280. return t;
  281. }
  282. });