constructor.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. describe('constructor', function() {
  2. beforeEach(function() {
  3. initCalendar()
  4. })
  5. it('should return a jQuery object for chaining', function() {
  6. var res = $(currentCalendar.el)
  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. initCalendar(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. initCalendar(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. initCalendar(options)
  49. expect(options).toEqual(optionsCopy)
  50. })
  51. describe('when called on a div', function() {
  52. beforeEach(function() {
  53. initCalendar()
  54. })
  55. it('should contain a table fc-toolbar', function() {
  56. var header = $(currentCalendar.el).find('.fc-toolbar')
  57. expect(header[0]).not.toBeUndefined()
  58. })
  59. it('should contain a div fc-view-container', function() {
  60. var content = $(currentCalendar.el).find('.fc-view-container')
  61. expect(content[0]).not.toBeUndefined()
  62. })
  63. it('should only contain 2 elements', function() {
  64. var calenderNodeCount = $(currentCalendar.el).find('>').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. initCalendar()
  70. var count = $(currentCalendar.el).find('>').length
  71. expect(count).toEqual(2)
  72. })
  73. })
  74. })
  75. })