weekNumberCalculation.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. describe('weekNumberCalculation', function() {
  2. pushOptions({
  3. weekNumbers: true
  4. })
  5. function getRenderedWeekText() {
  6. // works for both kinds of views
  7. return $('.fc-agenda-view .fc-week-number, .fc-week:first .fc-content-skeleton .fc-week-number').text()
  8. }
  9. function getRenderedWeekNumber() {
  10. var text = getRenderedWeekText() || ''
  11. return parseInt(text.replace(/\D/g, ''), 10)
  12. }
  13. [ 'basicDay', 'agendaDay' ].forEach(function(viewType) {
  14. describe('when in ' + viewType + ' view', function() {
  15. pushOptions({
  16. defaultView: viewType
  17. })
  18. it('should display the American standard when using \'local\'', function() {
  19. initCalendar({
  20. defaultDate: '2013-11-23', // a Saturday
  21. weekNumberCalculation: 'local'
  22. })
  23. expect(getRenderedWeekNumber()).toBe(47)
  24. })
  25. it('should display a locale-specific local week number', function() {
  26. initCalendar({
  27. defaultDate: '2013-11-23', // a Saturday
  28. locale: 'ar',
  29. weekNumberCalculation: 'local'
  30. })
  31. expect(getRenderedWeekText()).toMatch(/٤٨|48/)
  32. })
  33. // another local test, but to make sure it is different from ISO
  34. it('should display the American standard when using \'local\'', function() {
  35. initCalendar({
  36. defaultDate: '2013-11-17', // a Sunday
  37. weekNumberCalculation: 'local'
  38. })
  39. expect(getRenderedWeekNumber()).toBe(47)
  40. })
  41. it('should display ISO standard when using \'ISO\'', function() {
  42. initCalendar({
  43. defaultDate: '2013-11-17', // a Sunday
  44. weekNumberCalculation: 'ISO'
  45. })
  46. expect(getRenderedWeekNumber()).toBe(46)
  47. })
  48. it('should display the calculated number when a custom function', function() {
  49. initCalendar({
  50. weekNumberCalculation: function() {
  51. return 4
  52. }
  53. })
  54. expect(getRenderedWeekNumber()).toBe(4)
  55. })
  56. })
  57. })
  58. })