constructor.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. describe('constructor', function() {
  2. beforeEach(function() {
  3. affix('#calendar');
  4. });
  5. it('should return a jQuery object for chaining', function() {
  6. var res = $('#calendar').fullCalendar();
  7. expect(res instanceof jQuery).toBe(true);
  8. });
  9. it('should not modify the options object', function() {
  10. var options = {
  11. defaultView: 'agendaWeek',
  12. scrollTime: '09:00:00',
  13. slotDuration: { minutes: 45 }
  14. };
  15. var optionsCopy = $.extend({}, options, true);
  16. $('#calendar').fullCalendar(options);
  17. expect(options).toEqual(optionsCopy);
  18. });
  19. it('should not modify the events array', function() {
  20. var options = {
  21. defaultView: 'month',
  22. defaultDate: '2014-05-27',
  23. events: [
  24. {
  25. title: 'mytitle',
  26. start: '2014-05-27'
  27. }
  28. ]
  29. };
  30. var optionsCopy = $.extend(true, {}, options); // recursive copy
  31. $('#calendar').fullCalendar(options);
  32. expect(options).toEqual(optionsCopy);
  33. });
  34. it('should not modify the eventSources array', function() {
  35. var options = {
  36. defaultView: 'month',
  37. defaultDate: '2014-05-27',
  38. eventSources: [
  39. { events: [
  40. {
  41. title: 'mytitle',
  42. start: '2014-05-27'
  43. }
  44. ] }
  45. ]
  46. };
  47. var optionsCopy = $.extend(true, {}, options); // recursive copy
  48. $('#calendar').fullCalendar(options);
  49. expect(options).toEqual(optionsCopy);
  50. });
  51. describe('when called on a div', function() {
  52. beforeEach(function() {
  53. $('#calendar').fullCalendar();
  54. });
  55. it('should contain a table fc-toolbar', function() {
  56. var header = $('#calendar > .fc-toolbar');
  57. expect(header[0]).not.toBeUndefined();
  58. });
  59. it('should contain a div fc-view-container', function() {
  60. var content = ($('#calendar > .fc-view-container'));
  61. expect(content[0]).not.toBeUndefined();
  62. });
  63. it('should only contain 2 elements', function() {
  64. var calenderNodeCount = $('#calendar >').length;
  65. expect(calenderNodeCount).toEqual(2);
  66. });
  67. describe('and then called again', function() {
  68. it('should still only have a single set of calendar [header,content]', function() {
  69. $('#calendar').fullCalendar();
  70. var count = $('#calendar >').length;
  71. expect(count).toEqual(2);
  72. });
  73. });
  74. });
  75. });