From f4371efb7442cf3c680cf42230a963325ca3fba8 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 2 Jan 2017 11:31:43 -0800 Subject: [PATCH] Fix usages of destroyed buffers in specs --- spec/text-editor-spec.coffee | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/spec/text-editor-spec.coffee b/spec/text-editor-spec.coffee index c2f66a5e2..2432a66b0 100644 --- a/spec/text-editor-spec.coffee +++ b/spec/text-editor-spec.coffee @@ -4325,15 +4325,10 @@ describe "TextEditor", -> expect(editor.getLastSelection().isEmpty()).toBeTruthy() it "does not explode if the current language mode has no comment regex", -> - editor.destroy() - - waitsForPromise -> - atom.workspace.open(null, autoIndent: false).then (o) -> editor = o - - runs -> - editor.setSelectedBufferRange([[4, 5], [4, 5]]) - editor.toggleLineCommentsInSelection() - expect(buffer.lineForRow(4)).toBe " while(items.length > 0) {" + editor = new TextEditor(buffer: new TextBuffer(text: 'hello')) + editor.setSelectedBufferRange([[0, 0], [0, 5]]) + editor.toggleLineCommentsInSelection() + expect(editor.lineTextForBufferRow(0)).toBe "hello" it "does nothing for empty lines and null grammar", -> runs -> @@ -5056,11 +5051,13 @@ describe "TextEditor", -> describe ".destroy()", -> it "destroys marker layers associated with the text editor", -> + buffer.retain() selectionsMarkerLayerId = editor.selectionsMarkerLayer.id foldsMarkerLayerId = editor.displayLayer.foldsMarkerLayer.id editor.destroy() expect(buffer.getMarkerLayer(selectionsMarkerLayerId)).toBeUndefined() expect(buffer.getMarkerLayer(foldsMarkerLayerId)).toBeUndefined() + buffer.release() it "notifies ::onDidDestroy observers when the editor is destroyed", -> destroyObserverCalled = false