Quellcode durchsuchen

Merge branch 'getEventSources' into refetchEvents-filter

Casey Holzer vor 9 Jahren
Ursprung
Commit
3bd2425ab1
2 geänderte Dateien mit 51 neuen und 1 gelöschten Zeilen
  1. 7 1
      src/EventManager.js
  2. 44 0
      tests/automated/getEventSources.js

+ 7 - 1
src/EventManager.js

@@ -18,6 +18,7 @@ function EventManager(options) { // assumed to be a calendar
 	t.isFetchNeeded = isFetchNeeded;
 	t.fetchEvents = fetchEvents;
 	t.fetchEventSources = fetchEventSources;
+	t.getEventSources = getEventSources;
 	t.addEventSource = addEventSource;
 	t.removeEventSource = removeEventSource;
 	t.updateEvent = updateEvent;
@@ -242,7 +243,12 @@ function EventManager(options) { // assumed to be a calendar
 	
 	/* Sources
 	-----------------------------------------------------------------------------*/
-	
+
+
+	function getEventSources() {
+		return sources.slice(1); // returns a shallow copy of sources with stickySource removed
+	}
+
 
 	function addEventSource(sourceInput) {
 		var source = buildEventSource(sourceInput);

+ 44 - 0
tests/automated/getEventSources.js

@@ -0,0 +1,44 @@
+describe('getEventSources', function() {
+	var options;
+	var calendarEl;
+
+	beforeEach(function() {
+		affix('#cal');
+		calendarEl = $('#cal');
+		options = {
+			now: '2015-08-07',
+			defaultView: 'agendaWeek',
+			eventSources: [
+				{
+					events: [
+						{ id: 1, start: '2015-08-07T02:00:00', end: '2015-08-07T03:00:00', title: 'event A' }
+					]
+				},
+				{
+					events: [
+						{ id: 2, start: '2015-08-07T03:00:00', end: '2015-08-07T04:00:00', title: 'event B' }
+					]
+				},
+				{
+					events: [
+						{ id: 3, start: '2015-08-07T04:00:00', end: '2015-08-07T05:00:00', title: 'event C' }
+					]
+				}
+			]
+		};
+	});
+
+	it('does not mutate when removeEventSource is called', function(done) {
+		var eventSources;
+
+		calendarEl.fullCalendar(options);
+
+		eventSources = calendarEl.fullCalendar('getEventSources');
+		expect(eventSources.length).toBe(3);
+
+		calendarEl.fullCalendar('removeEventSource', eventSources[0]);
+		expect(eventSources.length).toBe(3);
+
+		done();
+	});
+});