From 16b3c4f87118b5ba3a54a8580e30ac4ddaeafd0c Mon Sep 17 00:00:00 2001 From: Adam Shaw Date: Sun, 24 Aug 2014 20:03:49 -0700 Subject: [PATCH] prevent massive memory leaks when automated tests run --- tests/automated/eventDestroy.js | 9 +++++++-- tests/lib/jasmine-ext.js | 6 ++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/automated/eventDestroy.js b/tests/automated/eventDestroy.js index 6809ff7..ffc43aa 100644 --- a/tests/automated/eventDestroy.js +++ b/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); } diff --git a/tests/lib/jasmine-ext.js b/tests/lib/jasmine-ext.js index 732c6c6..ea622c0 100644 --- a/tests/lib/jasmine-ext.js +++ b/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 +});