Przeglądaj źródła

prevent massive memory leaks when automated tests run

Adam Shaw 11 lat temu
rodzic
commit
16b3c4f871
2 zmienionych plików z 13 dodań i 2 usunięć
  1. 7 2
      tests/automated/eventDestroy.js
  2. 6 0
      tests/lib/jasmine-ext.js

+ 7 - 2
tests/automated/eventDestroy.js

@@ -10,12 +10,17 @@ describe('eventDestroy', function() {
 	});
 
 	function testSingleEvent(singleEventData, done) {
+		var callCnt = 0;
+
 		expect(singleEventData.id).toBeTruthy();
 		options.events = [ singleEventData ];
 		options.eventDestroy = function(event, element) {
-			expect(event.id).toBe(singleEventData.id);
-			done();
+			if (callCnt++ === 0) { // only care about the first call. gets called again when calendar is destroyed
+				expect(event.id).toBe(singleEventData.id);
+				done();
+			}
 		};
+
 		$('#cal').fullCalendar(options);
 		$('#cal').fullCalendar('removeEvents', singleEventData.id);
 	}

+ 6 - 0
tests/lib/jasmine-ext.js

@@ -159,3 +159,9 @@ beforeEach(function() {
 	}
 
 });
+
+// Destroy the calendar afterwards, to prevent memory leaks
+// (not the best place for this)
+afterEach(function() {
+	$('#calendar,#cal').fullCalendar('destroy'); // common id's for calendars in tests
+});