removeEventSources.js 1.1 KB

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