From dad6a6f9f2bb98f3fd3f27ed90e58d356b9f99e1 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 22 May 2017 09:27:58 -0700 Subject: [PATCH] Don't assume that save is synchronous in specs --- spec/whitespace-spec.coffee | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/spec/whitespace-spec.coffee b/spec/whitespace-spec.coffee index 6e1a513..22d98f9 100644 --- a/spec/whitespace-spec.coffee +++ b/spec/whitespace-spec.coffee @@ -347,9 +347,12 @@ describe "Whitespace", -> buffer.setText("foo \nbar\t \n\nbaz") it "saves the file without removing any trailing whitespace", -> - atom.commands.dispatch(workspaceElement, 'whitespace:save-with-trailing-whitespace') - expect(buffer.getText()).toBe "foo \nbar\t \n\nbaz" - expect(buffer.isModified()).toBe false + waitsFor (done) -> + buffer.onDidSave -> + expect(buffer.getText()).toBe "foo \nbar\t \n\nbaz" + expect(buffer.isModified()).toBe false + done() + atom.commands.dispatch(workspaceElement, 'whitespace:save-with-trailing-whitespace') describe "when the 'whitespace:save-without-trailing-whitespace' command is run", -> beforeEach -> @@ -358,9 +361,12 @@ describe "Whitespace", -> buffer.setText("foo \nbar\t \n\nbaz") it "saves the file and removes any trailing whitespace", -> - atom.commands.dispatch(workspaceElement, 'whitespace:save-without-trailing-whitespace') - expect(buffer.getText()).toBe "foo\nbar\n\nbaz" - expect(buffer.isModified()).toBe false + waitsFor (done) -> + buffer.onDidSave -> + expect(buffer.getText()).toBe "foo\nbar\n\nbaz" + expect(buffer.isModified()).toBe false + done() + atom.commands.dispatch(workspaceElement, 'whitespace:save-without-trailing-whitespace') describe "when the 'whitespace:convert-tabs-to-spaces' command is run", -> it "removes leading \\t characters and replaces them with spaces using the configured tab length", ->