From 3a776347ffa0b40b04678f16d2c908a5db8b4fa8 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Tue, 5 Jun 2012 14:23:34 -0600 Subject: [PATCH] Avoid leaking window resize subscriptions in editor spec --- spec/app/editor-spec.coffee | 9 ++++++++- src/app/editor.coffee | 2 -- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/spec/app/editor-spec.coffee b/spec/app/editor-spec.coffee index faeb46571..ba21544ba 100644 --- a/spec/app/editor-spec.coffee +++ b/spec/app/editor-spec.coffee @@ -35,6 +35,9 @@ describe "Editor", -> editor.enableKeymap() editor.isFocused = true + afterEach -> + editor.remove() + describe "construction", -> it "assigns an empty buffer and correctly handles text input (regression coverage)", -> editor = new Editor @@ -74,6 +77,7 @@ describe "Editor", -> newEditor.attachToDom() expect(newEditor.scrollTop()).toBe editor.scrollTop() expect(newEditor.scrollView.scrollLeft()).toBe 44 + newEditor.remove() describe ".setBuffer(buffer)", -> it "sets the cursor to the beginning of the file", -> @@ -462,6 +466,7 @@ describe "Editor", -> otherEditor.simulateDomAttachment() expect(otherEditor.setSoftWrapColumn).toHaveBeenCalled() + otherEditor.remove() describe "when some lines at the end of the buffer are not visible on screen", -> beforeEach -> @@ -2627,7 +2632,7 @@ describe "Editor", -> describe "when inside a pane", -> fakePane = null beforeEach -> - fakePane = { splitUp: jasmine.createSpy('splitUp').andReturn {} } + fakePane = { splitUp: jasmine.createSpy('splitUp').andReturn({}), remove: -> } spyOn(editor, 'pane').andReturn(fakePane) it "calls the corresponding split method on the containing pane with a copy of the editor", -> @@ -2636,6 +2641,7 @@ describe "Editor", -> [editorCopy] = fakePane.splitUp.argsForCall[0] expect(editorCopy.serialize()).toEqual editor.serialize() expect(editorCopy).not.toBe editor + editorCopy.remove() describe "when not inside a pane", -> it "does not split the editor, but doesn't throw an exception", -> @@ -2651,6 +2657,7 @@ describe "Editor", -> editor.trigger 'close' expect(editor.remove).toHaveBeenCalled() + editor.remove() editor = new Editor(mini: true) spyOn(editor, 'remove') editor.trigger 'close' diff --git a/src/app/editor.coffee b/src/app/editor.coffee index f260dbb43..cd80b42c4 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -228,8 +228,6 @@ class Editor extends View else @gutter.addClass('drop-shadow') - $(window).on "resize.editor#{@id}", => - @updateRenderedLines() afterAttach: (onDom) -> return if @attached or not onDom