timeFormat.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. describe('timeFormat', function() {
  2. var options;
  3. beforeEach(function() {
  4. affix('#cal');
  5. options = {
  6. defaultDate: '2014-06-04',
  7. events: [ {
  8. title: 'my event',
  9. start: '2014-06-04T15:00:00',
  10. end: '2014-06-04T17:00:00'
  11. } ]
  12. };
  13. });
  14. function getRenderedEventTime() {
  15. return $('.fc-event:first .fc-time').text();
  16. }
  17. describe('when in month view', function() {
  18. beforeEach(function() {
  19. options.defaultView = 'month';
  20. });
  21. it('renders correctly when default', function() {
  22. $('#cal').fullCalendar(options);
  23. expect(getRenderedEventTime()).toBe('3p');
  24. });
  25. it('renders correctly when default and the locale is customized', function() {
  26. options.locale = 'en-gb';
  27. $('#cal').fullCalendar(options);
  28. expect(getRenderedEventTime()).toBe('15');
  29. });
  30. it('renders correctly when customized', function() {
  31. options.timeFormat = 'Hh:mm:mm';
  32. $('#cal').fullCalendar(options);
  33. expect(getRenderedEventTime()).toBe('153:00:00');
  34. });
  35. });
  36. describe('when in agendaWeek view', function() {
  37. beforeEach(function() {
  38. options.defaultView = 'agendaWeek';
  39. });
  40. it('renders correctly when default', function() {
  41. $('#cal').fullCalendar(options);
  42. expect(getRenderedEventTime()).toBe('3:00 - 5:00');
  43. });
  44. it('renders correctly when default and the locale is customized', function() {
  45. options.locale = 'en-gb';
  46. $('#cal').fullCalendar(options);
  47. expect(getRenderedEventTime()).toBe('15:00 - 17:00');
  48. });
  49. it('renders correctly when customized', function() {
  50. options.timeFormat = 'Hh:mm:mm';
  51. $('#cal').fullCalendar(options);
  52. expect(getRenderedEventTime()).toBe('153:00:00 - 175:00:00');
  53. });
  54. });
  55. describe('when in multi-day custom basic view', function() {
  56. beforeEach(function() {
  57. options.views = {
  58. basicTwoDay: {
  59. type: 'basic',
  60. duration: { days: 2 }
  61. }
  62. };
  63. options.defaultView = 'basicTwoDay';
  64. });
  65. it('defaults to no end time', function() {
  66. $('#cal').fullCalendar(options);
  67. expect(getRenderedEventTime()).toBe('3p');
  68. });
  69. });
  70. describe('when in basicDay view', function() {
  71. beforeEach(function() {
  72. options.defaultView = 'basicDay';
  73. });
  74. it('defaults to showing the end time', function() {
  75. $('#cal').fullCalendar(options);
  76. expect(getRenderedEventTime()).toBe('3p - 5p');
  77. });
  78. });
  79. });