Просмотр исходного кода

gcal feed should call loading callback. fixes #3884

Adam Shaw 8 лет назад
Родитель
Сommit
cfa1c69823
2 измененных файлов с 25 добавлено и 0 удалено
  1. 4 0
      src/gcal/GcalEventSource.js
  2. 21 0
      tests/legacy/events-gcal.js

+ 4 - 0
src/gcal/GcalEventSource.js

@@ -25,6 +25,8 @@ var GcalEventSource = EventSource.extend({
 			return Promise.reject();
 		}
 
+		this.calendar.pushLoading();
+
 		return Promise.construct(function(onResolve, onReject) {
 			$.ajax($.extend(
 				{}, // destination
@@ -37,6 +39,8 @@ var GcalEventSource = EventSource.extend({
 						var rawEventDefs;
 						var successRes;
 
+						_this.calendar.popLoading();
+
 						if (responseData.error) {
 							_this.reportError('Google Calendar API: ' + responseData.error.message, responseData.error.errors);
 							onReject();

+ 21 - 0
tests/legacy/events-gcal.js

@@ -298,6 +298,27 @@ describe('Google Calendar plugin', function() {
 		$('#cal').fullCalendar(options);
 	});
 
+	it('calls loading with true then false', function(done) {
+		var cmds = [];
+
+		options.googleCalendarApiKey = API_KEY;
+		options.events =
+			'https://www.googleapis.com/calendar/v3/calendars/usa__en%40holiday.calendar.google.com/events';
+
+		options.loading = function(bool) {
+			cmds.push(bool);
+
+			if (cmds.length === 1) {
+				expect(cmds).toEqual([ true ]);
+			}
+			else if (cmds.length == 2) {
+				expect(cmds).toEqual([ true, false ]);
+				done();
+			}
+		};
+		$('#cal').fullCalendar(options);
+	});
+
 	describe('removeEventSource', function() {
 
 		it('works when specifying only the Google Calendar ID', function(done) {