removeEventSources.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. describe('removeEventSources', function() {
  2. var options;
  3. beforeEach(function() {
  4. affix('#cal');
  5. options = {
  6. defaultDate: '2014-08-01',
  7. defaultView: 'agendaDay',
  8. eventSources: [
  9. buildEventSource(1),
  10. buildEventSource(2),
  11. buildEventSource(3)
  12. ]
  13. };
  14. });
  15. describe('when called with no arguments', function() {
  16. it('removes all sources', function() {
  17. $('#cal').fullCalendar(options);
  18. expect($('.fc-event').length).toBe(3);
  19. $('#cal').fullCalendar('removeEventSources');
  20. expect($('.fc-event').length).toBe(0);
  21. });
  22. });
  23. describe('when called with specific IDs', function() {
  24. it('removes only events with matching sources', function() {
  25. $('#cal').fullCalendar(options);
  26. expect($('.fc-event').length).toBe(3);
  27. $('#cal').fullCalendar('removeEventSources', [ 1, 3 ]);
  28. expect($('.fc-event').length).toBe(1);
  29. expect($('.event2').length).toBe(1);
  30. });
  31. });
  32. function buildEventSource(id) {
  33. return {
  34. id: id,
  35. events: function(start, end, timezone, callback) {
  36. callback([ {
  37. title: 'event' + id,
  38. className: 'event' + id,
  39. start: '2014-08-01T02:00:00'
  40. } ]);
  41. }
  42. };
  43. }
  44. });